Not like in the docs: Gradients in other Colorspaces

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
elmimmo
Posts: 26
Joined: 2011-02-02T05:42:42-07:00
Authentication code: 8675308

Not like in the docs: Gradients in other Colorspaces

Post by elmimmo »

When running any of the two example commands in Gradients in other Colorspaces to create a full rainbow gradient,

Code: Select all

convert -size 30x600 gradient:'#FFF-#0FF' -rotate 90 \
-set colorspace HSB -colorspace RGB \
gradient_rainbow_2.jpg
the result is different depending on whether I output to JPEG or to TIFF. If JPEG, the result is identical to that of the docs; if TIFF, the output is 16 bit and the gradient is not linear: red, green and blue areas are thicker than the colors in between them (yellow, cyan, magenta). Even if I downgrade the bitdepth to 8 bit by appending `-depth 8` either as the first option or the last before the output name, the result is visually identical.

Code: Select all

convert -depth 8 -size 30x600 gradient:'#FFF-#0FF' -rotate 90 \
-set colorspace HSB -colorspace RGB \
gradient_rainbow_2.tif

Code: Select all

convert -size 30x600 gradient:'#FFF-#0FF' -rotate 90 \
-set colorspace HSB -colorspace RGB -depth 8 \
gradient_rainbow_2.tif
I am using this version:

Code: Select all

$ magick -version
Version: ImageMagick 7.0.7-28 Q16 x86_64 2018-03-25 http://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules 
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Not like in the docs: Gradients in other Colorspaces

Post by snibgo »

That documentation was written when IM was different, and it has not been updated.

I suggest you use the "sRGB" colorspace, not "RGB" (which is the linear version of sRGB).

What you see with RGB colorpsace will depend on whether your viewing software recognises linear RGB and converts it to sRGB, or whether it assumes (incorrectly) the image is sRGB.
snibgo's IM pages: im.snibgo.com
elmimmo
Posts: 26
Joined: 2011-02-02T05:42:42-07:00
Authentication code: 8675308

Re: Not like in the docs: Gradients in other Colorspaces

Post by elmimmo »

`-colorspace sRGB` instead of `-colorspace RGB` did indeed fix it. Thanks!
Post Reply