JamesHeinrich / phpThumb

phpThumb() - The PHP thumbnail generator
Other
315 stars 97 forks source link

Image changes color after resized with phpThumb #150

Open notom opened 4 years ago

notom commented 4 years ago

I am using phpThumb. I don't know the exact version, it's an old site. But the phpThumbConfigFileVersion is 1.7.15

This is the original image: https://www.kapartments.net/files/actual_images/dsc07639-00072.jpg And this is the phpThumb resized image: https://www.kapartments.net/phpThumb/phpThumb.php?w=1279&src=/files/actual_images/dsc07639-00072.jpg

The configurations are the default ones, but as you can see the colors are quite different. What can be the problem here?

JamesHeinrich commented 4 years ago

The original photo is using the ProPhoto RGB color space, which is getting lost/ignored during processing.

I haven't paid much attention to color spaces. If the image is being processed internally via ImageMagick it may be possible to preserve the colors better (I haven't investigated in detail). If it's using the built-in PHP GD functions then I wouldn't expect it to handle colorspaces well.

twiddly commented 4 years ago

I have same problem with a small fraction of the images. Occasionally, the thumbnail is missing significant amount of color.

I'm also using ImageMagick with phpThumb. How do you determine what color space an image is using?

JamesHeinrich commented 4 years ago

In the OP's sample photo, I see the color profile listed in IrfanView: JPEG, ProPhoto RGB, quality: 90, subsampling ON (2x2) In theory, it should probably be written to the EXIF tag, but EXIF.ColorSpace is set to 65535 (or -1) = "uncalibrated/unknown", so apparently IrfanView is (correctly) reading it from elsewhere, but I'm not sure where. How to determine the color space programmatically, especially if it's not listed in the expected field in EXIF, I don't know.

twiddly commented 3 years ago

This was solved for me by removing EXIF data from the image. In photoshop you can use 'save to web' or use one of the many EXIF removal tools (google it), like ImageOptim.