Operations appended so far.
The count before any rewrite, so it says what was asked for rather than what will run; see decide for the latter.
The container the source arrived in, and the default bytes encodes back to.
Frames the source holds, which is 1 for a still image.
Only the first is decoded, so a value above 1 means an encode of this plan is a still taken from an animation. The count comes from the header read open already performed.
Lets using release the handle; see dispose.
The result as a Blob, ready to hand to a FormData or a Response.
Optionalformat: ImageFormat
Container to encode as.
Encoder settings.
Blurs.
A true gaussian, as three box passes. The planner moves a blur that feeds a reduction of two or more to after the reduction, at a scaled sigma, which is exact for a gaussian.
Radius in pixels. Zero is a no-op and is eliminated.
Scales every channel. 1 is unchanged.
Runs the plan and encodes the result.
The plan is not consumed, so this can be called twice for two formats of one transformation and the planner's work is done once.
Optionalformat: ImageFormat
Container to encode as. Defaults to the source's own.
Encoder settings.
The encoded bytes.
Scales every channel about mid gray. 1 is unchanged.
Takes a rectangle, in the coordinates the previous operation produced.
The result as a data: URL.
For an inline <img src> or a placeholder. Base64 costs a third more bytes than the image,
so this is for small results.
Optionalformat: ImageFormat
Container to encode as.
Encoder settings.
Reports what the planner decided, without producing the image.
The saving is visible here: region and scale are what the decoder will be asked for, and
eliminated and collapsed are what the rewrites removed. Useful in a log line, and it is
how the library's own tests assert a plan rather than inferring it from the pixels.
Releases the plan and the source bytes.
Safe to call twice. Every later call on the image throws instead of reading freed memory.
Chooses how much work the decode may spend.
fancy, the default, decodes to the bitstream's definition. fast lets a lossy decoder drop
its smoothing pass, which is 1.53x on a lossy WebP for 46.8 dB and 1.11x to 1.25x on a
subsampled JPEG for 43.6 to 59.5 dB.
A lossless format has nothing to drop, because it defines its pixels exactly, so PNG, GIF, TIFF and lossless WebP decode identically either way. So does a 4:4:4 JPEG, which has no chroma to upsample.
This is the decode side only. The encoder's effort is an argument to bytes.
How hard to work.
Resamples and then crops or pads to an exact extent.
Target width.
Target height.
fit defaults to cover; gravity to center; filter to auto.
Turns operation fusion off, so every operation runs as its own pass.
Leave this on. It exists to measure what the planner is worth: with it off the same chain
costs one traversal and one buffer per operation, which is what the library would be without
the planner. bench/ is the only caller that should ever pass false.
False to run one operation per pass.
Raises every channel to a power. 1 is unchanged.
Replaces every channel with the pixel's luminance, and drops the color channels.
Rotates the hue, in degrees.
Subtracts every channel from full scale, leaving alpha alone.
Runs the plan and hands back the raw samples.
Below the encoders, for a caller who wants the pixels themselves: a histogram, a hand-written
kernel, or a measurement that should not include an encoder's time. Rows are tightly packed
and there is no stride separate from width * channels.
The extent, the channel count and width * height * channels bytes.
Resamples to an extent.
Target width. Zero, or omitted with a height given, keeps the aspect ratio.
Target height. Same rule.
Weights to sample through. auto is an area average down and a cubic up,
which is the right answer for almost every request.
The result as a Response, which is what a Worker returns.
Optionalformat: ImageFormat
Container to encode as.
Encoder settings, plus headers merged into the response's own.
Turns by a multiple of 90 degrees clockwise.
Folded into the output addressing rather than run as a pass, so any number of turns and flips cost one pass between them. rotateFree is the arbitrary-angle form.
Turns by an arbitrary angle, filling the corners with the background.
Runs after the plan rather than inside it. An arbitrary rotation changes the extent by a non-integer factor, so it cannot fold into the sample map the way a quarter turn does; it is applied to the materialized image. A quarter turn passed here is still handed to rotate, which is free.
Moves every channel toward or away from its luminance. 1 is unchanged.
Sharpens with an unsharp mask.
How much of the high-frequency difference to add back. 1 is a typical value.
Radius of the blur it is measured against.
Trims a uniform border.
Runs after the plan rather than inside it. How much to trim is a function of the pixels, and the planner decides the decode region and scale before a pixel is read, so a trim cannot be a plan operation. Chain it before a resize and the resize still happens first.
How far a pixel may differ from the border color and still be trimmed.
StaticopenOpens a source without decoding it.
The header is read so the planner knows the extent it is working from; no pixel is touched until the plan runs.
The loaded module.
The encoded image, in any shape Source accepts.
A transformation with no operations in it yet.
A chainable transformation over one source.
Nothing runs until you ask for the output. Every method here appends to a plan, and the plan runs once, when bytes or one of its siblings is called. That is not an implementation detail: it is what lets a 100x100 thumbnail of a 16 megapixel photograph decode a 500x500 region at a quarter scale instead of 16 megapixels, and the decision cannot be made after the first operation has already run.
The handle lives in the module's memory, so an image has to be released. Prefer
using:Without
using, call dispose in afinally. bytes does not dispose, because a caller may want two encodings of one plan.