![]() |
tinyimg 1.0.0
Lightweight image manipulation library for Cloudflare Workers
|
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.
| 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.
The two that do have a lever both spend it on a smoothing pass:
| 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.