Search code examples
bashimagemagickimagemagick-convert

how to insert text in images sequentially in a directory


I have tried the following:

n=1
for index in image*.png; 
do convert $index -fill white  -undercolor '#00000080'  -gravity South -pointsize 44 -annotate +0+550 “image`echo $n`”;
((n++)); 
done

This results in an error:

convert: `“image1”' @ error/convert.c/ConvertImageCommand/3272.

and so on till the end of all image files in the directory.

Basically I'm trying to insert text as the filename in the image.


Solution

  • Your plain double quotes around “imageecho $n” have been replaced by opening/closing double quotes(*). Also, the echo is unnecessary, try "image$n.png"

    (*) possibly the deed of an editor not meant to edit code, editing with Wordpad perhaps?