I would like to take a text file with about 1,000 lines and create a separate png image for each line in the file using possibly ImageMagick convert. The image should be 1920x1080 with a black background and white text. I am able to get the list (all at once) onto an image using this command:
convert -size 1980x1020 xc:black -font Play-Regular.ttf -pointsize 85 -fill white -gravity center -draw "text 0,0 '$(cat list.txt)'" image.png
I also tried to create a bash file, to iterate each line:
#!/bin/bash
File="list.txt"
Lines=$(cat $File)
for Line in $Lines
do
convert -size 1980x1020 xc:black -font Play-Regular.ttf -pointsize 85 -fill white -gravity center -draw "text 0,0 '$(cat Line)'" $line.png
done
I feel like I am getting closer, but my bash-fu is weak and the command threw several errors.
Line
is already the line you want to print, so don'tcat
it, but simply'$Line'
? This should work, but I think it's better to switch the loop from first storing the file contents in a variable to something likewhile read Line; do … <"$File"
for
for this purpose is problematic.