module

DataDungeon::ImageProbe

Constants

DECODERS = {} of String => Proc(Bytes, ::Tuple(Int32, Int32, Bytes))

Formats read and written through a library an application links by requiring it (data_dungeon/tiff), by content type: a decoder gives {width, height, RGBA pixels}, an encoder takes them.

ENCODERS = {} of String => Proc(Int32, Int32, Bytes, Bytes)
VISIBLE_ALPHA = 16

A pixel counts as visible from this alpha up (about 6%), so the faint noise a cut-out's matting leaves doesn't widen its content box.

Class methods

check_size(width : Int, height : Int, format : String) : Nil

Raises unless a picture of this size may be decoded.

Source
content_box(width : Int32, height : Int32, rgba : Bytes) : Tuple(Int32, Int32, Int32, Int32) | Nil

Just the content box of these pixels, for an animation's keyframes.

Source
decode(data : Bytes, content_type : String) : Tuple(Int32, Int32, Bytes)

The RGBA pixels of a still PNG or WebP, or of an animation's first frame, or of a format an application added (a TIFF): {width, height, pixels}.

Source
decode_png(data : Bytes) : Tuple(Int32, Int32, Bytes)

libpng's simplified reader takes 16-bit samples with no gAMA or sRGB chunk for linear light, brightening them on the way to 8 bits, and gets interlaced ones wrong besides. Its 16-bit "linear" output gives such samples as stored (premultiplied), so they're read that way and rounded here, at the nearest 8-bit level (within one where partly clear).

Source
decode_webp(data : Bytes) : Tuple(Int32, Int32, Bytes)
Source
decode_webp_frames(data : Bytes, moments : Array(Int32)) : Array(Tuple(Int32, Tuple(Int32, Int32, Bytes)))

An animated WebP's frames as shown at each of these moments (ms from its start): {moment, {width, height, pixels}}. Frames are decoded in order, up to the last moment asked for.

Source
from_pixels(width : Int32, height : Int32, rgba : Bytes) : Measurement

Transparency, content box and dominant colour, from RGBA pixels in one pass. The dominant colour is the mean of the most common colour bin (eight levels a channel), counting each pixel by its opacity.

Source
max_pixels

The most pixels decoded from one picture: 64 Mi (8192 × 8192, 256 MiB as RGBA), forty times the largest any store held in October 2026. A header can claim any size, so a small file could otherwise make DataDungeon allocate gigabytes; this is checked before allocating. An application with bigger pictures raises it. A picture over it is stored unmeasured, and converting it raises.

Source
max_pixels=(max_pixels : Int64)

The most pixels decoded from one picture: 64 Mi (8192 × 8192, 256 MiB as RGBA), forty times the largest any store held in October 2026. A header can claim any size, so a small file could otherwise make DataDungeon allocate gigabytes; this is checked before allocating. An application with bigger pictures raises it. A picture over it is stored unmeasured, and converting it raises.

Source
measure(data : Bytes, content_type : String) : Measurement | Nil

The measurement of these bytes, or nil for a format DataDungeon can't read (or bytes that aren't the image they claim to be).

Source

Nested types