Reputation: 72111
I'd like to create a bunch of PNGs, one for each letter of the alphabet.
How can I do this from the command line on mac/linux?
Upvotes: 0
Views: 855
Reputation: 72111
The following script will dump the letters of the alphabet to a series of PNGs. It requires imageMagick and GhostScript be installed on your system for the convert
utility.
e.g.
# creates the letters A.png -> Z.png in the current folder
dump_alphabet_as_pngs.sh
# creates the files test_A.png -> test_Z.png in the current folder,
# with a red font named "AvantGarde-Book"
dump_alphabet_as_pngs.sh test_ red AvantGarde-Book
# Create image for template
TEMPLATE=/tmp/_template.png
convert -size 80x80 xc:white $TEMPLATE
# Setup defaults
PREFIX=${1:-''}
COLOR=${2:-'red'}
FONT=${3:-'helvetica'}
SIZE=${4:-75}
# Note that the following will show you fonts you can use: 'convert -list font |grep Font:'
function createImage()
{
convert -font $FONT -fill $COLOR -pointsize $SIZE -draw "text 15,70 '$1'" $TEMPLATE $PREFIX$1.png
}
# Generate images
for x in {A..Z}
do
createImage $x
done
rm -f $TEMPLATE
Upvotes: 1
Reputation: 69338
You can create an image of the letter using Inkscape and setting whatever style and color you want.
Let's say you create one with the letter A and save it as a.svg
Then locate where the A
is, for example
style="font-size:72px;fill:#8b0000">A</tspan></text>
and replace it in a loop
for l in {A..Z}; do sed 's@\(#8b0000">\)\(A\)\(</tspan></text>\)@\1'$l'\3@' a.svg | convert - $l.png; done
and you'll have all your letters
Upvotes: 2