Page 1 of 1

why annoted text backgound color must be opposite to image backgound color

Posted: 2016-12-13T02:07:58-07:00
by JohnShen00
My ImageMagick version: 6.3.9-Q8
OS: Windows 7

Hello,

I was trying to annotate a text to an image, but I found that must have text background color opposite to the image background color, otherwise the text won't show.


[Problem Description]
Say I get two images, one named "bg_white.jpg" (image backgound = white, colorspace = CMYK) and the other named "bg_black.jpg" (image background = black, colorspace = CMYK). The following cmd could have the text show.

# show text for bg_white.jpg

Code: Select all

convert bg_white.jpg -bordercolor White -border 40x40 -font Arial -pointsize 20 -background Black -fill White -gravity South -annotate +0+5 'ThisIsAWhiteBgTest' bg_white_annotated.jpg
(A interesting thing here, although I set "-background Black -fill White", I could actually get white background with black text, in contrast, if I set "-background White -fill Black", I got nothing, this really confused me)

# show text for bg_black.jpg

Code: Select all

convert bg_black.jpg -bordercolor White -border 40x40 -font Arial -pointsize 20 -background White -fill Black -gravity South -annotate +0+5 'ThisIsABlackBgTest' bg_black_annotated.jpg
[Testing Images]
bg_white.jpg (https://www.dropbox.com/s/1l2r3cqbebjsz ... e.jpg?dl=0)
bg_black.jpg (https://www.dropbox.com/s/oj7hfsiblxaht ... k.jpg?dl=0)


[Requirement]
My requirement is simple: add white borders around the image and write some text (in black) on the bottom border.

I was thinking since I had specified "-bordercolor White", so just annotating text with "-fill black" would solve the problem.


[Question]
Did I do something wrong? Is there anyway that always set "-background White -fill Black" to any image to get what I want?

Appreciate for your help.

Best Regards
John

Re: why annoted text backgound color must be opposite to image backgound color

Posted: 2016-12-13T09:52:27-07:00
by snibgo
You are using colour names with CMYK colorspace. But colour names give values for RGB colorspace. When used in CMK, you need the "opposite" names.

Re: why annoted text backgound color must be opposite to image backgound color

Posted: 2016-12-13T09:52:36-07:00
by fmw42
I would suggest you convert your CMYK images to sRGB before trying to process. Some commands in IM expect RGB images and do not work properly for CMYK images.

Re: why annoted text backgound color must be opposite to image backgound color

Posted: 2016-12-13T10:32:13-07:00
by JohnShen00
snibgo wrote:You are using colour names with CMYK colorspace. But colour names give values for RGB colorspace. When used in CMK, you need the "opposite" names.
Thanks a lot for your reply. Then how can I add white background and black text in CMYK?

-background cmyk(0,0,0,0) -fill cmyk(0,0,0,100)

Seems doesn't work for me.

Regards
John

Re: why annoted text backgound color must be opposite to image backgound color

Posted: 2016-12-13T10:39:54-07:00
by GeeMack
JohnShen00 wrote:Thanks a lot for your reply. Then how can I add white background and black text in CMYK?

-background cmyk(0,0,0,0) -fill cmyk(0,0,0,100)

Seems doesn't work for me.
I can't quite tell exactly what you're trying to do, but maybe you should be using "-undercolor" instead of "-background" there.

Re: why annoted text backgound color must be opposite to image backgound color

Posted: 2016-12-13T10:52:26-07:00
by JohnShen00
fmw42 wrote:I would suggest you convert your CMYK images to sRGB before trying to process. Some commands in IM expect RGB images and do not work properly for CMYK images.
Thanks for your suggestion.
I'm working on a project which processes images for advertisement printing. Most of our images are CMYK jpeg, only customers who are not sensitive about color and "lazy" (don't want trouble to deal with CMYK) will accept RGB, in very rare case.
I'm kind of worrying 'CMYK -> RGB -> processing RGB -> CMYK' will cause information lost and distort customer's requirement. So I trend to process CMYK directly.

Any suggestion for processing CMYK directly?

Appreciate for your help

John

Re: why annoted text backgound color must be opposite to image backgound color

Posted: 2016-12-13T10:59:27-07:00
by JohnShen00
GeeMack wrote:
JohnShen00 wrote:Thanks a lot for your reply. Then how can I add white background and black text in CMYK?

-background cmyk(0,0,0,0) -fill cmyk(0,0,0,100)

Seems doesn't work for me.
I can't quite tell exactly what you're trying to do, but maybe you should be using "-undercolor" instead of "-background" there.
Good suggestion. Thanks. will try soon.

Re: why annoted text backgound color must be opposite to image backgound color

Posted: 2016-12-13T13:14:30-07:00
by fmw42
Processing with profiles to convert CMYK to sRGB to CMYK should work fine and give good quality.