"""Godot 4 GST2 WebP -> PNG conversion used by the native-GXM Vita port.""" import io import struct from PIL import Image def convert_ctex(raw: bytes) -> bytes | None: if not raw.startswith(b"GST2") or len(raw) < 56: return None fmt, width, height, mips, imagefmt = struct.unpack_from(">i),max(1,height>>i)): return None im = im.convert({0:"L",1:"LA",2:"L",3:"LA",4:"RGB",5:"RGBA"}[imagefmt]) buf = io.BytesIO() im.save(buf,format="PNG",optimize=True) blob = buf.getvalue() out += struct.pack("