开发者

Resized image turns green-ish? Any Ideas?

We have a pr开发者_如何学运维etty standard implementation of image resizing in PHP. However, some images are coming out with a greenish-tint.

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

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

I've checked the color profile on the original jpg and it's RGB.

Here's the resize portion of 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);


RGB is not a color profile, it's a color space. Valid color profiles would be (for example) sRGB and Adobe RGB. If you check the images you linked to, you'll see the original has an sRGB IEC61966-2.1 color profile embedded, and the resized has no color profile, so it's going to be shown differently based on which profile it is assumed to have.

Unfortunately, I don't think the GD image functions in PHP pay any attention to the color profile. You can try saving out images for web via Photoshop where they're converted to a generic sRGB profile, or use ImageMagick to do the resizing (which I believe is color profile aware).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜