This is a bit of an odd question, but basically I'm trying to create a set of Pictionary cards for a game. To do this, I have a list of 1500 nouns separated by newlines and I need each of them to be placed on individual PNG files of a specific resolution. Is there an easy way of doing this?
1 Answer
This is a simple task for ImageMagick. The caption tool allows for word wrapping, though if it's just nouns then that might not be a concern. An example command would look like this:
convert -background black -fill white -pointsize 32 \
-size 500x300 -gravity center caption:'WORD' WORD.png
Here's the resulting PNG:
Then all you need is a script to input your words file and feed them in to that command. Here's how to do it with bash:
#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
convert -background black -fill white -pointsize 32 \
-size 500x300 -gravity center caption:$line $line.png
done < "$1"
Usage would be ./scriptname words-file.txt
-
+1 WORST CASE, without bash, the OP can find and replace on newline using notepad++ to emit a 1500 line bat file (not recommended)– YorikSep 29, 2015 at 20:58
-
This works. FYI, for future readers, this can be done in widows like this: FOR /F %%i IN (words.txt) DO convert -background white -fill black -pointsize 60 -size 582x408 -gravity center caption:%%i %%i.png Sep 30, 2015 at 21:59