MaestroError / php-heic-to-jpg

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

Cannot convert HEIC to JPG on vps, CentOs 7 #22

Closed treasure567 closed 1 year ago

treasure567 commented 1 year ago

I tested on my windows local machine and everything works fine. But when I push to production, it breaks giving the error below. I'm using this package in a Laravel Application.

Error: Couldn't convert HEIC to JPG: '' | Bin used: 'heicToJpg' HEIC: '\/tmp\/phpZHQoXP' Full Command: '\/home\/azychu\/public_html\/core\/vendor\/maestroerror\/php-heic-to-jpg\/src\/..\/bin\/heicToJpg \"\/tmp\/phpZHQoXP\" \"\/tmp\/phpZHQoXP-82110470764956f66edaa89.28636582\"' Output from heif-converter-image exe: "}

MaestroError commented 1 year ago

Hi, @treasure567 👍 Thanks for reaching out, please try to run /home/azychu/public_html/core/vendor/maestroerror/php-heic-to-jpg/src/../bin/heicToJpg "/tmp/phpZHQoXP" "/tmp/phpZHQoXP-82110470764956f66edaa89.28636582" command on server manually and let me know the output. I think the problem is with permissions, you are trying to convert the "/tmp/phpZHQoXP" file, try to first save the image (move image to the normal location in your project, instead of the global tmp folder) and then run conversation 👍

niravcodeembassy commented 1 year ago

Hi I am getting same issue When I run Command from terminal Getting this error: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/../public_html/vendor/maestroerror/php-heic-to-jpg/src/../bin/heicToJpg

ShoresOfNowhere commented 1 year ago

I second this one, I'm not on Centos but on standard Linux hosting and I have the very same error; shouldn't this be at least stated as a dependency?

Thanks!

MaestroError commented 1 year ago

Hello @ShoresOfNowhere, what OS is standard Linux hosting? Some hosting companies are using CentOS as well 👍

MaestroError commented 1 year ago

@niravcodeembassy It is hard to say what can be the cause of it, try to find out what packages should you install to have GLIBCXX_3.4.21. Or try to set up your php-heic-to-jpg with heif-converter-image, it is an alternative way. For more info, check this docs too

ShoresOfNowhere commented 1 year ago

Hello @ShoresOfNowhere, what OS is standard Linux hosting? Some hosting companies are using CentOS as well 👍

In fact I checkd with my hoster and they are using Centos 7!

ShoresOfNowhere commented 1 year ago

Also, I tried to use heif-converter but this simply returned a similar error, but with TWO different missing libs:

/home/jveqhniy/zunica.cogixo.it/admin/libx/php-heic-to-jpg/src/../bin/heif-converter-linux: /lib64/libc.so.6: version GLIBC_2.34 not found (required by /home/jveqhniy/zunica.cogixo.it/admin/libx/php-heic-to-jpg/src/../bin/heif-converter-linux)

/home/jveqhniy/zunica.cogixo.it/admin/libx/php-heic-to-jpg/src/../bin/heif-converter-linux: /lib64/libc.so.6: version GLIBC_2.32 not found (required by /home/jveqhniy/zunica.cogixo.it/admin/libx/php-heic-to-jpg/src/../bin/heif-converter-linux)

radekmichlik commented 1 year ago

On Debian 10 I have same issue as it is trying to use heicToJpg which doesn't work. I tried php-heic-to-jpg-linux-arm64 via command line and it pass through. However I am not able to tell the application to use this as second parameter converterPath doesn't work to me.

MaestroError commented 1 year ago

Hi @radekmichlik ! Thank you for your feedback! Unfortunately, converterPath is created for specifying the location of heif-converter-image. In your case, if php-heic-to-jpg-linux-arm64 works your debian 10 is arm64 architecture, and it should be detected automatically.

public function checkLinuxOS(): self {
        $os = strtolower(php_uname('s'));
        $arch = strtolower(php_uname('m'));

        if (str_contains($os, 'linux')) {
            $this->os = "linux";
        }

        if (str_contains($arch, "aarch64")){
            $this->arch = "arm64";
        }

        $this->checkLinuxExe();

        return $this;
    }

Please find this function (checkLinuxOS) in your vendor, print the $os and $arch variables and show the results. After finding it, I will fix the issue and draft a new release. You will need just update the package with composer 👍

If we debug it for you, other Debian 10 users will be also thankful ❤️

radekmichlik commented 1 year ago

Hi @MaestroError sure, here it is for Debian 10:

OS: linux Arch: x86_64

I tested it also on Debian 11 and it has same parameters.

Hope it helps.

MaestroError commented 1 year ago

Hi @radekmichlik! Sorry for the late answer. Please check this link out.

uname -m

It says (I also checked) that your x86_64 is the amd64, not arm64. Please, recheck your output!

MaestroError commented 1 year ago

I added a forcing feature for Linux, please check this docs. Just update package to the version 1.0.4 and you will be able to use this feature 👍 @radekmichlik Good luck! Let me know if you will need further help 👍

radekmichlik commented 1 year ago

Ups, you are right. It is indeed amd64 architecture. I tried this once more to be sure but it still shows that it is using heicToJpg

/www/releases/28/vendor/maestroerror/php-heic-to-jpg/src/../bin/heicToJpg

With the new version it is actually working as it is using php-heic-to-jpg-linux-arm64 . I tested it manually also with php-heic-to-jpg-darwin-amd64 and php-heic-to-jpg-darwin-arm64 and it works with both through command line as well. To be honest I am a bit lost at this situation, maybe it gives you a clue :-)

Anyway I have two more things to discuss so I will probably open a new related issues.

Thanks for your work!

MaestroError commented 1 year ago

All is good on this end, so closing this issue. Feel free to open a new one if anything pops up! 😊