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

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
JohnShen00
Posts: 4
Joined: 2016-12-13T01:15:17-07:00
Authentication code: 1151

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

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
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: why annoted text backgound color must be opposite to image backgound color

Post 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.
JohnShen00
Posts: 4
Joined: 2016-12-13T01:15:17-07:00
Authentication code: 1151

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

Post 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
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

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

Post 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.
JohnShen00
Posts: 4
Joined: 2016-12-13T01:15:17-07:00
Authentication code: 1151

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

Post 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
JohnShen00
Posts: 4
Joined: 2016-12-13T01:15:17-07:00
Authentication code: 1151

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

Processing with profiles to convert CMYK to sRGB to CMYK should work fine and give good quality.
Post Reply