Generate images from large list of words

1

1

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?

quadrplax

Posted 2015-09-28T22:43:02.283

Reputation: 13

Do you have any design software available (or preferred) such as Photoshop, Illustrator, or InDesign? – JohnB – 2015-09-28T22:48:18.637

@JohnB Just paint.net, nothing that costs money – quadrplax – 2015-09-28T23:28:39.267

GIMP supports scripting... – Yorik – 2015-09-29T20:56:18.420

Answers

4

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:

enter image description here

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

JohnB

Posted 2015-09-28T22:43:02.283

Reputation: 374

+1 WORST CASE, without bash, the OP can find and replace on newline using notepad++ to emit a 1500 line bat file (not recommended) – Yorik – 2015-09-29T20:58:19.023

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 – quadrplax – 2015-09-30T21:59:22.287