I need to draw some text over a pre-existing image that was saved as CMYK (the final output is for printing). When I specify the fill color for the text, I get it's color compliment (e.g., if I say fill white, I get black ... and vice versa).
If I use annotate, I get the same result.
I've tried using -set colorspace RGB, but then the original CMYK images colors are inverted.
I've created a small self-contained test that demonstrates this:
convert -size 150x150 -border 2x2 xc:"cmyk(0%, 0%, 0%, 0%)" -colorspace cmyk -draw "fill black circle 75,75,75,20 " test.jpg
.... or this one using annotate:
convert -size 200x200 xc:"cmy(0%, 0%, 0%)" -pointsize 40 -fill white -annotate +25+70 'Sammy' test.jpg
(using cmy, or cmyk I get the same results)
The 150x150 square is white (cmyk = 0,0,0,0), as it should be, but the drawn circle is also white (even though I specified black). If I change fill black to fill white, I get a black circle.
.... or in the second case ....
The annotated text is correctly white, but the 200 by 200 square has been inverted to black (even though cmy(0,0,0) should be white. If I specify colorspace as cmy, it stays the same:
convert -size 200x200 xc:"cmy(0%, 0%, 0%)" -colorspace cmy -pointsize 40 -fill white -annotate +25+70 'Sammy' test.jpg
But if I specify the color space as cmyk and make my original square cmyk, I get the correct white square, but then the annotated text is black.
convert -size 200x200 xc:"cmyk(0%, 0%, 0%, 0%)" -colorspace cmyk -pointsize 40 -fill white -annotate +25+70 'Sammy' test.jpg
I cannot for the life of me find the magic settings that will make both objects' colors behave.
No matter what I do, either one (the original image, or the added - drawn or annotated - part) has it's colors inverted.
How can I draw or annotate a CMYK image and not get inverted colors when I do?
(Windows XP SP3 - ImageMagick 6.5.8-3 2009-11-28 Q16)
Chuck
CMYK colors inverted with draw or annotate
-
- Posts: 14
- Joined: 2007-06-25T16:08:06-07:00
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: CMYK colors inverted with draw or annotate
I don't believe that you can draw in any colorspace other than RGB.
I think you need to convert your CMYK image to RGB, draw your colors and if necessary then convert back to CMYK
convert cmykimage -colorspace RGB rgbimage
then draw
then
convert rgbimage-withdrawing -colorspace CMYK cmykimage-withdrawing.
Note however, your get better color preservation if you use profiles rather than just -colorspace. See http://www.imagemagick.org/Usage/formats/#profiles
I think you need to convert your CMYK image to RGB, draw your colors and if necessary then convert back to CMYK
convert cmykimage -colorspace RGB rgbimage
then draw
then
convert rgbimage-withdrawing -colorspace CMYK cmykimage-withdrawing.
Note however, your get better color preservation if you use profiles rather than just -colorspace. See http://www.imagemagick.org/Usage/formats/#profiles
-
- Posts: 14
- Joined: 2007-06-25T16:08:06-07:00
Re: CMYK colors inverted with draw or annotate
Thanks ...I had read that draw had problems (with the K channel, that's why I tried CMY), but I also read that annotate did not (I guess that was wrong). It seems like I'll lose some color accuracy with those two conversions (CMYK->RGB->CMYK), but I'm game to try.
......... Okay ... I tried it.
Once I got some color profiles (http://www.adobe.com/support/downloads/ ... s_win.html) I got it to work. I didn't get perfect results right away, but after trying different profiles the color conversions now look spot on (the final cmyk image colors are a perfect, side by side match with the original.)
I used:
convert cmyk.jpg -profile AdobeRGB1998.icc temp.jpg
... followed by ...
convert temp.jpg -pointsize 50 -draw "gravity north fill white font Lucida-Sans-Regular text 0,125 'Sammy'" -profile USWebUncoated.icc cmyk_back.jpg
** Note: It's important to put the -profile USWebUncoated.icc after the -draw command - and - when I used sRGB.icm and USWebCoatedSWOP.icc the colors did not come back with a perfect match. I needed to use both AdobeRGB1998.icc and USWebUncoated.icc (as above) .
So thank you, muchly. Over one big hurdle.
So now a more basic Imagemagick question, ... can I do the conversion to RGB, then draw, then convert back to CMYK all in one command (without having to create the temp.jpg file on disk)?
Chuck
......... Okay ... I tried it.
Once I got some color profiles (http://www.adobe.com/support/downloads/ ... s_win.html) I got it to work. I didn't get perfect results right away, but after trying different profiles the color conversions now look spot on (the final cmyk image colors are a perfect, side by side match with the original.)
I used:
convert cmyk.jpg -profile AdobeRGB1998.icc temp.jpg
... followed by ...
convert temp.jpg -pointsize 50 -draw "gravity north fill white font Lucida-Sans-Regular text 0,125 'Sammy'" -profile USWebUncoated.icc cmyk_back.jpg
** Note: It's important to put the -profile USWebUncoated.icc after the -draw command - and - when I used sRGB.icm and USWebCoatedSWOP.icc the colors did not come back with a perfect match. I needed to use both AdobeRGB1998.icc and USWebUncoated.icc (as above) .
So thank you, muchly. Over one big hurdle.
So now a more basic Imagemagick question, ... can I do the conversion to RGB, then draw, then convert back to CMYK all in one command (without having to create the temp.jpg file on disk)?
Chuck
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: CMYK colors inverted with draw or annotate
yes, you should!
try
convert cmyk.jpg -profile AdobeRGB1998.icc -pointsize 50 -draw "gravity north fill white font Lucida-Sans-Regular text 0,125 'Sammy'" -profile USWebUncoated.icc cmyk_back.jpg
or
convert -respect-parenthesis \( cmyk.jpg -profile AdobeRGB1998.icc \) -pointsize 50 -draw "gravity north fill white font Lucida-Sans-Regular text 0,125 'Sammy'" -profile USWebUncoated.icc cmyk_back.jpg
try
convert cmyk.jpg -profile AdobeRGB1998.icc -pointsize 50 -draw "gravity north fill white font Lucida-Sans-Regular text 0,125 'Sammy'" -profile USWebUncoated.icc cmyk_back.jpg
or
convert -respect-parenthesis \( cmyk.jpg -profile AdobeRGB1998.icc \) -pointsize 50 -draw "gravity north fill white font Lucida-Sans-Regular text 0,125 'Sammy'" -profile USWebUncoated.icc cmyk_back.jpg
-
- Posts: 14
- Joined: 2007-06-25T16:08:06-07:00
Re: CMYK colors inverted with draw or annotate
Thanks ... (I know that was very basic info). It works fine without the parenthesis, just as you had it.
convert cmyk.jpg -profile AdobeRGB1998.icc -pointsize 50 -draw "gravity north fill white font Lucida-Sans-Regular text 0,125 'Sammy'" -profile USWebUncoated.icc cmyk_back.jpg
Super!
Thanks,
Chuck
convert cmyk.jpg -profile AdobeRGB1998.icc -pointsize 50 -draw "gravity north fill white font Lucida-Sans-Regular text 0,125 'Sammy'" -profile USWebUncoated.icc cmyk_back.jpg
Super!
Thanks,
Chuck