Hello,
my eyes are anything but good, but I still use them. On a smartphone, I'd like to create contact pictures, which wold contain contact names written with white letters on black background, the letters should be as large as possible.
It looks like ImageMagick has everything I need. I was briefly reading docs section about working with texts, and there's a way to put a text into an image with given directions, where ImageMagick decides the font size as large as possible.
I can prepare a file with texts which would serve as contact names, but I'm not sure how to code a script which would read such a text file and produce series of images with those texts on them. I think it'd be nice to prepare a CSV file.
I'm using Windows 8.1, so maybe I could use a .bat script or a PowerShell script. Unfortunately, I'm not an experienced script coder, so I don't seem to be able to prepare such a script file. Can you help me? Thanks in advance.
Creating a batch of images containing a large text
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Creating a batch of images containing a large text
For the IM command, "caption:" is useful here.
Having cataracts, I find white characters on a black background easier to read than black on white. You might have a different preference.
This is an ImageMagick forum, not a scripting forum, but the script can be very simple.
Suppose the text file names.csv contains:
Suppose your screen is 300x200 pixels. Windows BAT script:
This creates file names_0.png, names_1.png and names_2.png:
Having cataracts, I find white characters on a black background easier to read than black on white. You might have a different preference.
This is an ImageMagick forum, not a scripting forum, but the script can be very simple.
Suppose the text file names.csv contains:
Code: Select all
Jo Bee
Aleksandr Isayevich Solzhenitsyn
Bill Williams
Code: Select all
set NUM=0
for /F "tokens=*" %%A in (names.csv) do (
%IM%convert ^
-size 300x200 ^
-gravity Center ^
-background Black -fill White ^
caption:"%%A" ^
names_!NUM!.png
set /A NUM+=1
)
snibgo's IM pages: im.snibgo.com
Re: Creating a batch of images containing a large text
Many thanks for your help. Yes, this is not a forum about scripting, but I asked here, since ImageMagick is a main tool used in my task, but I was really not sure how to do what i really intended to do. Now I'm trying to fully understand commands used in your script, so I can customize this scripts to my needs.
Re: Creating a batch of images containing a large text
And the same script for Linux? Please ....snibgo wrote:For the IM command, "caption:" is useful here.
Having cataracts, I find white characters on a black background easier to read than black on white. You might have a different preference.
This is an ImageMagick forum, not a scripting forum, but the script can be very simple.
Suppose the text file names.csv contains:Suppose your screen is 300x200 pixels. Windows BAT script:Code: Select all
Jo Bee Aleksandr Isayevich Solzhenitsyn Bill Williams
This creates file names_0.png, names_1.png and names_2.png:Code: Select all
set NUM=0 for /F "tokens=*" %%A in (names.csv) do ( %IM%convert ^ -size 300x200 ^ -gravity Center ^ -background Black -fill White ^ caption:"%%A" ^ names_!NUM!.png set /A NUM+=1 )
Re: Creating a batch of images containing a large text
Here is a Linux BASH shell script that does the same steps:-
#!/bin/sh
while read TEXT
do
NAME=`echo $TEXT | tr ' ' '_'` # replace spaces with underscores
echo $TEXT " : " $NAME
convert \
-size 300x200 \
-gravity Center \
-background Black -fill White \
caption:"$TEXT" \
$NAME.png
done < text.lis
text.lis contains the text, one line per image.
#!/bin/sh
while read TEXT
do
NAME=`echo $TEXT | tr ' ' '_'` # replace spaces with underscores
echo $TEXT " : " $NAME
convert \
-size 300x200 \
-gravity Center \
-background Black -fill White \
caption:"$TEXT" \
$NAME.png
done < text.lis
text.lis contains the text, one line per image.