the-ninth Posted December 23, 2010 Share Posted December 23, 2010 Hi Everybody, I am using PHP/GD to resize a photo to a smaller size and my problem is that when I show the result in Firefox, it looks different from the original. The picture has more contrast, especially the dark areas are even darker. When I show the result in Internet Explorer or the Windows Photo Viewer it looks the same as the original photo. The problem also only occurs when I resize the photo with PHP/GD. When I resize it with Adobe Lightroom, then the result looks correct in Firefox and Internet Explorer. Here is an example: With PHP/GD: http://www.the-ninth.com/demo/demo_php.jpg With Adobe Lightroom: http://www.the-ninth.com/demo/demo_lightroom.jpg When comparing the two photos in Firefox you'll see the difference. In IE they look nearly the same. I am using the following functions to resize: ImageCreateFromJpeg to read the original image, ImageCreateTrueColor to create the new image, ImageCopyResampled to write the resized image to the new image and ImageJpeg with quality 100 to save the new image. Before saving I sharpen the new image. However that is not the problem, I already tried without sharpening and the picture still looks different in Firefox. Any ideas what I am doing wrong? Thanks and regards, Robert Quote Link to comment Share on other sites More sharing options...
requinix Posted December 23, 2010 Share Posted December 23, 2010 GD isn't the best at maintaining quality when resizing. Actually quite poor at times. You may not, in fact, be doing anything wrong. Considering using ImageMagick instead - there's a command-line program as well as a PHP extension. Quote Link to comment Share on other sites More sharing options...
the-ninth Posted December 23, 2010 Author Share Posted December 23, 2010 Hi, Actually I am happy with the result as it is shown in Internet Explorer. My problem is just that it looks different in Firefox. Thanks, Robert Quote Link to comment Share on other sites More sharing options...
the-ninth Posted December 23, 2010 Author Share Posted December 23, 2010 Hi, I found the problem: when resizing the photo with GD, the color profile is lost. The original file has sRGB. Firefox takes the system profile if there is no profile in the file. In many cases this is sRGB but I have a calibrated monitor and therefore a custom profile. If I set gfx.color_management.mode to 1 in Firefox, then it takes sRGB per default and the photo looks the same. So the big question is how to I retain the color profile with GD? My provider does not has ImageMagick, so that is not an option. Any ideas? Thanks, Robert Quote Link to comment Share on other sites More sharing options...
the-ninth Posted December 27, 2010 Author Share Posted December 27, 2010 Hi, I had some mistakes in my previous postings, but now I understand the problem better: Internet Explorer does not do color-management, so the image looks the same whether it has a profile or not. The same, but not as I see it in Adobe Lightroom. Firefox does color-management. So if there is a color profile, the image looks exactly like I see it in Adobe Lightroom. If there is none, the image looks like in Internet Explorer. When switching gfx.color_management.mode to 1 then Firefox does color-management, even if there is no profile in the file, it just assumes sRGB. So if the original picture was exported in sRGB, the re-sized one without profile looks correct in mode 1. Since besides Firefox also Safari does color-management and IE9 will do it as well, it was important to me to retain the color profile. I switched my code to ImageMagick, and that works fine. Color profiles are retained when resizing the image. Cheers, Robert Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.