Tristan Le Guern

The tpNG chunk

While working on the pnginfo utility and the accompanying lgpng library I started hunting for uncommon or unofficial PNG chunks (dubbed “PNGmon shinies” by a friend, in a reference a Pokémon rarity system). One of them was the tpNG chunk.

I sadly do not remember how I stumbled upon it but I believe it started with a fan made, unofficial pixel arts maps for a game named Underrail by Saltamontes on the company’s forum (link to the post).

Here is an excerpt:

I am creating a map while I play through the game for navigation purposes, […]. To accomplish this I use pixel art and I am manually drawing this map […]. NOTE 2: Download the package to download all the files! The package also includes my original GraphicsGale (GAL) file and the 4x size images.

Okay, let’s download one of these:

Pixel-art map of an underground cave

And now inspect the content:

$ pnginfo -lf Lower\ Underrail.png
IHDR
tIME
tEXt
tpNG <--- What's this?
gAMA
bKGD
IDAT
IEND

According to the PNG § 5.4 Chunk naming conventions at least two things can be inferred from this chunk’s name: the small case t indicates an optional chunk (its presence or absence does not impact how the actual pixels will be extracted and interpreted) and the small case p indicates a privately defined chunk. This generally mean that no official description of the chunk exists, a situation that easily makes me look and poke around.

First, let’s check the content of the tEXt chunk, as it often enough contains the software used to generate the PNG file:

$ pnginfo -c tEXt -f Lower\ Underrail.png
tEXt: Software: GLDPNG ver 3.4

What is this, again?

GraphicsGale

Saltamontes mentioned using the GraphicsGale software to create his files so I searched about this first. Hosted at https://graphicsgale.com/ it is a pixel art editor very obviously written by a Japanese developer — ignoring the language switch in the top right corner other clues include the cute 200x40 pixels gif button and the very typical look and feel of Shift_JIS encoding of some pages.

I started my Windows laptop and downloaded the portable version of GraphicsGale, then selected one of the two demo projects to export as a PNG image:

Screenshot of GraphicsGale Save As pop-up

Here is sample2.png:

Image of a pixel-art fairy flying above the clouds at night

Just check it to be sure:

$ pnginfo -lf sample2.png | grep tpNG
tpNG <--- the unknown chunk is here too
$ pnginfo -c tEXt -f sample2.png
tEXt: Software: GLDPNG ver 3.4

My freshly generated PNG image has the exact same tEXt chunk containing the string Software: GLDPNG ver 3.4 and the same curious extra chunk, which means GraphicsGale is definitely responsible for inserting it in the file. But searching the project’s home page didn’t yield any results for keywords such as “tpng” or “gldpng”.

Searching GLDPNG ver 3.4 on DuckDuckGo and Google yielded a few other files with the same chunk. Interestingly most of these files were pixel arts or video game related. The few that were not contained Japanese text.

Poking at the executable with the strings utility got some interesting keywords:

$ strings gale.exe
...
SOFTWARE\Borland\Delphi\RTL
...
TFontComboBoxEx component v1.00 for Delphi 2.0. (C) 1997 Susumu KAWAMURA. For details, see READMEJ.TXT file.
...
TGLDPNGWriteStream
...
GLDPNG ver 3.4
...

According to these bits of information GraphicsGale is most likely written in Delphi, an object oriented language evolved from Pascal, and includes an external library named GLDPNG, most likely also written in Delphi.

GLDPNG

The GLDPNG library author is only known (to me at least) under the pseudonym “Tarquin”. The author’s personal website disappeared from the Internet and the Wayback Machine did not archive it in depth, sadly only the landing page is preserved.

Although not much is usable the author mentions publishing its software to Delphian World, a defunct website for Delphi enthusiasts. Fast forward some more digging and I exhumed three versions of the library:

Sadly the Wayback Machine did not archive Delphian World at earlier dates, although I was able to locate the code in a few Github projects. For the source speleologists out there I pushed everything I had on a repository: https://github.com/tleguern/gldpng.

According to the changelog and the copyright text in manual/GLDPNG3.html at least two years of development are not covered and the first known release is version 3.1.0. If anyone has access to the missing archives I would be glad to receive them by email ;)

Side note: known software using GLDPNG

Project name Website GLDPNG version
GraphicsGale https://graphicsgale.com 3.4.3F
Hyper-Paint http://hyper-paint.lolipop.jp/rireki.htm Unknown
Metafile Converter http://www.shibaguchi.com/molip/metaconverte.html 3.3.1
TepaEditor https://greenspace.info/tepa 3.3.3

Chunk description

Finally armed with the source code it becomes easy to understand the content of the tpNG chunk.

The four-byte chunk type field contains the hexadecimal values

74 70 4e 47

If present, the tpNG chunk indicates that the image was created using the GLDPNG library with optional extensions.

Name Size
Version 4 bytes
Password 1 byte
Alpha256 1 byte
Unused 2 bytes

Version is a short text string containing the version of GLDPNG library used to create the file. The only known value is GLD3.

Password is a single byte integer. If set to 1 the PNG stream has been password encrypted by the encoder.

Alpha256 is a single byte integer specifying that the file uses true colours with a bit depth of 8 (which is the standard colour type 6). Even at the time GLDPNG was written such a possibility existed so I don’t know why it was created as an extension.

Finally two bytes are used for padding to a total eight bytes. Their content should be ignored.

The question “why is this chunk named tpNG?” is not answered in any of the files, as far as my understanding of botched translations of Japanese can go. My bet is on “Tarquin PNG”.

The second question “why is the library named GLDPNG?” is not answered either. My bet in this case is made with less certainty but I would assume it means “Gold PNG”.

Password encrypted PNG files?

While GLDPNG mentions password encryption for PNG streams, it doesn’t offer a direct implementation (although one is present in a code sample). Instead, it provides callback functions for library users, which introduces a significant compatibility issue: since there’s no way to specify the exact encryption algorithm used, it becomes difficult to achieve compatibility between tpNG-aware encoders and decoders. To solve this issue – if it needs to be solved at all – a specific keyword could be pushed to a tEXt chunk containing a documented algorithm name.

I was not able to find a file with an encrypted stream.

Rarity

How rare is the tpNG chunk in the wild? I would say “uncommon” enough that hundreds of them are available on various video games wiki, with a higher frequency on Japanese language website.

A real shiny would have either of the Alpha256 or Password options activated.

This is a list of images taken from various places generated with the help of the GLDPNG library. I inserted the details of both tEXt and tpNG chunks for each image.

Changelog