{ datagubbe }

datagubbe.se » durden


Durden is a program that identifies, counts and, optionally, marks and/or cuts out and saves unique tiles in a given image file.


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.


Durden was written and tested in Python 3.6. It requires PIL (the Python Imaging Library). It has been linted with these settings.


The latest release is v1.1 (2022-09-20).

Example usage

Say we've got some cool game graphics, like this:

A low resolution and suspiciously copyright-infringing game character standing in a desert landscape.
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:

The same suspiciously copyright-infringing image as above, but with repeating 8x8 pixel tiles blocked out by a very green color.

More usage information is available in the included documentaion.