Skip to main content

Module imageio

Module imageio 

Source
Expand description

Pictures macOS decodes through ImageIO: AVIF, HEIC and HEIF, JPEG XL (macOS 14 and later) and their animated forms (AVIF and HEIF sequences). The image crate reads none of them, so on macOS these decode here at full resolution, turned by their orientation, and animated files hand out their frames and delays. Elsewhere every call fails and callers fall back to QuickLook or a placeholder.

Which formats the running system reads is asked of ImageIO (CGImageSourceCopyTypeIdentifiers), so JPEG XL on macOS 13 reports itself unsupported instead of failing every decode.

Structs§

Animation
An animated AVIF or HEIF sequence, read frame by frame. Each frame is a whole picture (sequence frames don’t need compositing).
WriteFrame
One picture to write with [write].

Functions§

available
Whether the running system’s ImageIO reads ext (JPEG XL needs macOS 14). Always false off macOS.
decode
Decodes the file’s main picture at full resolution, turned upright.
decode_bytes_within
Decodes the picture in data no larger than max_side pixels on its longer side, as straight-alpha sRGB RGBA, not turned. ImageIO scales while it decodes (a JPEG at a fraction of its size directly), so a huge picture never sits in memory at full size. Any format ImageIO reads.
delay_ms
A frame’s delay in milliseconds from its ImageIO properties: the unclamped delay when the file gives one, else the clamped one, in seconds. Browsers’ rule for tiny delays is applied by the player.
handles
Whether ext is one of the formats this module decodes on a system that supports it (see available for whether this one does).
is_animated
Whether a file of count images is an animation: several images, the first carrying a frame delay. An image collection (a HEIF burst, or a HEIC with its depth map) has several images but no timing, and stays a still.
orientation
The orientation an ImageIO Orientation property (the EXIF values 1–8) stands for; anything else leaves the picture as stored.
oriented_size
The size a picture of w x h stored pixels shows at once turned.
type_of
The ImageIO type of a (lower-case) extension this module handles.
write
Writes frames to path as the ImageIO format of ext (macOS can write AVIF, HEIC and HEIF sequences, not AVIF sequences or JPEG XL). Several frames with delays make a HEIF sequence.