SongGuess
    Preparing search index...

    Interface RequestInitCfPropertiesImageDraw

    interface RequestInitCfPropertiesImageDraw {
        background?: string;
        blur?: number;
        border?:
            | { color: string; width: number }
            | {
                bottom: number;
                color: string;
                left: number;
                right: number;
                top: number;
            };
        bottom?: number;
        brightness?: number;
        composite?: "out"
        | "in"
        | "over"
        | "atop"
        | "xor"
        | "lighter";
        contrast?: number;
        dpr?: number;
        fit?:
            | "cover"
            | "scale-down"
            | "scale-up"
            | "contain"
            | "crop"
            | "pad"
            | "squeeze";
        flip?: "v"
        | "h"
        | "hv";
        gamma?: number;
        gravity?:
            | "auto"
            | "center"
            | "bottom"
            | "left"
            | "top"
            | "face"
            | "right"
            | "entropy"
            | BasicImageTransformationsGravityCoordinates;
        height?: number;
        left?: number;
        opacity?: number;
        repeat?: true
        | "x"
        | "y";
        right?: number;
        rotate?: 0 | 180 | 90 | 270 | 360;
        saturation?: number;
        segment?: "foreground";
        sharpen?: number;
        top?: number;
        trim?:
            | "border"
            | {
                border?: | boolean
                | { color?: string; keep?: number; tolerance?: number };
                bottom?: number;
                height?: number;
                left?: number;
                right?: number;
                top?: number;
                width?: number;
            };
        upscale?: "interpolate"
        | "generate";
        url: string;
        width?: number;
        zoom?: number;
    }

    Hierarchy (View Summary)

    Index
    background?: string

    Background color to add underneath the image. Applies only to images with transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…), hsl(…), etc.)

    blur?: number

    Radius of a blur filter (approximate gaussian). Maximum supported radius is 250.

    border?:
        | { color: string; width: number }
        | {
            bottom: number;
            color: string;
            left: number;
            right: number;
            top: number;
        }

    Adds a border around the image. The border is added after resizing. Border width takes dpr into account, and can be specified either using a single width property, or individually for each side.

    bottom?: number
    brightness?: number

    Increase brightness by a factor. A value of 1.0 equals no change, a value of 0.5 equals half brightness, and a value of 2.0 equals twice as bright. 0 is ignored.

    composite?: "out" | "in" | "over" | "atop" | "xor" | "lighter"

    How to combine the foreground and backdrop pixels to create the result

    contrast?: number

    Increase contrast by a factor. A value of 1.0 equals no change, a value of 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is ignored.

    dpr?: number

    Device Pixel Ratio. Default 1. Multiplier for width/height that makes it easier to specify higher-DPI sizes in .

    fit?:
        | "cover"
        | "scale-down"
        | "scale-up"
        | "contain"
        | "crop"
        | "pad"
        | "squeeze"

    Resizing mode as a string. It affects interpretation of width and height options:

    • scale-down: Similar to contain, but the image is never enlarged. If the image is larger than given width or height, it will be resized. Otherwise its original size will be kept.
    • scale-up: Similar to contain, but the image is never shrunk. If the image is smaller than the given width or height, it will be resized. Otherwise its original size will be kept.
    • contain: Resizes to maximum size that fits within the given width and height. If only a single dimension is given (e.g. only width), the image will be shrunk or enlarged to exactly match that dimension. Aspect ratio is always preserved.
    • cover: Resizes (shrinks or enlarges) to fill the entire area of width and height. If the image has an aspect ratio different from the ratio of width and height, it will be cropped to fit.
    • crop: The image will be shrunk and cropped to fit within the area specified by width and height. The image will not be enlarged. For images smaller than the given dimensions it's the same as scale-down. For images larger than the given dimensions, it's the same as cover. See also trim.
    • pad: Resizes to the maximum size that fits within the given width and height, and then fills the remaining area with a background color (white by default). Use of this mode is not recommended, as the same effect can be more efficiently achieved with the contain mode and the CSS object-fit: contain property.
    • squeeze: Stretches and deforms to the width and height given, even if it breaks aspect ratio
    flip?: "v" | "h" | "hv"

    Flips the images horizontally, vertically, or both. Flipping is applied before rotation, so if you apply flip=h,rotate=90 then the image will be flipped horizontally, then rotated by 90 degrees.

    gamma?: number

    Increase exposure by a factor. A value of 1.0 equals no change, a value of 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.

    gravity?:
        | "auto"
        | "center"
        | "bottom"
        | "left"
        | "top"
        | "face"
        | "right"
        | "entropy"
        | BasicImageTransformationsGravityCoordinates

    When cropping with fit: "cover", this defines the side or point that should be left uncropped. The value is either a string "left", "right", "top", "bottom", "auto", or "center" (the default), or an object {x, y} containing focal point coordinates in the original image expressed as fractions ranging from 0.0 (top or left) to 1.0 (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will crop bottom or left and right sides as necessary, but won’t crop anything from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to preserve as much as possible around a point at 20% of the height of the source image.

    height?: number

    Maximum height in image pixels. The value must be an integer.

    left?: number
    opacity?: number

    Floating-point number between 0 (transparent) and 1 (opaque). For example, opacity: 0.5 makes overlay semitransparent.

    repeat?: true | "x" | "y"
    • If set to true, the overlay image will be tiled to cover the entire area. This is useful for stock-photo-like watermarks.
    • If set to "x", the overlay image will be tiled horizontally only (form a line).
    • If set to "y", the overlay image will be tiled vertically only (form a line).
    right?: number
    rotate?: 0 | 180 | 90 | 270 | 360

    Number of degrees (90, 180, 270) to rotate the image by. width and height options refer to axes after rotation.

    saturation?: number

    Increase contrast by a factor. A value of 1.0 equals no change, a value of 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is ignored.

    segment?: "foreground"

    Image segmentation using artificial intelligence models. Sets pixels not within selected segment area to transparent e.g "foreground" sets every background pixel as transparent.

    sharpen?: number

    Strength of sharpening filter to apply to the image. Floating-point number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a recommended value for downscaled images.

    top?: number

    Position of the overlay image relative to a given edge. Each property is an offset in pixels. 0 aligns exactly to the edge. For example, left: 10 positions left side of the overlay 10 pixels from the left edge of the image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom of the background image.

    Setting both left & right, or both top & bottom is an error.

    If no position is specified, the image will be centered.

    trim?:
        | "border"
        | {
            border?: | boolean
            | { color?: string; keep?: number; tolerance?: number };
            bottom?: number;
            height?: number;
            left?: number;
            right?: number;
            top?: number;
            width?: number;
        }

    Allows you to trim your image. Takes dpr into account and is performed before resizing or rotation.

    It can be used as:

    • left, top, right, bottom - it will specify the number of pixels to cut off each side
    • width, height - the width/height you'd like to end up with - can be used in combination with the properties above
    • border - this will automatically trim the surroundings of an image based on it's color. It consists of three properties:
      • color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)
      • tolerance: difference from color to treat as color
      • keep: the number of pixels of border to keep
    upscale?: "interpolate" | "generate"

    Controls the algorithm used when an image needs to be enlarged. This parameter works with any fit mode that upscales, such as contain, cover, and scale-up. It has no effect when fit=scale-down or when the target dimensions are smaller than the source.

    • interpolate: Uses bicubic interpolation, which may reduce image quality. This is the default behavior when upscale is not specified.
    • generate: Uses AI upscaling to produce sharper, more detailed results when enlarging images.
    url: string

    Absolute URL of the image file to use for the drawing. It can be any of the supported file formats. For drawing of watermarks or non-rectangular overlays we recommend using PNG or WebP images.

    width?: number

    Maximum width in image pixels. The value must be an integer.

    zoom?: number

    Specifies how closely the image is cropped toward detected faces when combined with the gravity=face option. Accepts a valid range between 0.0 (includes as much of the background as possible) and 1.0 (crops the image as closely to the face as possible). The default is 0.