Negative gray gradients

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Negative gray gradients

Post by snibgo »

Tested with IM v7.0.7-28 HDRI on Windows 8.1.

Negative colours are generally allowed and work fine, eg:

Code: Select all

magick xc:gray(-123%) txt:

# ImageMagick pixel enumeration: 1,1,65535,gray
0,0: (-80608)  #000000000000  gray(-123%)
However, they are apparently not allowed in gradient, eg:

Code: Select all

magick -size 10x1 gradient:gray(-123%)-white txt:

magick: unrecognized color `(' @ warning/color.c/QueryColorCompliance/2394.
magick: unrecognized color `123%)' @ warning/color.c/GetColorCompliance/1050.
magick: no images for write '-write' 'txt:' at CLI arg 2 @ error/operation.c/CLINoImageOperator/4792.
I think they should be allowed, and that this is a simple bug.
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: Negative gray gradients

Post by fmw42 »

What is your expected behavior for any negative color value in HDRI compile?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Negative gray gradients

Post by snibgo »

I forgot to put "-size 10x1" in the gradient example. Now corrected.

I expect the text output to show a gradient between -123% and white (+100%).

A workaround is to use only positive values in the gradient, then subtract:

Code: Select all

magick -size 10x1 gradient:gray(0)-gray(223%) -evaluate subtract 123% txt:

# ImageMagick pixel enumeration: 10,1,65535,gray
0,0: (-80609.3)  #000000000000  gray(-123.002%)
1,0: (-64371.2)  #000000000000  gray(-98.2241%)
2,0: (-48133)  #000000000000  gray(-73.4463%)
3,0: (-31894.9)  #000000000000  gray(-48.6685%)
4,0: (-15656.8)  #000000000000  gray(-23.8908%)
5,0: (581.298)  #024502450245  gray(0.887004%)
6,0: (16819.4)  #41B341B341B3  gray(25.6648%)
7,0: (33057.5)  #812281228122  gray(50.4426%)
8,0: (49295.6)  #C090C090C090  gray(75.2203%)
9,0: (65533.8)  #FFFEFFFEFFFE  gray(99.9981%)
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: Negative gray gradients

Post by fmw42 »

For a constant image

Code: Select all

magick xc:gray(-123%) txt:
What color should that be? I am not clear on why you would want negative colors? Can you explain?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Negative gray gradients

Post by snibgo »

I'm working on a general solution to the recent thread on wavy lines. For this, I will build a displacement map that will interpolate between the wavy lines, but extrapolate beyond them. The wavy lines will be at 0 and 100% of the result, but the image outside the lines might be -30% to +105%. For that, I need a gradient between those values. IM can do this in HDRI, but a syntax bug prevents negative values in "gradient:".
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: Negative gray gradients

Post by fmw42 »

Thanks. I understand.
Post Reply