tinyimg - v1.0.0
    Preparing search index...

    Interface TransformOptions

    Everything a one-shot transformation can ask for.

    Every field is optional and an empty object is a valid request: it decodes and re-encodes. The order the operations run in is fixed and documented on transform, because an option object has no order of its own and two callers writing the same keys have to get the same image.

    interface TransformOptions {
        background?: Color;
        blur?: number;
        brightness?: number;
        budgetMs?: number;
        contrast?: number;
        crop?: Rect;
        dpr?: number;
        effort?: "fancy" | "fast";
        filter?: ResampleFilter;
        fit?: Fit;
        flip?: FlipAxis;
        format?: ImageFormat | "auto";
        gamma?: number;
        gravity?: Gravity;
        grayscale?: boolean;
        height?: number;
        hue?: number;
        invert?: boolean;
        lossless?: boolean;
        metadata?: MetadataPolicy;
        progressive?: boolean;
        quality?: number;
        rotate?: 0 | 180 | 90 | 270;
        saturation?: number;
        sharpen?: number;
        trim?: number | boolean;
        width?: number;
    }
    Index
    background?: Color

    Fills whatever a pad or a rotation leaves empty.

    blur?: number

    Gaussian blur radius in pixels.

    brightness?: number

    Scales every channel. 1 is unchanged.

    budgetMs?: number

    A CPU budget in milliseconds, which changes what format: 'auto' chooses.

    The Workers Free plan allows 10 milliseconds of CPU per request and it is not configurable, so a request either fits or fails; there is no paying slightly more. Give a budget below the limit rather than at it, since the estimate behind the choice is accurate to about 20%.

    An explicitly named format is never substituted, however far over budget it is: naming one is a decision, and this option does not overrule it.

    contrast?: number

    Scales every channel about mid gray. 1 is unchanged.

    crop?: Rect

    Source rectangle, taken before anything else.

    dpr?: number

    Multiplies width and height, for serving a retina variant of one request.

    effort?: "fancy" | "fast"

    How much computation the encoder may spend. 'fancy' is the default.

    A separate axis from TransformOptions.quality: quality says what the output should look like, this says how hard to work to get there. See the effort option on Image.bytes for what each format gives up and what it was measured to cost.

    Weights the resample reads through. auto is an area average down and a cubic up.

    fit?: Fit

    How an aspect mismatch is absorbed. Only read when both width and height are set.

    flip?: FlipAxis

    Which axes to mirror.

    format?: ImageFormat | "auto"

    Container to encode as. Defaults to the source's own format.

    'auto' picks one. On its own that is WebP, which is the better artifact. With TransformOptions.budgetMs it becomes the best format that fits the budget, which matters because the encoders differ by about a factor of five per sample.

    gamma?: number

    Raises every channel to a power. 1 is unchanged.

    gravity?: Gravity

    Which part a crop keeps, or where a pad puts the image.

    grayscale?: boolean

    Replaces every channel with the pixel's luminance.

    height?: number

    Target height in pixels. With width unset, the aspect ratio is kept.

    hue?: number

    Rotates the hue, in degrees.

    invert?: boolean

    Subtracts every channel from full scale, leaving alpha alone.

    lossless?: boolean

    Use a format's lossless mode where it has one.

    metadata?: MetadataPolicy

    Whether to carry EXIF and other metadata into the output. Defaults to keep.

    progressive?: boolean

    Write a progressive or interlaced stream.

    quality?: number

    Quality for a lossy format, 1 through 100.

    rotate?: 0 | 180 | 90 | 270

    Quarter turns clockwise. Anything else is rejected; use Image.rotateFree.

    saturation?: number

    Moves every channel toward or away from its luminance. 1 is unchanged.

    sharpen?: number

    Unsharp mask amount.

    trim?: number | boolean

    Trims a uniform border, at this tolerance. true means a tolerance of 8.

    width?: number

    Target width in pixels. With height unset, the aspect ratio is kept.