[6.8.6-3] '-colorspace RGB' makes image darker

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
foutrelis
Posts: 3
Joined: 2013-03-24T23:51:49-07:00
Authentication code: 6789

[6.8.6-3] '-colorspace RGB' makes image darker

Post by foutrelis »

On the left is the original image and on the right is the resulting image after being processed with 'convert orig.png -colorspace RGB new.png'.

Image Image

This looks like a bug to me, but I'm not certain what the '-colorspace RGB' option is supposed to do; this switch is automatically added by the sorl-thumbnail package I use to generate thumbnails in a web application.

I'm on Arch Linux x86_64 with custom compiled ImageMagick 6.8.6-3. (Behavior is the same with Arch's ImageMagick 6.8.6-2 package.)

Code: Select all

$ convert --version
Version: ImageMagick 6.8.6-3 2013-07-08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib fontconfig freetype gslib jng jp2 jpeg lcms lqr lzma openexr pango png ps rsvg tiff wmf x xml zlib
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: [6.8.6-3] '-colorspace RGB' makes image darker

Post by fmw42 »

convert orig.png -colorspace RGB new.png
After about IM 6.7.7.7, colospace RGB and sRGB were swapped to be more correct. So by adding -colorspace RGB you are converting an sRGB image to RGB. The latter has a gamma=1 rather than the input sRGB gamma of 0.4545. Thus it will be darker.

See
viewtopic.php?f=4&t=21269


In your example, you do not need to add -colorspace, since your image is already sRGB.
Last edited by fmw42 on 2013-07-08T10:34:11-07:00, edited 2 times in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: [6.8.6-3] '-colorspace RGB' makes image darker

Post by magick »

Try -colorspace sRGB (non-linear) rather than -colorspace RGB (linear).
User avatar
foutrelis
Posts: 3
Joined: 2013-03-24T23:51:49-07:00
Authentication code: 6789

Re: [6.8.6-3] '-colorspace RGB' makes image darker

Post by foutrelis »

Thank you for your responses! I still don't understand something though.

I only noticed the darker output images after upgrading from ImageMagick 6.8.5-10 to 6.8.6-2. I've now also noticed the following:
  • In an image viewer, both output images appear darker. (Mirage and GIMP on Linux, Windows Photo Viewer on Windows 7.)
  • In a web browser only the image produced by ImageMagick 6.8.6-2 appears darker. (Firefox and Chromium on Linux, Chrome on Windows 7.)
What changed between 6.8.5-10 and 6.8.6-2 to cause this change in how the images are displayed in a browser?

You can view the test images here: http://imgur.com/a/v1zpI (Only the third image appears darker when viewed in a browser.)
Last edited by foutrelis on 2013-07-08T12:13:53-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: [6.8.6-3] '-colorspace RGB' makes image darker

Post by fmw42 »

I am not sure. But see also viewtopic.php?f=3&t=23693.

You can track most of the changes at http://www.imagemagick.org/script/changelog.php

Around 6.8.4.0 some other changes to grayscale. So there have been a number of changes. I believe that the 6.8.6.x versions are now pretty stable and correct with respect to colorspace and grayscale.

Also different browsers may show different results unless there is a proper profile assigned to the image.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: [6.8.6-3] '-colorspace RGB' makes image darker

Post by fmw42 »

You can view the test images here: http://imgur.com/a/v1zpI (Only the third image appears darker when viewed in a browser.)
I cannot get in -- they seem to be doing maintenance. I will check later. But please identify the exact command you are using to make those images and provide the input image, so we can test your two versions and the exact command. Then we can look at the verbose information to see what might be the difference.

But as I said before, some browsers treat images differently when trying to interpret png for example without profiles. So it really depends upon the colorspace and the gamma value in the files. Some formats do not store the actual gamma and make assumptions about that as well.

For example if you used -colorspace RGB rather than sRGB on a version of IM after 6.7.7.7, then gamma will be set to 1. Some browsers and other viewers may ignore the gamma value and assume it is 0.4545, which would view lighter (as if you used -colorspace sRGB rather than RGB). RGB should be darker if the gamma=1 and the viewers respect that. If you don't want the darker view, then use -colorspace sRGB or leave -colorspace off if the input is already sRGB.

If you indeed want a linear RGB colorspace, then use a profile such as AdobeRGB (1998).icc. If you want sRGB, then use the sRGB.icc profile. Then the browsers should honor the profiles and they will display the same.

see
http://www.imagemagick.org/Usage/formats/#profiles
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: [6.8.6-3] '-colorspace RGB' makes image darker

Post by fmw42 »

You have uncovered a bug. You are getting a gamma=1 for 68510, but a gamma of 0.4545 for 6860 and onward when using -colorspace RGB

I will report it.
Post Reply