Automatic creation of images displaying sequential numbers
April 30, 2008 2:22 AM   Subscribe

How do I automatically create a series of images of sequential numbers? ( 01.jpg shows the number '1', 02.jpg the number '2', etc)

I would prefer to do this using software for Windows. Although if need be, a Mac-only solution would do.

The file-format is of no importance, since conversion is always possible.
Image size for my use is about 500x500 pixels. Simple two-tone images are fine, although some influence on (randomization of) background color, font type/color would be even better.

I'm no guru, but have a basic understanding of Adobe's CS3 Suite and have monkeyed around with various video-editing programs (using the titler functions) as well as image-management software (e.g. ThumbsPlus) and different watermarking software to get this problem solved, but without success.

I'm sure it must be possible, even if the method is a 'dirty' way of using a program. ThumbsPlus for example can make thumbnail-sheets of images, which it then numbers, if you ask it to. However, I haven't been able to cheat this option into doing what I need.

Any ideas? Making these by hand is not going to be fun...
posted by Grensgeval to Media & Arts (5 answers total) 8 users marked this as a favorite
 
This is the sort of thing you could do fairly easily in VB 2008. My guess is it would take less than 10 lines of code. If you don't find a better solution and need someone to write the code for you, mail me and I'll see what I can do.
posted by le morte de bea arthur at 2:51 AM on April 30, 2008


Best answer: Install Cygwin, making sure to include ImageMagick in your install. Typing these commands from the bash shell will generate all of the images:

FILLS=(firebrick2 magenta2 NavyBlue DarkGreen DarkGoldenrod2)
FONTS=(Helvetica-BoldOblique Palatino-Bold AvantGarde-Book Times-Italic)

X=1
while [ $X -lt 100 ]; do
    FILL=${FILLS[( $RANDOM % ${#FILLS[@]} )]}
    FONT=${FONTS[( $RANDOM % ${#FONTS[@]} )]}
    convert -size 500x500 -fill $FILL -font $FONT -gravity center label:$X ${X}.png
    let X=X+1
done


See these recipes for examples. Here are color names.

Sorry, I didn't bother to make the file for 1 be 01.png, rename it yourself.
posted by grouse at 2:58 AM on April 30, 2008 [3 favorites]


Here's a solution in VB.NET 2005. You have to set maxNumber to whatever you need it to be, and you would need to mess with the font size and text location for it to look pretty, but the rest of it should be what you need.


Dim maxNumber As Integer = 100
Dim textSize As New Size(500, 500)
Dim textLocation As New Point(0, 0)

Dim numberofdigits As Integer = CInt(Math.Floor(Math.Log10(maxNumber))) + 1

For i As Integer = 1 To maxNumber

Dim numberText As String = i.ToString
Dim font As New Font("Lucida Console", 240, FontStyle.Regular)

Dim blankImage As New Bitmap(textSize.Width, textSize.Height)
Dim graph As Graphics = Graphics.FromImage(blankImage)
graph.DrawString(numberText, font, Brushes.Black, textLocation.X, textLocation.Y)

Dim fileName As String = i.ToString.PadLeft(numberofdigits, "0"c) & ".bmp"
blankImage.Save(fileName)

Next

posted by burnmp3s at 4:31 AM on April 30, 2008


Adobe Photoshop:
File | Automate | Batch

You can run it from a folder or using files that are already opened.
posted by chocolatepeanutbuttercup at 5:11 AM on April 30, 2008


Response by poster: @grouse, that was beautiful.
I'm not a programmer at all, but even I can understand that code.

Installed Cygwin, copied your code and it worked the very first time.

Using your links I'll pretty the results up a little.

Thank you so much!

@burbmp3s, thank you for you reply!
It was easier for me to understand the Cygwin code, so for now that what I went with.
I'll give your code a test run later in the week, it will be put to use, so also major kudos to you, cheers!
posted by Grensgeval at 5:41 AM on April 30, 2008


« Older How to expand wireless network?   |   Is NearlyFreeSpeech any good? Newer »
This thread is closed to new comments.