annotate with inverted text colors?

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
heep
Posts: 6
Joined: 2010-08-26T02:24:56-07:00
Authentication code: 8675308

annotate with inverted text colors?

Post 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?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: annotate with inverted text colors?

Post 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.
heep
Posts: 6
Joined: 2010-08-26T02:24:56-07:00
Authentication code: 8675308

Re: annotate with inverted text colors?

Post by heep »

Thanks. Would there be any sane way to do this with annotate or something similarly simple? The text is just pixel text.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: annotate with inverted text colors?

Post 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.
heep
Posts: 6
Joined: 2010-08-26T02:24:56-07:00
Authentication code: 8675308

Re: annotate with inverted text colors?

Post by heep »

Great work, Fred! Thanks!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: annotate with inverted text colors?

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
heep
Posts: 6
Joined: 2010-08-26T02:24:56-07:00
Authentication code: 8675308

Re: annotate with inverted text colors?

Post by heep »

Good point. Perhaps a shadow under that annotation?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: annotate with inverted text colors?

Post by anthony »

If you are wanting annotation rather than watermarking, look at IM examples, Annotations
http://www.imagemagick.org/Usage/annotating/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply