Page 1 of 1

How to batch annotate my images?

Posted: 2013-05-30T10:12:44-07:00
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.

Re: How to batch annotate my images?

Posted: 2013-05-30T13:40:28-07:00
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