Does the changed image turn green? Any ideas?

We have a pretty standard image resizing implementation in PHP. However, some images come out with a greenish tint.

Here's the original: http://www.capitallightingfixture.com/product_images/3979WG-514.jpg

Here the size is resized: http://www.capitallightingfixture.com/product_images/5-3979WG-514.jpg

I checked the color profile on the original jpg and RGB.

Here is part of resizing my PHP:

if (function_exists("gd_info")){ $dst_img = imagecreatetruecolor($thumb_width,$thumb_height); }else{ $dst_img = imagecreate($thumb_width,$thumb_height); } if(@imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_width,$thumb_height,$origw,$origh)){ }else{ imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_width,$thumb_height,$origw,$origh); } imagedestroy($src_img); imagejpeg($dst_img, '', 85); 
+4
source share
1 answer

RGB is not a color profile; it is a color space. Valid color profiles are (for example) sRGB and Adobe RGB. If you check the images you contacted, you will see that the original sRGB IEC61966-2.1 color profile is embedded in the original, and the resized one does not have a color profile, so it will be displayed differently based on which profile it supposedly has.

Unfortunately, I do not think that the GD image functions in PHP pay attention to the color profile. You can try to save images for web pages through Photoshop, where they are converted to a common sRGB profile, or use ImageMagick to resize (which, in my opinion, is a color profile).

+4
source

Source: https://habr.com/ru/post/1339272/


All Articles