API referencestd/image

std/image/meta

Public declarations, types, methods, and source contracts for std/image/meta.

On this page

Library guide · API index and notation

This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.

import "std/image/meta"

Names used in signatures

Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.

Alias Package Source file
binary std/image/shared/binary meta.dodo
brotli std/compress/brotli meta.dodo
deflate std/compress/deflate meta.dodo
pixels std/image/pixels meta.dodo
scratch std/image/shared/scratch meta.dodo
zlib std/compress/zlib meta.dodo

ENCODING_RAW

Constant · Source

How an Item’s bytes are stored.

pub const ENCODING_RAW: u8 = 0

ENCODING_ZLIB

Constant · Source

A zlib stream (PNG iCCP, compressed iTXt).

pub const ENCODING_ZLIB: u8 = 1

ENCODING_BROTLI

Constant · Source

A JPEG XL “brob” box payload: the 4-byte type of the box it replaces (“Exif”, “xml “) followed by a Brotli stream of that box’s payload.

pub const ENCODING_BROTLI: u8 = 2

ENCODING_JXL

Constant · Source

Entropy-coded in a JPEG XL codestream (ICC only).

pub const ENCODING_JXL: u8 = 3

Item

Struct · Source

One payload: data[offset..offset + length] in encoding. Absent when length is zero. EXIF items start at the TIFF header (“II*\0” or “MM\0*”); XMP items are the XML packet.

pub struct Item {
    pub offset: usize
    pub length: usize
    pub encoding: u8
}

Item.none

Function · Source

pub fn none() -> Item

Item.raw

Function · Source

pub fn raw(offset: usize, length: usize) -> Item

Item.present

Function · Source

pub fn present(&self) -> bool

Item.clone

Function · Source

pub fn clone(&self) -> Item

Item.bytes

Function · Source

The item’s stored bytes in data, the file it came from.

pub fn bytes(&self, data: &[u8]) -> &[u8]!pixels.Error from(data)

Metadata

Struct · Source

pub struct Metadata {
    pub exif: Item
    pub xmp: Item
    pub icc: Item
}

Metadata.empty

Function · Source

pub fn empty() -> Metadata

decode

Function · Source

Decode an item into output, returning the byte count: raw items are copied, zlib items inflated, Brotli items decompressed (EXIF then starts at the TIFF header, as for raw items; output must also hold the 4-byte offset field and any padding before it). Brotli items are decoded with 16 KiB of stack workspace (brotli.STACK_WORKSPACE_LEN words; about 30 KiB of stack in all), enough for the streams the reference encoder writes for payloads of up to 128 KiB; one that needs more fails with TooLarge, and decode_with_scratch() decodes every stream. Inflating a zlib item takes about 20 KiB of stack. JPEG XL items fail with Unsupported here.

pub fn decode(data: &[u8], item: &Item, output: &mut[u8]) -> usize!pixels.Error

scratch_size

Function · Source

Scratch bytes decode_with_scratch() needs for item: for a Brotli item, its stream’s workspace (brotli.workspace_size(), read from the stream headers: exact for almost every stream, at most about 1.3 MiB); zero for the other encodings.

pub fn scratch_size(data: &[u8], item: &Item) -> usize!pixels.Error

decode_with_scratch

Function · Source

decode() with caller-supplied scratch of scratch_size(data, item) bytes, which may be heap or static storage; Brotli items then take no large stack and every valid stream decodes. Smaller scratch fails with TooLarge when a Brotli stream’s tables do not fit.

pub fn decode_with_scratch(data: &[u8], item: &Item, output: &mut[u8], work: &mut[u8]) -> usize!pixels.Error

exif_orientation

Function · Source

The orientation tag (0x0112) of a TIFF-structured EXIF payload, 1 to 8, or 1 when absent. Only IFD0 is searched, as the tag lives there.

pub fn exif_orientation(exif: &[u8]) -> u32!pixels.Error

Search every guide, reference page, and API declaration.