def read_p2d(path): with open(path, 'rb') as f: magic = f.read(4) if magic != b'P2DF': raise ValueError('Bad magic') version = struct.unpack('<B', f.read(1))[0] pf = struct.unpack('<B', f.read(1))[0] w = struct.unpack('<H', f.read(2))[0] h = struct.unpack('<H', f.read(2))[0] f.read(2) # reserved data = f.read(w*h*4) if pf != 1: raise NotImplementedError('Only RGBA8888 supported') im = Image.frombytes('RGBA', (w,h), data) return im
npm install -g png2p2d
In your game code (e.g., Godot GDScript): png to p2d converter