Page 1 of 1

annotate with inverted text colors?

Posted: 2011-11-15T09:54:02-07:00
by heep
I would like to put a small watermark on images.

I would like the color of the text to be an inversion of the colors below it, on a pixel by pixel level, thereby insuring it showed up on everything.

Is this possible?

Re: annotate with inverted text colors?

Posted: 2011-11-15T10:55:15-07:00
by Bonzo
I would guess you would need to create a mask of your watermark - select the part of the image your watermark covers - negate it then composite it back. I do not know how good it would look though.

Re: annotate with inverted text colors?

Posted: 2011-11-15T11:00:54-07:00
by heep
Thanks. Would there be any sane way to do this with annotate or something similarly simple? The text is just pixel text.

Re: annotate with inverted text colors?

Posted: 2011-11-15T11:38:47-07:00
by fmw42
try these. as bonzo has suggested, you need to create a mask from your text and use it to composite the image and its negative


convert \( rose: -resize 400% \) \( -clone 0 -negate \) \
\( -clone 0 -fill black -colorize 100% -fill white \
-font arial -pointsize 48 -gravity center -annotate +0+0 "TESTING" \) \
-compose over -composite rose_test.png

convert \( rose: -resize 400% \) \( -clone 0 -negate \) \
\( -clone 0 -fill black -colorize 100% -fill white \
-font arial -pointsize 48 -gravity center -annotate +0+0 "TESTING" \) \
-compose dissolve -define compose:args=50,100 -composite rose_test2.png

I resized the rose: IM internal image to make it larger so that I could use a bigger font for demonstration.

Re: annotate with inverted text colors?

Posted: 2011-11-15T13:05:27-07:00
by heep
Great work, Fred! Thanks!

Re: annotate with inverted text colors?

Posted: 2011-11-15T19:10:52-07:00
by anthony
If you use 'difference' composition with a mask. Black remains normal, white becomes negated.
http://www.imagemagick.org/Usage/compose/#difference

However with any negation method perfect grays will always remain unchanged.

This is which watermarks that both lighten and darken images are often a better option. It removes the possibility of having no effect for some specific color in the image.

Re: annotate with inverted text colors?

Posted: 2011-11-15T19:20:39-07:00
by heep
Good point. Perhaps a shadow under that annotation?

Re: annotate with inverted text colors?

Posted: 2011-11-15T21:48:23-07:00
by anthony
If you are wanting annotation rather than watermarking, look at IM examples, Annotations
http://www.imagemagick.org/Usage/annotating/