libvips / php-vips

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

Pictures lose exif data after being loaded into vips #247

Closed fabianblum closed 1 month ago

fabianblum commented 1 month ago

Hello everyone,

we use vips for our image processing and since the last operating system update from Debian Buster 10 to Bookworm 13 we have the problem that vips loses the exif data (especially the orientation) as soon as the image is loaded. However, it works analogously with imagick without any problems.

We are using

jcupitt/vips: 2.4 libvips: 8.14.5 (I have also tried the latest version but no change)

Here is the snippet

$buffer = file_get_contents('image.jpg');
$vips = Vips\Image::newFromBuffer($buffer);
$vips->writeToFile(__DIR__ . '/output.jpg');

I suspect that some lib is missing or has changed in the version but I couldn't figure out which one is the problem.

I tried libexif and libexiv2, but no improvement.

Do you have any idea whats missing?

Many thanks in advance

jcupitt commented 1 month ago

Huh, strange, it should work. I tried:

$ docker run -it --rm debian:bookworm
root@0e9504526db2:/# apt update && apt upgrade
...
root@0e9504526db2:/# apt install libvips-tools wget --no-install-recommends
...
root@0e9504526db2:/# wget http://www.rollthepotato.net/~john/IMG_0381.jpg
...
root@0e9504526db2:/# vipsheader -a IMG_0381.jpg 
IMG_0381.jpg: 1067x800 uchar, 3 bands, srgb, jpegload
width: 1067
height: 800
bands: 3
format: uchar
coding: none
interpretation: srgb
xoffset: 0
yoffset: 0
xres: 2.83465
yres: 2.83465
filename: IMG_0381.jpg
vips-loader: jpegload
jpeg-multiscan: 0
jpeg-chroma-subsample: 4:2:0
exif-data: 742 bytes of binary data
resolution-unit: in
exif-ifd0-ImageDescription:                                 (                               , ASCII, 32 components, 32 bytes)
exif-ifd0-Make: Canon (Canon, ASCII, 6 components, 6 bytes)
exif-ifd0-Model: Canon PowerShot S90 (Canon PowerShot S90, ASCII, 20 components, 20 bytes)
exif-ifd0-Orientation: 1 (Top-left, Short, 1 components, 2 bytes)
exif-ifd0-XResolution: 72/1 (72, Rational, 1 components, 8 bytes)
exif-ifd0-YResolution: 72/1 (72, Rational, 1 components, 8 bytes)
exif-ifd0-ResolutionUnit: 2 (Inch, Short, 1 components, 2 bytes)
...
root@0e9504526db2:/# vipsheader --version
vips-8.14.1

So it has all the exif data.

Maybe you have several libvips on your system, and one of them has been built without libexif?

fabianblum commented 1 month ago

While building vips

curl -sL https://github.com/libvips/libvips/releases/download/v8.14.5/vips-8.14.5.tar.xz -o vips.tar.xz \
  && tar xf vips.tar.xz \
  && cd vips-8.14.5 \
  && meson setup build --buildtype=release --libdir=lib -Dintrospection=false  \

i get this, i think that is the problem

image

The build cant find the exif-header, but i can see it image

and libexif is on the same spot image

jcupitt commented 1 month ago

That message is normal, it's just a workaround for an annoying inconsistency in libexif packaging.

Your php is probably finding a different libvips at runtime that has been built without libexif support. I'd remove all libvips installs except the one you really want to use.

fabianblum commented 1 month ago

Thank you very much for your help and input. I have now been able to solve the problem. Strangely enough, it was the libmagickcore which was installed in two versions. After I removed the older version, it worked without any problems