![]() |
tinyimg 1.1.1
Lightweight image manipulation library for WebAssembly
|
Options a decoder honors when only part of an image is wanted. More...
#include <image.h>
Public Attributes | |
| uint32_t | x |
| uint32_t | y |
| uint32_t | width |
| uint32_t | height |
| uint8_t | scale_den |
| uint8_t | channels |
| uint8_t | effort |
| How much computation the decoder may spend; a TinyEffort. | |
Options a decoder honors when only part of an image is wanted.
The rectangle is in source pixels and is clamped to the image. A width or height of zero means the full extent in that axis. scale_den then subsamples that rectangle, so the decoded image is ceil(width / scale_den) across.
Every codec box averages when downscaling, so a scaled decode is a real reduction rather than a nearest neighbor pick. JPEG additionally does the work in the DCT domain, which is why its scaled decode is cheaper as well as smaller.
That average is exact at TINYIMG_EFFORT_FANCY, which is what lets a scaled decode of one picture agree across formats. WebP's FAST tier averages its planes instead of the pixels it converts from them, which is a reduction of the same picture and not the same bytes; effort documents the floor.
| uint8_t TinyDecodeOpts::channels |
Channels to produce, 1 through 4. Zero keeps the file's own count.
| uint8_t TinyDecodeOpts::effort |
How much computation the decoder may spend; a TinyEffort.
Zero is TINYIMG_EFFORT_FANCY, the default, which decodes to the bitstream's own definition.
Only a lossy decoder has anything to drop, and the reason is structural: a lossless format defines its pixels exactly, so every step is needed to produce them and there is no approximation available. PNG, GIF, TIFF and WebP lossless therefore decode identically at either effort.
Both lossy decoders spend it on a smoothing pass:
VP8 has a second one that a scaled request reaches, and it is the only place here that changes how a reduction is computed rather than which passes run. At scale_den above one it averages the luma and chroma planes over each output pixel's box and converts once, instead of converting the frame and averaging that: 2.05x to 3.35x together with the filter skip, for 38.9 dB and a worst sample 46 levels off the exact box average. Alpha carries no chroma and stays exact.
| uint32_t TinyDecodeOpts::height |
Region height; zero means to the bottom edge.
| uint8_t TinyDecodeOpts::scale_den |
Subsampling denominator: 1, 2, 4 or 8. Anything else is read as 1.
| uint32_t TinyDecodeOpts::width |
Region width; zero means to the right edge.
| uint32_t TinyDecodeOpts::x |
Left edge of the region in source pixels.
| uint32_t TinyDecodeOpts::y |
Top edge of the region in source pixels.