Durden
Durden is a program that identifies, counts and, optionally, marks and/or cuts out and saves unique tiles in a given image file.
Background
A friend was working on game graphics for a 16-bit console game and asked if I could write a program for dealing with tiled background graphics. Several programs already provide this kind of functionality, but it sounded like it'd be fun to write and I don't mind reinventing wheels on my spare time if I get some enjoyment out of it.
The algorithm used is naïve and fairly slow, but it does the job and should work "fast enough" for the low pixel counts usually involved in retro game making.
Requirements
Durden was written and tested in Python 3.6. It requires PIL (the Python Imaging Library). It has been linted with these settings.
Download
The latest release is v1.1 (2022-09-20).
- Download the main distribution archive (durden11.tgz, ~3.5k)
- Read the source code of the main program.
Example usage
Say we've got some cool game graphics, like this:
The image has been scaled up for educational purposes.
Let's assume this file is called tileman.png
.
If we wanted to mark and save all 8x8 pixel tiles in this image,
we could invoke durden like this:
$ durden tileman.png wh=8 save mark m=2
This means find all 8x8 pixel tiles (wh=8
),
save
all unique tiles in an automatically
created directory, mark
all repeating tiles with color
index 2 (m=2
) and save the result in a copy of the
original file.
We'll be presented with the following output:
Number of 8 * 8 tiles in 'tileman.png': 41 Marked image saved as marked_tileman.png Tiles saved in tileman.png_tiles
In the newly created directory tileman.png_tiles
, we'll
find the files tile_0.png
through tile_40.png
,
all of them 8x8 PNG files.
In the file marked_tileman.png
we'll see all repeating tiles
blocked out by our selected color index 2, like so:
More usage information is available in the included documentaion.