selective-php / image-type

Image type (format) detection for PHP
MIT License
7 stars 4 forks source link

PDN - Paint.NET file format #56

Closed odan closed 5 years ago

odan commented 5 years ago

The ".pdn" format does not have a binary specification, it consists of Paint.NET's internal object state saved to a file using .NET serialization.

Magic bytes

The first 4 bytes: PDN3

Source:

magicStr = fh.read(4).decode('ascii')

if magicStr != 'PDN3':
    raise PDNReaderError('Invalid magic string for PDN file: %s' % magicStr)

    headerSizeStr = fh.read(3) + b'\x00'
    if len(headerSizeStr) != 4:
        raise PDNReaderError('Unable to read header size. File may be corrupted.')