ImageMagick Color Management

Announcements pertaining to ImageMagick, or ImageMagick related software. This list is moderated. No discussions here, instead post to the users group instead.
Post Reply
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

ImageMagick Color Management

Post by magick »

ImageMagick always supported color profiles, however, for images without a profile or a declaration of colorspace, ImageMagick assumed linear RGB. With support of the sRGB colorspace in practically every camera made now-a-days, ImageMagick was modified as of version 6.7.7-8 to assume sRGB unless otherwise specified by a color profile or colorspace (e.g. CMYK). In addition, for many of the image formats we assume grayscale is linear. Most image processing algorithms assume a linear colorspace, therefore we recommend you remove the gamma function before certain image processing algorithms are applied. For example,
  • convert myimage.jpg -colorspace rgb -resize 200% -colorspace sRGB mybigimage.jpg
To declare an image is linear RGB rather than sRGB, you can use the set option:
  • convert myimage.jpg -set colorspace RGB myRGBimage.jpg
Post any questions or concerns about these changes to the user or developers forum.

Thanks to Anthony and Fred for their invaluable help in ensuring sRGB support within ImageMagick worked properly. And thanks to http://www.brucelindbloom.com/ for the correct formulations for converting linear RGB to sRGB and back.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: ImageMagick Color Management

Post by anthony »

For examples of doing resizes using linear-RGB colorspace see
IM Examples, Resizing with Colorspace Correction
http://www.imagemagick.org/Usage/resize ... colorspace

The page also goes on to the many filters, options and techniques you can use to improve resizing.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick Color Management

Post by fmw42 »

After IM 6.8.5.4, the -set colorspace RGB, is no longer needed when converting to other colorspaces channels (nor for -colorspace gray).

-colorspace gray is also now equivalent to rec709luma rather than rec601luma to be more consistent with sRGB standards
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick Color Management

Post by fmw42 »

Starting with IM 6.8.6.0 all grayscale colors and grayscale gradients are now non-linear (by default) with gamma=0.4545 rather than the ones with gray(...) being linear with gamma=1 (which was the case from about IM 6.7.8.3).

So the following formats that used to be linear (gamma=1) are now non-linear (gamma=0.4545)

gray(xx)
gray(xx%)
gradient:"gray(xx)-gray(yy)"
gradient:"gray(xx%)-gray(yy%)"

Named grayscale or gradient with named grayscale colors are still non-linear with gamma=0.4545

The only exceptions seems to be in IM 6.8.7.1 where gamma=1 (linear) for both gray(...) and gray(...) gradients
and in IM 6.8.7.2 where only the gray(...) gradients still show gamma=1 (linear), but simple gray(...) colors have gamma=0.4545 (non-linear)

To create linear gray scale colors one can do either:

1) use icc-color(rgb,xx,xx,xx) to get a linear gray

NOTE: that is different from icc-color(srgb,xx,xx,xx) with produces a non-linear gray

see http://www.imagemagick.org/script/color.php

e.g.

convert -size 100x100 xc:"icc-color(rgb,128,128,128)" -format "%[gamma]\n" info:
1



2) use xc:gray -intensity rec709luminance -colorspace gray

e.g.

convert -size 100x100 xc:gray -intensity rec709luminance -colorspace gray -format "%[gamma]\n" info:
1
Post Reply