php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53598 GD does not support color profiles
Submitted: 2010-12-23 12:49 UTC Modified: 2019-09-02 14:34 UTC
Votes:77
Avg. Score:4.6 ± 0.7
Reproduced:70 of 71 (98.6%)
Same Version:43 (61.4%)
Same OS:41 (58.6%)
From: the-ninth at gmx dot com Assigned: pajoye (profile)
Status: Suspended Package: GD related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-12-23 12:49 UTC] the-ninth at gmx dot com
Description:
------------
Hi,

It seems that GD currently does not support embedding color profiles into JPEGs created with ImageJpeg(). The colors of the generated JPEG then look different from the ones in the original JPEG if the browser is color-management-capable and the system uses a different profile than was embedded in the original JPEG.

For example, I have a large image generated by Adobe Lightroom, which has sRGB embedded as profile. The resized photo generated by GD has lost the profile. I am using Firefox and have a calibrated monitor, so the system does not use sRGB per default. In Firefox the resized picture has different colors then the original one. Only if I force Firefox to use sRGB by setting gfx.color_management.mode to 1, the picture looks the same as the original. But obviously I cannot expect this from my website's visitors.

When researching this on the Web I found that many people have that problem but there is no solution in sight. ImageMagick is not an option for me, my hoster does not support it.

It would be great if GD could be extended to allow embedding color profiles into images.

Thanks, Robert


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-23 15:37 UTC] pajoye@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2010-12-23 15:37 UTC] pajoye@php.net
hi,

Can you send me a couple of images with the profile(s) you are referring to please?
 [2010-12-23 15:45 UTC] the-ninth at gmx dot com
Hi,

Check these two pictures:

http://www.the-ninth.com/demo/demo_php.jpg
http://www.the-ninth.com/demo/demo_lightroom.jpg

demo_lightroom.jpg was generated by Adobe Lightroom and contains the profile. Demo.php was generated by GD and does not contain the profile.

To see the difference you need to have a system color profile that is different from sRGB, like you would have with a calibrated monitor. Then if you open them in Firefox you'll see the difference. I think Safari does color management too, so you might see the difference there as well. Maybe also IE9.

If you do not have a calibrated monitor, then probably sRGB is the system default anyway, so in this case Firefox takes sRGB for the picture without the profile and the result is correct.

Thanks, Robert
 [2010-12-23 15:52 UTC] pajoye@php.net
I think I need more visible differences as I don't have a calibration system in place nor a calibrated monitor :P

I will already analyze the delta in the meta information of both images.
 [2010-12-24 01:11 UTC] the-ninth at gmx dot com
Hi,

Try this one: 
http://www.the-ninth.com/demo/demo_php_argb.jpg
http://www.the-ninth.com/demo/demo_lightroom_argb.jpg

It was generated in AdobeRGB color space and the profile was removed during resizing. I assume that your Firefox should display it differently, because for the one from Lightroom it knows that it is AdobeRGB while for the one from PHP/GD it will fall back to sRGB.

But in any case, the essence is that color profiles are a part of images and at least some current browsers rely on this information. At the moment it is FF and Safari, and IE9 will have color-management too. Then the problem will affect the majority of users.

So for the future it would be really helpful if GD would allow to read/write color profiles.

Cheers, Robert
 [2010-12-26 19:22 UTC] pajoye@php.net
-Status: Assigned +Status: Feedback
 [2010-12-26 19:22 UTC] pajoye@php.net
Can you restore the links please? 404 now
 [2010-12-26 19:44 UTC] the-ninth at gmx dot com
-Status: Feedback +Status: Assigned
 [2010-12-26 19:44 UTC] the-ninth at gmx dot com
Sorry, should be back now.

I added one more:
http://www.the-ninth.com/demo/demo_phpim.jpg

This one was re-sized with ImageMagick, which retains the color profile.

Cheers, Robert
 [2011-02-27 10:33 UTC] pulzarraider at gmail dot com
One more example, which shows difference in image with and without color profile. Use Firefox to see the difference:

Original picture (with ICC profil Samsung - Natural Color Pro)
http://fotky.sme.sk/foto/171985/vrak-skeleton-coast

Picture resized with GD2 library (color profile is lost, sRGB used?)
http://fotky.sme.sk/foto/171985/vrak-skeleton-coast?type=v&x=650&y=433
 [2014-05-29 23:23 UTC] rostavanek at gmail dot com
hi i have the same exact problem using OpenCart which uses GD library... i explained everything here:

http://forum.opencart.com/viewtopic.php?f=20&t=125838

essentially most APPLE MACBOOK users that use Firefox will end up with washed out colors for all images that are resized using GD library... the color profile is discarded by GD library and 'Untagged RGB' files are generated by GD library... 

my situation refers to OpenCart because thats where i need to fix the problem...

thanks and BUMP
 [2016-10-17 12:25 UTC] cmb@php.net
Related to bug #55163.
 [2017-01-22 15:16 UTC] cmb@php.net
-Status: Assigned +Status: Suspended
 [2017-01-22 15:16 UTC] cmb@php.net
This is a general libgd issue (not particularly related to PHP's
bundled libgd), and there is already
<https://github.com/libgd/libgd/issues/136>, so I'm suspending
this ticket.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 07:01:28 2024 UTC