mirror of
https://github.com/Nexoniarz/YAPF.git
synced 2026-11-03 04:54:26 +00:00
- yapf_encode() / yapf_free_buffer(): encode to memory; yapf_save uses it - yapf.c also compiles as C++ - `yapf compare`: size and decode speed of the original format vs YAPF, with a lossless check - bindings with tested examples: C++ (header-only), C# (P/Invoke), Rust (crate, builds the C code), Go (cgo), Java (FFM API, Java 22+), Zig (@cImport), LuaJIT (FFI), TypeScript types for the JS port; Python now encodes in memory - docs/LANGUAGES.md and examples/ with measured results - KDE Dolphin thumbnail plugin (KF6, CMake) - README: honest status for Photoshop / VS Code / Figma (not run in the apps yet) and macOS (cross-compiled only), platform table Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
956 B
956 B
yapf.py — YAPF in Python
import yapf
img = yapf.load("texture.yapf") # or yapf.decode(data)
print(img.width, img.height, img.channels, img.mip_levels)
img.pixels # bytes, rows top to bottom
yapf.save("copy.yapf", img) # or yapf.encode(img) -> bytes
yapf.save("new.yapf", yapf.Image(w, h, 4, rgba_bytes))
It uses the C library through ctypes when it finds one:
- the file named by the
YAPF_LIBRARYenvironment variable, libyapf.so/libyapf.dylib/yapf.dllnext toyapf.py, or inlib/<platform>/beside it (e.g.lib/windows-x64/yapf.dll),- the system library path (
sudo make installinstalls one).
Without the library it falls back to a pure-Python decoder that needs
numpy (decoding only; about 1.4 s for a 4K image). yapf.backend()
tells you which one is in use.
Example: YAPF_LIBRARY=../../build/libyapf.so python3 example.py ../../other/YAPF.YAPF