Skip to main content

Module measure

Module measure 

Source
Expand description

How big a picture is, and which way up — without decoding it.

Always the first thing done to a file, because every other decision depends on it: whether it may be decoded at all, what it should be decoded to, and what shape it will present once its orientation is applied. Decoding to find out how big something is would be the whole problem this crate exists to avoid.

§What “without decoding” costs

Less than a decode, and not nothing. image’s into_dimensions() reads a header, but a JPEG decoder in 0.25 buffers the file before it will answer — so this is O(file bytes) of reading rather than O(1), and it is O(1) in allocation, which is the part that matters here.

The same header-first check hyprforge-authui’s wallpaper path and hyprforge-clipmenu’s thumbnails already do, for the same reason.

Structs§

Measured
What a header says about a picture.
SourcePixels
The dimensions as stored in the file, before orientation.

Functions§

measure
Reads path’s header: how big, what format, which way up.
measured_path
The path, for callers that keep a Measured around without one.