MaestroError/php-heic-to-jpg

Compatible with Ubuntu?

DanielGSoftware opened this issue ยท 19 comments

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?

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?

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 ? ๐Ÿ˜„

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.

@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 ๐Ÿ‘

When executed with heicToJpg binary:

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

. -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.

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

@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

@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

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

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.

@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 ๐Ÿ‘

@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.

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

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

@DanielGSoftware Thank you very much for your contribution โค๏ธ

@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 :)

@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!

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 ๐Ÿ‘