libvips / php-vips

php binding for libvips
MIT License
618 stars 25 forks source link

Corruption writing files, even to buffer... #248

Closed gmcmicken closed 1 month ago

gmcmicken commented 1 month ago

I'm in the midst of upgrading php to 8.x on amazon linux 2, and while libvips is installed the same as with php 7.x it seems to be writing garbage files. I tried with a simple readFromFile() and writeToFile(), removing all my image processing code and it's still messed up. Before I spend my effort into this - is it something you've seen before?

I installed libvips using a package from the remi repository:

[ec2-user@ip-172-31-49-150 environment]$ yum list | grep vips
vips.x86_64                              8.15.2-1.el7.remi            @remi     
vips-devel.x86_64                        8.15.2-1.el7.remi            @remi     
vips-openslide.x86_64                    8.15.2-1.el7.remi            @remi     
vips-poppler.x86_64                      8.15.2-1.el7.remi            @remi     
vips-tools.x86_64                        8.15.2-1.el7.remi            @remi     
php70-php-pecl-vips.x86_64               1.0.13-2.el7.remi            remi      
php71-php-pecl-vips.x86_64               1.0.13-2.el7.remi            remi      
php72-php-pecl-vips.x86_64               1.0.13-2.el7.remi            remi      
php73-php-pecl-vips.x86_64               1.0.13-2.el7.remi            remi      
php74-php-pecl-vips.x86_64               1.0.13-2.el7.remi            remi      
php80-php-pecl-vips.x86_64               1.0.13-2.el7.remi            remi      
php81-php-pecl-vips.x86_64               1.0.13-2.el7.remi            remi      
php82-php-pecl-vips.x86_64               1.0.13-2.el7.remi            remi      
php83-php-pecl-vips.x86_64               1.0.13-4.el7.remi            remi      
python2-vips.x86_64                      8.7.4-2.el7.remi             remi      
texlive-dvips.noarch                     2:svn29585.0-38.amzn2.0.5    amzn2-core
texlive-dvips-bin.x86_64                 2:svn26509.0-38.20130427_r30134.amzn2.0.5
texlive-dvips-doc.noarch                 2:svn29585.0-38.amzn2.0.5    amzn2-core
vips-heif.x86_64                         8.15.2-1.el7.remi            remi      
vips-magick-gm.x86_64                    8.15.2-1.el7.remi            remi      
vips-magick-im6.x86_64                   8.15.2-1.el7.remi            remi      
vips-magick-im7.x86_64                   8.15.2-1.el7.remi            remi      
vips-python.x86_64                       8.7.0-1.el7.remi             remi   

and then installed php-vips with pecl

[ec2-user@ip-172-31-49-150 environment]$ pecl list | grep vips
vips    1.0.13  stable

which is the same process I did in my php7 environment.

Result: image

jcupitt commented 1 month ago

Hi @gmcmicken,

php-vips hasn't used PECL for a long time. If you want to use PECL, you need the 1.x branch of php-vips:

https://github.com/libvips/php-vips/tree/1.x

Which I think should still work, though I've not tested it for years.

php-vips 2.0 and later have been reworked to use php FFI instead. There's no native component (except for the libvips library itself), with everything in pure PHP. This is supposed to improve reliability and make deployment easier.

I'd just enable ffi and install php-vips 2.x with composer.

gmcmicken commented 1 month ago

Hey thanks, I just found the problem and it's with the file read and not to do with php-vips at all. I would use ffi but this is a managed platform on aws and php is configured without ffi.