Batch processing stray tiles with Image Magick

Chris H.'s Ultima / ACS-style game development system!

Moderators: Ice Cream Jonsey, joltcountry

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Batch processing stray tiles with Image Magick

Post by Garth's Equipment Shop »

So is there any existing utility that can take a bunch of 16x16 PNG files and merge them together in one large image? Or even in one page, from which you could take screenshots? (From there it should be trivial to paste sections of that into 320x200 BMP files)
Yes - Image Magick!

First you'll need to dl ImageMagick if you haven't already. Heres the link to the official dl page with all the different distros for various OS's.

http://www.imagemagick.org/script/binary-releases.php

The command were interested in here is "montage."

http://www.imagemagick.org/script/montage.php


Here is the batch file...

md montages
cd montages
montage ../*.png -geometry 16x16+2+2 -tile 16x9 -format bmp -depth 8 -size 320x200 tileset.bmp
convert tileset-?.bmp -bordercolor white -border 160x100 -gravity center -crop 320x200+0+0 tileset-?.bmp

save it as whatever name you want except "montage" or "convert" which are ImageMagic commands


The batch file I made is designed to run from any directory that contains the tiles you wish to merge and convert into one 320x200 BMP. Preferably 16x16 tiles so they dont get resized which would result in unpredictable quality - and yes if they are not 16x16 they will be automatically resized but the original png files will not be changed at all.

The output files are saved to a new directory created by the batch file. Also, if you wanted to merge a bunch of files of some other format all you need to do is edit the batch file and replace '../*.png' with '../*.gif' or '../*.bmp' '../*.ppm' or whatever format. ImageMagic can read a bewildering number of formats including uncommon or older ones. If you wanted you could edit the batch file to process a comination of formats.


The resulting bmp is almost ready to import tiles from in the ACK tile editor.

The final step is to convert the image's indexed color palette to the one ACK uses. Open any ACK game that uses the default palette and run the tile editor. Press enter to edit a tile. Press S key to show ACK's 256 color palette index. Hit ctrl-F5 to get a screen cap of it.

Find the captured image and load that up in Photoshop. Go to color table and save that as a PS ACT file. Load your new tileset and again go to the color table and load the ACK.ACT color table you saved. (I'm sure you can accomplish this in other graphics programs. I merely used Photoshop to illustrate this step as its the one i know best)

Be sure you choose NONE for the option to use any type of dithering when applying the custom colortable. Otherwise the icons come out fuzzy or with stray pixels in random places.

And your done. Now you can save the image to the import folder of ACK and run the tile editor and press Alt-B to bring up a list of the tilesets you have in the import folder, choose your new tileset and start importing tiles from it.