Game Development Community

ImageMagick

by Michael Cordner · in Torque Game Builder · 07/18/2005 (8:30 am) · 13 replies

I've noticed that loads of people have created custom tools for doing things such as tiling, combining, and splitting images to convert them into torque 2d compatible images. Having a good sniff around for tools to do exactly that kind of thing, I came across imagemagick... seems to do everything you could ever possibly want with an image, and is open source and free. It installs as a series of command line tools, so it seems to be very handy for automating builds and art production pipelines.

http://sourceforge.net/projects/imagemagick/

Here are the commands I use on a regular basis:

Combine a series of images numbered from 0 to n into a single horizontal strip image (animation CELL type)
convert +append myimage_frame_*.png myimage.png

Split a big image into tiles numbered 0 through n
convert -crop [tileSizeX]x[tileSizeY] bigImage.png bigImage_tile%d.png


I believe it will work on just about any image type, and can convert between formats readily.

#1
07/18/2005 (8:34 am)
IM has been mentioned a few times. Unfortunately the convert a load of images into one long strip isn't terribly useful. T2D has a maximum image size that it can deal with, so sticking 20 128x128 images in a long line creates a 2560x128 image and T2D falls over.

If it could create a grid like structure for the images, it would be much more useful.
#2
07/18/2005 (8:39 am)
Didn't know about the limitation, but I'm sure it wouldnt be much of an issue to write a script around the image magic tools to
create a grid instead. It sounds far less painful than some of the custom executables I've been seeing. Perhaps I'll have a go at it.

What is the maximum image size?
#3
07/18/2005 (8:56 am)
I think its safest to stay under 2048 or in x or y... Ideally something that makes image grids
1024 x 1024
2048 x 1024
2048 x 2048
these or less would be ideal... A parameter for choosing the max size of a grid would be invaluable, could run some resource tests with T2D and see if smaller or larger imagemaps run more efficient :)
#4
07/18/2005 (9:06 am)
Looking around at the imagemagick documentation, came across the montage command... (not at dev machine so I'm unable to try it). It's meant for generating thumbnails but it looks like it might do the job. Anyone ever tried it?

join several images together without any extraneous graphics (e.g. no label, no shadowing, no surrounding tile frame), use:
montage +frame +shadow +label -tile 5x1 -geometry 50x50+0+0 *.png joined.png

Where does this limitation in one dimension come from? An image is just a block of data whether you decide to interpret it as it 10x10 or 1x100.
#5
07/18/2005 (9:59 am)
Huge chunks of the T2D code are based around TGE, so I suspect the image size restrictions come from there. No doubt the source can be changed to allow larger images to be used, but it won't become an out of the box solution until TGE is updated and the source is rolled into T2D.
#6
07/18/2005 (10:16 am)
Philip hit it... a texture size limit for TGE... typically in 3D games you wouldn't want to make texture sizes larger than 2048 x 2048. :)

I think you run into compatability issues with older video cards when you pass 1024 x 1024 in an image/texture size.
#7
07/24/2005 (5:04 am)
Just to be clear here. T2D doesn't fall over, your graphics card does or at least that should be the case. I can quite happily use 4K sized textures or even 8K on some graphics cards at work. A utility such as GLInfo can tell you your maximum texture support as each graphics card has a maximum hardware texture support, that's all. Also, the larger the texture, the slower your graphics card can address it. Scattered addressing of a larger area of internal graphics memory is much slower.

We are currently working on a new imagemap system that will abstract-away the need to worry so much about your target hardware although we'll be providing more control for power-users.

The need to understand your target audiences hardware is what we're talking about here, not just getting it to run on your system. As Matthew quite rightly pointed-out, different cards have different texture-size limitations. The "chunked" support in T2D and indeed in TGE try to address this issue, with limitations, by splitting-up large bitmaps into "chunks" of 256x256 that are pretty much guaranteed to work on almost any 3D graphics card you care to mention.

- Melv.
#8
08/30/2005 (11:17 am)
For the record, that command works absolutely beautifully for tiling images, or at least for my needs.

montage +frame +shadow +label -background none -tile 6x6 -geometry 128x128+0+0 *.png walkcycle.png

makes a nice 6x6 grid of images assuming there are 36 sequenced png files in the current directory
#9
09/01/2005 (11:03 am)
Just wanna say that I found all the above information really useful, thanks everyone. Especially the converting a string of single images into a strip.
#10
10/13/2005 (10:35 am)
I am using this command, but a problem I cannot figure out is that any white in my images is converted to transparent in the output image. The source images already have an alpha channel so white should not be converted to transparent.

montage -background transparent -tile 6x6 -geometry 32x32+0+0 *.png balloons.png

[EDIT: never mind! sorry it turns out the source images were really transparent I was just looking at them on a white background. doh]
#11
10/14/2005 (2:44 am)
Heheeh... I use paintshop pro for viewing images, it's cheap and reliable and best of all transparent areas of images really show up as transparent.
#12
10/14/2005 (3:20 am)
I use PSP as well, but I don't think it has the ability to create image strips. At least if it does, I haven't found it and have wasted a lot of time doing them by hand!
#13
10/14/2005 (10:44 am)
@Michael- see my edit. imagemagick works fine- it was user error.