Files
basis_universal/python/tests/test_basic_decode.py
Richard Geldreich ea6778b2b5 adding new files
2026-01-19 01:59:35 -05:00

19 lines
424 B
Python

from basisu_py import Transcoder
from PIL import Image
import numpy as np
# Load input file
with open("test.ktx2", "rb") as f:
data = f.read()
# Decode (AUTO backend)
t = Transcoder()
rgba = t.decode_rgba(data) # returns HxWx4 uint8 NumPy array
print("Decoded:", rgba.shape, rgba.dtype)
# Convert to Pillow Image and save
img = Image.fromarray(rgba, mode="RGBA")
img.save("decoded.png")
print("Wrote decoded.png")