Skip to main content

Module image

Module image 

Source
Expand description

The intrinsic size a placement is fitted to, read off an image’s bytes without decoding them.

Enums§

ImageImportError
Why an image’s size could not be read.

Functions§

image_intrinsic_size
The intrinsic size of an image, dispatching by kind.
parse_length 🔒
Parse a leading length value, dropping any unit suffix (px, pt, …). Percentages are not absolute sizes, so they yield None.
png_intrinsic_size
The intrinsic size of a PNG, read straight from its IHDR chunk — no decoder needed. A PNG is the 8-byte signature followed by the IHDR chunk, whose data begins at byte 16: width is the big-endian u32 at bytes 16..20 and height at bytes 20..24. None if the signature is wrong, the header is truncated, or a dimension is zero.
size_from_attrs 🔒
Read the root <svg> size: prefer viewBox ("min-x min-y w h"), else the numeric part of width/height. None when neither is present.
svg_intrinsic_size
The intrinsic size of an SVG: its viewBox (preferred) or width/height attributes, defaulting to a 1×1 square when none are declared.