Page 1 of 1

Negated Text?

Posted: 2009-10-09T17:32:35-07:00
by White
Hello,

How to make negated label? I give you an example:
Image

Thank you!

Re: Negated Text?

Posted: 2009-10-09T17:40:55-07:00
by fmw42
No easy solution that I know about. Best I can think is to make the image twice, once with each text color. Then make a mask with the center horizontal band white and the rest black. Then use the mask to composite the two versions together so that the center uses the image with one text color and the rest of the image comes from the other text color.

see

http://www.imagemagick.org/Usage/compose/
http://www.imagemagick.org/Usage/channels/#masks

Re: Negated Text?

Posted: 2009-10-10T02:42:26-07:00
by White
Before posting I tried this:
With GIMP create mask.png file with transparent background.
After that:

Code: Select all

convert mask.png matte:- | convert - -negate mask2.png
convert mask2.png -fill white -pointsize 45 -draw "rotate -30 gravity Center fill white text 0,0 'Negated Text' " +matte mask3.png
composite -compose CopyOpacity mask3.png image.jpg stamp.png
convert stamp.png -negate negated_stamp.png
composite -gravity center image.jpg negated_stamp.png result.jpg
But result.jpg is just negated image.jpg.

fmw42 I'm not sure that I understand you correctly. Can you give example commands, please!

Re: Negated Text?

Posted: 2009-10-10T10:11:54-07:00
by fmw42
fmw42 I'm not sure that I understand you correctly. Can you give example commands, please!
Here is an example, but it may not be the most efficient. But it works.

# create background
convert -size 500x100 xc:dodgerblue \
-gravity center -background gold -extent 500x300 text_bg.png
Image

# create mask from background
convert text_bg.png -channel blue -separate +channel -threshold 0 text_mask.png
http://www.fmwconcepts.com/misc_tests/t ... t_mask.png

# create text with first color on transparent background
convert -background none -font Candice -pointsize 60 -fill black \
label:'Test Contrast Text' \
-rotate 25 -gravity center -extent 500x300 text1.png
Image

# create text with second color on transparent background
convert -background none -font Candice -pointsize 60 -fill wheat \
label:'Test Contrast Text' \
-rotate 25 -gravity center -extent 500x300 text2.png
Image

# composite both text colors with mask
convert text1.png text2.png text_mask.png -compose over -composite text3.png
Image

# overlay composited text onto background
convert text_bg.png text3.png -compose over -composite text_final.png
Image

Re: Negated Text?

Posted: 2009-10-11T01:00:31-07:00
by anthony
A -compose difference with a black and white mask will selectively negate the other image according to that mask. You can also try using the relatated compose method 'exclusive'.

See IM Examples, Compose, Difference
http://www.imagemagick.org/Usage/compose/#difference

Re: Negated Text?

Posted: 2009-10-11T05:04:07-07:00
by White
I see where is my mistake. The last command from my previous post must be

Code: Select all

convert image.jpg negated_stamp.png -compose over -composite result.jpg
and it works. Thank you fmw42!

Code: Select all

composite mask3.png image.jpg -gravity center -compose difference result.jpg
works too and must be much more efficient.
Thank you anthony!