@daihum/image-formats
v0.1.0
Published
Neutral image format essentials: pure magic-number sniffing and identity facts for PNG/JPEG/GIF/BMP/TIFF/WebP, with upright metadata/decode-to-raster primitives for PNG/JPEG/GIF/TIFF/WebP (BMP is identity-only).
Maintainers
Readme
@daihum/image-formats
Neutral image-format essentials. Support boundary (v1): the identity set is PNG, JPEG, GIF, BMP, TIFF, WebP; the decode set is PNG, JPEG, GIF, TIFF, WebP (exported machine-readably as DECODE_SUPPORTED_FORMATS). BMP is sniff/identity-only — ./decode rejects it with the typed unsupported-format error because the ruled codec engine ships no BMP loader.
@daihum/image-formats(root, side-effect-free, no codec):sniffImage(bytes)— pure, synchronous magic-number identification with explicitunknown-format/truncated-inputfailures; canonical media-type and extension facts; shared types and typed errors.@daihum/image-formats/decode(lazy wasm-vips):readImageMetadata(encoded vs upright dimensions, EXIF orientation 1–8, frame count with the reportedfirst-frame-onlyv1 policy),decodeImageToRgba8,decodeImageToPng,decodeImageToPngWithMaxWidth(a cap — never upscales).
The codec engine (wasm-vips) initializes lazily on the first decode/metadata call and its types never appear in the public API. In browsers it requires cross-origin isolation (COOP/COEP) with SharedArrayBuffer; non-capable environments receive a stable typed unsupported-environment failure. Resource limits (maxSourceBytes, maxPixels) are caller-supplied — this package ships no policy defaults.
Out of scope in v1: SVG/PDF/HEIC/AVIF, multi-frame extraction beyond the first frame, and any product/custody vocabulary.
