possible bug in hsl color creation IM 6.5.6-4 Q16 (HDRI)
Posted: 2009-09-24T12:39:08-07:00
I am not getting consistent color creation when using hsl as percent vs raw values. From the page http://www.imagemagick.org/script/color.php it says for raw values:
"The format of an HSL color value in the functional notation is hsl(h,s,l). The hue value h ranges from 0 to 360. Saturation and lightness (s and l) range from 0 to 255"
So I created a color swatch as follows:
convert -size 100x100 xc:"rgb(238,208,200)" colorswatch.png
Now I measure its hsl colors:
convert colorswatch.png -scale 1x1! -colorspace HSL txt:-
# ImageMagick pixel enumeration: 1,1,65535,hsl
0,0: ( 2299,34588,56283) #08FB871CDBDB hsl(3.50877%,52.7778%,85.8824%)
Now I create a swatch with these HSL percent values:
convert -size 100x100 xc:"hsl(3.50877%,52.7778%,85.8824%)" colorswatch_hsl.png
(This is close but not exactly the same)
Also it is puzzling that http://www.imagemagick.org/script/color.php says to specify an HSL color one should use hue in range of 0-360 NOT percent, but saturation and lightness as percent. So why is hue as specified by txt: above being shown as percent. Is this correct?
If I convert 3.50877% to range 0-360 (eg 3.5*360/100=13) and use that as
convert -size 100x100 xc:"hsl(13,52.7778%,85.8824%)" colorswatch_hsl.png
it actually comes out better than using the percent value as above and listed by txt:
So one potential error is the way that txt: presents the hue value in hsl.
Now I convert the percents to raw values (hue in range 0-360 and saturation and lightness in range 0-255)
convert -size 100x100 xc:"hsl(13,135,219)" colorswatch_hsl2.png
The latter is not even close. What am I missing?
No matter what value I use for hue (I tried 360-13=347), e.g. hsl(347,135,219), I get the same cyan-like color as above.
Am I misreading the documentation above such that one can only specify hsl colors as hue (0-360) and saturation and lightness as percent?
"The format of an HSL color value in the functional notation is hsl(h,s,l). The hue value h ranges from 0 to 360. Saturation and lightness (s and l) range from 0 to 255"
So I created a color swatch as follows:
convert -size 100x100 xc:"rgb(238,208,200)" colorswatch.png
Now I measure its hsl colors:
convert colorswatch.png -scale 1x1! -colorspace HSL txt:-
# ImageMagick pixel enumeration: 1,1,65535,hsl
0,0: ( 2299,34588,56283) #08FB871CDBDB hsl(3.50877%,52.7778%,85.8824%)
Now I create a swatch with these HSL percent values:
convert -size 100x100 xc:"hsl(3.50877%,52.7778%,85.8824%)" colorswatch_hsl.png
(This is close but not exactly the same)
Also it is puzzling that http://www.imagemagick.org/script/color.php says to specify an HSL color one should use hue in range of 0-360 NOT percent, but saturation and lightness as percent. So why is hue as specified by txt: above being shown as percent. Is this correct?
If I convert 3.50877% to range 0-360 (eg 3.5*360/100=13) and use that as
convert -size 100x100 xc:"hsl(13,52.7778%,85.8824%)" colorswatch_hsl.png
it actually comes out better than using the percent value as above and listed by txt:
So one potential error is the way that txt: presents the hue value in hsl.
Now I convert the percents to raw values (hue in range 0-360 and saturation and lightness in range 0-255)
convert -size 100x100 xc:"hsl(13,135,219)" colorswatch_hsl2.png
The latter is not even close. What am I missing?
No matter what value I use for hue (I tried 360-13=347), e.g. hsl(347,135,219), I get the same cyan-like color as above.
Am I misreading the documentation above such that one can only specify hsl colors as hue (0-360) and saturation and lightness as percent?