MaestroError / php-heic-to-jpg

The easiest way to convert HEIC images to JPEG with PHP and Laravel framework
MIT License
148 stars 20 forks source link

Compatible with Ubuntu? #14

Closed DanielGSoftware closed 1 year ago

DanielGSoftware commented 1 year ago

Hi @MaestroError, sorry for bothering you again so soon! I managed to successfully integrate the package in our code on my macbook M1. However, once deployed on our QA server (ubuntu), I get the Couldn't convert HEIC to JPG error. I've tried all the different methods and arch params, but I can't seem the get it to work.

Can you confirm that if you know the package should work with ubuntu as the OS?

MaestroError commented 1 year ago

Hi @DanielGSoftware ! No problem with that, you can contact me anytime you need 👍 Yes, it should work on Ubuntu, I wrote it there 😄 I assume that you were using the convertOnMac method on MacOS, did you update it to convert for Linux?

DanielGSoftware commented 1 year ago

Yep, I tried both convertImage and convertImageMac methods, with the last one also changing to arm architecture.

The error I get is: Couldn't convert HEIC to JPG: '' | Bin used: 'php-heic-to-jpg-darwin-amd64' HEIC: '/tmp/phpy4T0gk' error.

Locally it works fine. Any suggestions I could try ? 😄

DanielGSoftware commented 1 year ago

I forced using php-heic-to-jpg-darwin-amd64, heicToJpg or php-heic-to-jpg-darwin-arm64, but all result in the same error unfortunately.

MaestroError commented 1 year ago

@DanielGSoftware There should be a "Full command:" in error, try to use the heicToJpg binary (on Ubuntu), copy that command from the error message and run it manually in the console and let me know the output 👍

DanielGSoftware commented 1 year ago

When executed with heicToJpg binary:

-bash: [secret-path]/vendor/maestroerror/php-heic-to-jpg/src/../bin/heicToJpg: cannot execute binary file: Exec format error
DanielGSoftware commented 1 year ago

. -bash: [secret-path]/vendor/maestroerror/php-heic-to-jpg/src/../bin/heicToJpg: cannot execute binary file: Exec format error

Hey @MaestroError, would you have the opportunity to have a look at this? I tried to debug further, but we're stuck on this unfortunately.

MaestroError commented 1 year ago

Hi @DanielGSoftware ! This error means that the binary is not executable, for example, if you use heicToJpg Linux binary on MacOS and vice versa 👍 So one of the bin files should give you a different error, try the "full command:" with different binaries: php-heic-to-jpg-darwin-amd64 - php-heic-to-jpg-darwin-arm64 and show me the error

DanielGSoftware commented 1 year ago

@MaestroError thanks for the reply :)! I executed full commands using all binaries, but for both amd64 and arm64 I get cannot execute binary file: Exec format error as well :(

-bash: [secret-path]/vendor/maestroerror/php-heic-to-jpg/src/../bin/php-heic-to-jpg-darwin-arm64: cannot execute binary file: Exec format error

-bash: [secret-path]/vendor/maestroerror/php-heic-to-jpg/src/../bin/php-heic-to-jpg-darwin-amd64: cannot execute binary file: Exec format error

MaestroError commented 1 year ago

@DanielGSoftware You are welcome! Hmm.. What platform are you running? 😄 If you tried all these binaries: php-heic-to-jpg-darwin-amd64, heicToJpg and php-heic-to-jpg-darwin-arm64 the only platform left is Windows, or we have here very very strange issue, try heicToJpg.exe

DanielGSoftware commented 1 year ago

Our server runs on an ubuntu image, using 64-bit (Arm) architecture.

I ran heicToJpg.exe, php-heic-to-jpg-darwin-amd64, php-heic-to-jpg-darwin-arm64, and heicToJpg. They all return the same error: cannot execute binary file: Exec format error.

Also, I now understand this error is not directly related to this package, it's a more general error. So thanks again for putting in the effort to help me :). I'll try to do some research on my own too

DanielGSoftware commented 1 year ago

I think it makes sense why I get this error. Running file for all executables will return: heicToJpg: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux) heicToJpg.exe: PE32+ executable (console) x86-64, for MS Windows php-heic-to-jpg-darwin-amd64: Mach-O 64-bit x86_64 executable php-heic-to-jpg-darwin-arm64: Mach-O 64-bit arm64 executable,

All of these are not compatible with ubuntu's arm64.

MaestroError commented 1 year ago

@DanielGSoftware Nice new information! As it seems heicToJpg binary works only on amd64, so maybe I can help you, I will update it with the new binary for Linux/arm64 and some functions, I will let you know about the update 👍

DanielGSoftware commented 1 year ago

@MaestroError just as I read your response, I also managed to compile a new binary file compatible for this. I tested it and... it works! If you want, I can make a PR containing this new file.

MaestroError commented 1 year ago

@DanielGSoftware Yes! That would be nice, Thanks! Just add arm64 (your arch) to the file name and I will integrate it into the PHP 👍

DanielGSoftware commented 1 year ago

@MaestroError thanks! I'll leave the rest up to you :)

MaestroError commented 1 year ago

@DanielGSoftware Thank you very much for your contribution ❤️

DanielGSoftware commented 1 year ago

@MaestroError you're welcome! All that's left is to set this file as the executable for linux arm64 systems. I can make a PR for this later today :)

DanielGSoftware commented 1 year ago

@MaestroError alright, I've begun writing the code. I decided to try to keep it simple just so the code works, but implementing this change felt a bit odd and I'm not fully satisfied with how it looks. I think it's because of how the file is structured, with some decision that have been made in the past. I think there's a lot of room for improvement.

Before I overwhelm you with questions/comments, are you open to start a small discussion about this and maybe we can improve the file structure? I already have some idea's which I think will be a nice add. That's it, thanks again ❤️ . PR will come soon!

MaestroError commented 1 year ago

You are a real surprise @DanielGSoftware! ❤️ Sure, we can discuss any changes 👍 All my free time now is targeted to fix this issue and it will be very helpful if you can help with other updates, so you are welcome! Also, you can create any PR that you think is needed and I will review it. Please, make sure that all tests are passing OK 👍