tinyimg 1.0.0
Lightweight image manipulation library for Cloudflare Workers
Loading...
Searching...
No Matches
TinyDecodeOpts Struct Reference

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.

Detailed Description

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.

Member Data Documentation

◆ channels

uint8_t TinyDecodeOpts::channels

Channels to produce, 1 through 4. Zero keeps the file's own count.

◆ effort

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:

  • VP8 skips its deblocking filter, which is 1.53x for 46.8 dB.
  • JPEG replicates chroma instead of interpolating it, which is 1.11x to 1.25x for 43.6 to 59.5 dB. It reaches subsampled files only, so a 4:4:4 file is unaffected.

◆ height

uint32_t TinyDecodeOpts::height

Region height; zero means to the bottom edge.

◆ scale_den

uint8_t TinyDecodeOpts::scale_den

Subsampling denominator: 1, 2, 4 or 8. Anything else is read as 1.

◆ width

uint32_t TinyDecodeOpts::width

Region width; zero means to the right edge.

◆ x

uint32_t TinyDecodeOpts::x

Left edge of the region in source pixels.

◆ y

uint32_t TinyDecodeOpts::y

Top edge of the region in source pixels.


The documentation for this struct was generated from the following file: