LCHab not correctly supported with `-fill`
ImageMagick version
7.1.1-47 Q16-HDRI aarch64 22763
Operating system
MacOS
Operating system, version and so on
15.4 (24E248)
Description
When defining a color with -fill (or +level-colors), a parameter may be passed as lchab() (or other colorspace). No warning or error is issued, so the User can assume this is valid. However, the resulting color is not correct (hue is shifted). Discussed here: #8083.
Either the parameter should be rejected, or ideally the color is correctly calculated from the provided to the current colorspace.
Steps to Reproduce
Minimal test case: A hue=0 in LCHab should be red, but gives green:
magick -size 1x1 xc:'lchab(70,40,0)' -colorspace sRGB txt:
Other hues are also wrong, (e.g. 120˚ should give green, but is drawn as magenta).
It seems rgb() and hsb() work correctly.
@snibgo reported conversion is also broken on #8083 with:
lchuv and OHTA.
Images
Not required.
Colors may be conveniently tested using online calculators such as https://www.easyrgb.com/en/convert.php
The following output also looks incorrect:
magick -size 1x1 xc:lchab(70,40,0) txt:
# ImageMagick pixel enumeration: 1,1,0,65535,lchab
0,0: (45875,43048,32768) #B333A8288000 lchab(70,40.0019,180.003)
It really looks like we are parsing the blue channel incorrectly. It is also happening for this value:
magick -size 1x1 xc:lchab(70,40,20) txt:
# ImageMagick pixel enumeration: 1,1,0,65535,lchab
0,0: (45875,43048,37908) #B333A8289414 lchab(70,40.0019,208.238)
Testing with an older version, 7.0.10-57 Q16 x86_64 (Intel macOS).
magick -size 1x1 xc:'lchab(70,40,20)' txt:
-- Provides correct results.
magick in.png -colorspace RGB -fill 'lchab(80,50,130)' -opaque white out.png
-- Is wrong (replaces white with magenta not green, as seen in current version).