Page 1 of 1

unrecognized color error

Posted: 2018-12-29T14:31:48-07:00
by mikmach
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?

Re: unrecognized color error

Posted: 2018-12-29T15:01:05-07:00
by snibgo
Why do you have double-quotes? Try removing them.

Re: unrecognized color error

Posted: 2018-12-29T15:01:53-07:00
by mikmach
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

Re: unrecognized color error

Posted: 2018-12-29T15:21:30-07:00
by snibgo
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.

Re: unrecognized color error

Posted: 2018-12-29T17:33:40-07:00
by snibgo
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.

Re: unrecognized color error

Posted: 2018-12-30T03:29:04-07:00
by mikmach
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.