Skip to content

LCHab not correctly supported with -fill #8093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ace-dent opened this issue Apr 10, 2025 · 3 comments
Open

LCHab not correctly supported with -fill #8093

ace-dent opened this issue Apr 10, 2025 · 3 comments

Comments

@ace-dent
Copy link

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.

@ace-dent
Copy link
Author

Colors may be conveniently tested using online calculators such as https://www.easyrgb.com/en/convert.php

@dlemstra
Copy link
Member

dlemstra commented Apr 10, 2025

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)

@ace-dent
Copy link
Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants