TagStudio icon indicating copy to clipboard operation
TagStudio copied to clipboard

feat: render `.pdn` thumbnails.

Open Sola-ris opened this issue 2 months ago • 8 comments

Summary

Add support for rendering .pdn thumbnails. Fixes https://github.com/TagStudioDev/TagStudio/issues/1147

.pdn files have an XML header that contains the thumbnail as a base64 encoded .png file. The file layout is the following:

  • 4 byte magic number (PDN3)
  • 24-bit little-endian int specifying the header's length
  • The XML header
  • The actual image data which we don't care about

The header itself looks like this:

<pdnImage width="800" height="600" layers="1" savedWithVersion="5.109.9343.2610">
    <custom>
        <thumb png="base64 string" />
    </custom>
</pdnImage>

Sources for the file format

  • http://justsolve.archiveteam.org/wiki/Paint.NET_image
    • Apparently there's a compresed version of the file format, but I couldn't get Paint.NET to produce that one
  • https://github.com/rivy/OpenPDN
    • https://github.com/rivy/OpenPDN/blob/master/src/Data/Document.cs#L64-L120
    • https://github.com/rivy/OpenPDN/blob/master/src/DocumentWorkspace.cs#L2594-L2610
  • https://github.com/addisonElliott/pypdn/blob/master/pypdn/reader.py#L142-L143
  • The test file opened in a text editor

Before

before

After

after

File used for testing

pdn.zip (The actual file is archived since GitHub doesn't allow uploading .pdn files)

Tasks Completed

  • Platforms Tested:
    • [ ] Windows x86
    • [ ] Windows ARM
    • [ ] macOS x86
    • [ ] macOS ARM
    • [x] Linux x86
    • [ ] Linux ARM
  • Tested For:
    • [x] Basic functionality
    • [ ] PyInstaller executable

Sola-ris avatar Sep 24 '25 20:09 Sola-ris