How to batch annotate my images?

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
ggyyree
Posts: 1
Joined: 2013-05-30T10:08:46-07:00
Authentication code: 6789

How to batch annotate my images?

Post by ggyyree »

I use following codes to batch annotate my images using ImageMagick convert function under Windows7 system.

for %i in (*.png) do convert %i -fill yellow -box green -gravity South -pointsize 20 -annotate +0+0 (a) "%~niAnnotated.png"

My questions are:

1. How to change the annotated text (a) into (a), (b), (c), ... as looping the images?

2. how to add -trim function to remove the white space around the images with annotation. I use the script above with -trim but remove my annotation as well.

Thanks.

Aaron.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to batch annotate my images?

Post by snibgo »

1. IM will use whatever text you specify. This could be an environment variable, in this case set up by the "for" loop. For example, you might have a file containing a list of filenames and captions. Your script could read this file. For each *.png, use the caption if it has one, otherwise use the filename. But this is all about scripting, not ImageMagick.

2. I don't understand the question. If you want to ensure that only white (not green etc) pixels are trimmed, add a white border first:

Code: Select all

convert rose: -fill Yellow -box green -gravity South -pointsize 20 -annotate +0+0 (abc) -bordercolor White -border 1 -trim c.png
snibgo's IM pages: im.snibgo.com
Post Reply