-
Notifications
You must be signed in to change notification settings - Fork 0
Advanced Decoding
arrow edited this page Jun 6, 2026
·
2 revisions
If you're a developer and want more control, use the WIMFDecoder class. It lets you do some cool stuff like lazy loading or cropping giant images without wasting your RAM
Don't want to load 100MB of pixels just to see the tags? This class reads the JSON header instantly and stops there
from wimf import WIMFDecoder
# only reads the header
decoder = WIMFDecoder("huge_asset.wimf")
print(decoder.width, decoder.height)
print(decoder.metadata)If you have a massive 16K image and you only need a tiny patch, don't decode the whole thing. This only touches the tiles you actually asked for
# get a 300x300 patch from the middle
patch = decoder.decode(roi=(500, 500, 300, 300))Need a fast thumbnail? This skips the high-frequency passes and gives you a 1/2 or 1/4 size image almost instantly
# mip_level 1 = Half, 2 = Quarter
thumb = decoder.decode(mip_level=2)If the file has undo history, you can pull specific states out
# get the 3rd step in the undo history
old_version = decoder.decode_chrono_state(index=2)If you're building a web app and getting WIMF data from a JSON response, just use this
decoder = WIMFDecoder.from_base64("b64_string_here")
img = decoder.decode()