HSB hue value differences

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
arizonagroovejet
Posts: 28
Joined: 2009-01-20T12:37:52-07:00

HSB hue value differences

Post by arizonagroovejet »

I'm seeing a difference in how HSB hue values work between 6.8.8 and how they work on 6.8.9 and 6.9.3.

I've run this

Code: Select all

$ for i in {0..360};do convert -size 10x100  xc:"hsb($i,100%, 50%)" MIFF:-  ;done| montage -tile x1 -geometry +0+0 -  /tmp/hsbmontage.png
on four different Linux distros using the version of ImageMagick that's included with them.

Running it on

Code: Select all

$ head -2 /etc/os-release
NAME="openSUSE Leap"
VERSION="42.2"
$ convert --version
Version: ImageMagick 6.8.8-1 Q16 x86_64 2016-12-23 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fontconfig freetype jng jp2 jpeg lcms ltdl lzma openexr pangocairo png rsvg tiff webp wmf x xml zlib
$
and on

Code: Select all

$ head -2 /etc/os-release
NAME="SLED"
VERSION="12-SP1"
$ convert --version
Version: ImageMagick 6.8.8-1 Q16 x86_64 2016-12-13 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fontconfig freetype jng jp2 jpeg lcms ltdl lzma openexr pangocairo png rsvg tiff webp wmf x xml zlib
$
produces this
http://imgur.com/a/BIm8y
Which does not look how I expected it to from reading the documentation.


Running the same command on

Code: Select all

$ head -2 /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
$ convert --version
Version: ImageMagick 6.8.9-9 Q16 arm 2016-11-27 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib

 $
and on

Code: Select all

$ head -2 /etc/os-release
NAME=Fedora
VERSION="25 (Workstation Edition)"
$ convert --version
Version: ImageMagick 6.9.3-0 Q16 x86_64 2016-05-14 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps rsvg tiff webp wmf x xml zlib
mike@crash:tmp>

produces this
http://imgur.com/a/mNcPS
which looks how I expect.


Was the way HSB hue values work changed between 6.8.8 and 6.8.9? Is there something messed up about openSUSE and SLED ImageMagick packages? Something else?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: HSB hue value differences

Post by snibgo »

It looks like a bug that was fixed.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: HSB hue value differences

Post by fmw42 »

Hue was changed several times. So some versions of IM use percent. Very old versions and new versions use it in the range 0-360.

See http://www.imagemagick.org/script/color.php, where it says:

"For ImageMagick between 6.5.6-6 and 6.9.2-0, HSL (HSB) could only be specified with Hue as percent in range 0—100%, when Saturation and Lightness (Brightness) were also specified as percent in range 0—100%."
arizonagroovejet
Posts: 28
Joined: 2009-01-20T12:37:52-07:00

Re: HSB hue value differences

Post by arizonagroovejet »

fmw42 wrote: 2017-02-03T11:54:03-07:00 "For ImageMagick between 6.5.6-6 and 6.9.2-0, HSL (HSB) could only be specified with Hue as percent in range 0—100%, when Saturation and Lightness (Brightness) were also specified as percent in range 0—100%."
I confess that sentence is slightly further down that page than I'd bothered to previously read.

This produces what I'd expect with 6.8.8 on openSUSE.

Code: Select all

$ for i in {0..360};do convert -size 10x100  xc:"hsb($i,255,127.5)" MIFF:-  ;done| montage -tile x1 -geometry +0+0 -  /tmp/hsbmontage.png

So it seems that in 6.8.8 hue is treated as percentage if saturation and brightness are percentage with values of more than 100 wrapping around (40 140 240 have same value), but it's treated as a 0-360 range if saturation and brightness are specified as integer/float. I'm afraid I'm not clear on whether the quoted sentence is supposed to convey that. Also the page cites different behaviour with regard hue values for 6.5.6-6 and 6.9.2-0 and I'm getting a difference between 6.8.8 and 6.8.9. I guess the documentation is written mostly with current version of ImageMagick in mind rather than whatever out dated version any given Linux distro includes.

Anyway, thanks for your reply as it caused me to figured out how to get the behaviour I expect with 6.8.8.
Post Reply