unrecognized color error

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
mikmach
Posts: 42
Joined: 2015-02-06T07:50:43-07:00
Authentication code: 6789

unrecognized color error

Post by mikmach » 2018-12-29T14:31:48-07:00

Hello,

ImageMagick: Version: ImageMagick 7.0.8-8 Q16 x64 2018-07-23 (for MS-Windows)
Windows 8.1
cygwin - zsh 5.5.1

I'd like to create most color pallette for image and following some examples I've got to:

Code: Select all

magick convert -size 100x100 $(magick convert IMG_20181112_055511.jpg -format %c -colorspace HSB -colors 10 histogram:info:- | sort -n -r | awk '{print $NF}' | sed -e 's/\r//g' | sed -e 's/srgb/xc:"rgb/' -e 's/)/)"/' | paste -sd' ') +append pallette0.png
Part in $() is for extraction colors from histogram, ordering it and getting rid of some cygwin/windows/newline stuff, when redirected to file it is in form:

Code: Select all

xc:"rgb(18,17,17)" xc:"rgb(163,164,169)" xc:"rgb(216,213,211)" xc:"rgb(180,186,197)" xc:"rgb(82,80,84)" xc:"rgb(188,195,206)" xc:"rgb(211,175,156)" xc:"rgb(147,129,124)" xc:"rgb(232,207,178)" xc:"rgb(192,191,193)"
When using first chunk I get:

Code: Select all

convert: unrecognized color `"rgb(18,17,17)"' @ warning/color.c/QueryColorCompliance/2394.
convert: unrecognized color `"rgb(163,164,169)"' @ warning/color.c/QueryColorCompliance/2394.
convert: unrecognized color `"rgb(216,213,211)"' @ warning/color.c/QueryColorCompliance/2394.
convert: unrecognized color `"rgb(180,186,197)"' @ warning/color.c/QueryColorCompliance/2394.
convert: unrecognized color `"rgb(82,80,84)"' @ warning/color.c/QueryColorCompliance/2394.
convert: unrecognized color `"rgb(188,195,206)"' @ warning/color.c/QueryColorCompliance/2394.
convert: unrecognized color `"rgb(211,175,156)"' @ warning/color.c/QueryColorCompliance/2394.
convert: unrecognized color `"rgb(147,129,124)"' @ warning/color.c/QueryColorCompliance/2394.
convert: unrecognized color `"rgb(232,207,178)"' @ warning/color.c/QueryColorCompliance/2394.
convert: unrecognized color `"rgb(192,191,193)"' @ warning/color.c/QueryColorCompliance/2394.
When pasting second chunk into command line everything works as intended, just when using it directly (or even `cat`ing it from temp file).

It also happens when extracting hex color values (like #93817C). If it was purely weird stuff on border of Windows ImageMagick version and cygwin it should fail with last color value (192,191,193) - not all of them separately

Any help please?

snibgo
Posts: 11207
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: unrecognized color error

Post by snibgo » 2018-12-29T15:01:05-07:00

Why do you have double-quotes? Try removing them.
snibgo's IM pages: im.snibgo.com

mikmach
Posts: 42
Joined: 2015-02-06T07:50:43-07:00
Authentication code: 6789

Re: unrecognized color error

Post by mikmach » 2018-12-29T15:01:53-07:00

I've found alternative:

Code: Select all

magick convert IMG_20181112_055511.jpg +dither -colors 10 -unique-colors -filter box -resize 3000% pdither.png
But I'd like to solve original problem - going through histogram gives some more options for color choosing.

TIA

snibgo
Posts: 11207
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: unrecognized color error

Post by snibgo » 2018-12-29T15:21:30-07:00

milkmach wrote:But I'd like to solve original problem ...
Don't add those quotes. They are not interpreted by the shell but passed to IM, which doesn't expect quotes.
snibgo's IM pages: im.snibgo.com

snibgo
Posts: 11207
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: unrecognized color error

Post by snibgo » 2018-12-29T17:33:40-07:00

wrote:convert: unrecognized color `"rgb(18,17,17)"' @ warning/color.c/QueryColorCompliance/2394.
The warning tells us that IM is trying to interpret a colour that starts with double quotes. No colours start with double quotes.

We can see the problem with pure bash commands. Bash removes the quotes in:

Code: Select all

$ echo asd:"xyz"
asd:xyz
But if we use sed to create the quotes, they are not removed:

Code: Select all

$ echo asd:xyz | sed -e 's/xyz/"xyz"/'
asd:"xyz"
If we use that in a command expansion, they are not removed:

Code: Select all

$ echo $(echo asd:xyz | sed -e 's/xyz/"xyz"/' )
asd:"xyz"
I'm using Cygwin bash on Windows, but I expect the same behaviour on all versions of bash.
snibgo's IM pages: im.snibgo.com

mikmach
Posts: 42
Joined: 2015-02-06T07:50:43-07:00
Authentication code: 6789

Re: unrecognized color error

Post by mikmach » 2018-12-30T03:29:04-07:00

Thank you all so much. Just removing " solved case and when testing on series of images it confirmed my impression. Getting info from histogram gives better results (for me) than use of simple color reduction.

Post Reply