Registry / storage / etcpak

etcpak

JSON →
library0.9.15pypypi✓ verified 85d ago

Python wrapper for the etcpak library, providing fast block-based texture compression (BC1-7, ETC1/2, ASTC) for image data, particularly useful in game development and rendering pipelines. Current version 0.9.15, updated occasionally.

pip install etcpak
INSTALL
IMPORT
SIG · ETCPAK
E
etcpak
storagepythonv0.9.15
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compress_bc1
from etcpak import compress_bc1
import etcpak
Direct import of submodule not exposed; use top-level functions after import etcpak
compress_bc3
from etcpak import compress_bc3
No common wrong import
compress_etc1
from etcpak import compress_etc1
No common wrong import
compress_etc2
from etcpak import compress_etc2
No common wrong import

Compress an RGB image to BC1 (DXT1) format. Input data must be 4x4 block-aligned.

from PIL import Image import numpy as np from etcpak import compress_bc1 img = Image.open('example.png').convert('RGB') arr = np.array(img, dtype=np.uint8) # Ensure 4x4 aligned (BCn blocks require dimensions multiple of 4) height, width = arr.shape[:2] if height % 4 != 0 or width % 4 != 0: raise ValueError('Image dimensions must be multiples of 4 for BCn compression') compressed = compress_bc1(arr.tobytes(), width, height) print(f'Compressed size: {len(compressed)} bytes')
Debug
Known issues
gotchaInput dimensions must be multiples of 4 for BCn compression (BC1-BC7). Non-aligned sizes cause errors or undefined behavior.
fix
Pad image to multiples of 4, or crop. Use e.g., PIL.ImageOps.pad() or np.pad().
affects: all
gotchaetcpak expects raw bytes in RGB order (pixel layout). Other orderings (BGRA, RGBA) produce incorrect results. Ensure input is contiguous and correctly ordered.
fix
Convert image to 'RGB' mode (PIL) and use array.tobytes(). For RGBA, use compress_bc3 etc. accordingly.
affects: all
gotchacompress_bc5 expects two-channel input (RG). Providing 4-channel data will cause errors or silent corruption.
fix
Extract the two channels and pack as interleaved bytes (R,G,R,G...).
affects: all
deprecatedThe 'etcpak' module may be confused with 'pyetcpak' or 'etcpak-compress'. Always use 'etcpak' from PyPI by K0lb3.
fix
Install `pip install etcpak==0.9.15` and use `from etcpak import ...`.
affects: all
Errors
Common errors & fixes
ValueError: The height and width must be multiples of 4.
Input image dimensions not divisible by 4 for BCn compression.
fix
Resize or pad image to multiples of 4 before feeding to etcpak.
TypeError: a bytes-like object is required, not 'array'
Passed a numpy array directly instead of its bytes() representation.
fix
Use `arr.tobytes()` or `arr.tostring()` to convert to bytes.
ModuleNotFoundError: No module named 'etcpak'
Package not installed or installed under a different name (e.g., 'pyetcpak').
fix
Install using `pip install etcpak`. Ensure no conflicting packages.
Upgrade
Version history
0.9.15latest on PyPI · released Aug 11, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
24
Resources
etcpak — pip install etcpak · libregistry