Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Overlay each line of a text file onto sequentially named image files
#!/bin/bash
#Developed for a very specific case. Your image files must be named 1.jpg, 2.jpg, 3.jpg etc. Place this script, the images files and the text file in the same folder. Then run ./overlaytext.sh. It'll overwrite the original files, so make a backup.
no=1
#change 40 to however many files you have
while [ $no -le 40 ]
#change textfile to whatever text file you have
do text=$(sed -n "$no{p}" textfile);
#the -size, -pointsize, -background and -fill can be changed to whatever you desire
convert $no.jpg -gravity Center null: -size 450 -pointsize 40 -background "#474a11" -fill white caption:"$text" -layers composite $no.jpg; no=$(($no + 1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment