Skip to content

RequestInitCfPropertiesImage

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6318

optional anim: boolean

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6391

Whether to preserve animation frames from input files. Default is true. Setting it to false reduces animations to still images. This setting is recommended when enlarging images or processing arbitrary user content, because large GIF animations can weigh tens or even hundreds of megabytes. It is also useful to set anim:false when using format:“json” to get the response quicker without the number of frames.


optional background: string

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6208

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

BasicImageTransformations.background


optional blur: number

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6416

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


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

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6433

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.


optional brightness: number

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6450

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.


optional compression: "fast"

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6482

Slightly reduces latency on a cache miss by selecting a quickest-to-compress file format, at a cost of increased file size and lower image quality. It will usually override the format option and choose JPEG over WebP or AVIF. We do not recommend using this option, except in unusual circumstances like resizing uncacheable dynamically-generated images.


optional contrast: number

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6456

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.


optional dpr: number

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6324

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


optional draw: RequestInitCfPropertiesImageDraw[]

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6421

Overlays are drawn in the order they appear in the array (last array entry is the topmost layer).


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

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6181

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.
  • 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

BasicImageTransformations.fit


optional flip: "h" | "v" | "hv"

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6473

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.


optional format: "json" | "avif" | "webp" | "jpeg" | "png" | "baseline-jpeg" | "png-force" | "svg"

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6374

Output format to generate. It can be:

  • avif: generate images in AVIF format.
  • webp: generate images in Google WebP format. Set quality to 100 to get the WebP-lossless format.
  • json: instead of generating an image, outputs information about the image, in JSON format. The JSON object will contain image size (before and after resizing), source image’s MIME type, file size, etc.
  • jpeg: generate images in JPEG format.
  • png: generate images in PNG format.

optional gamma: number

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6461

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.


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

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6194

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.

BasicImageTransformations.gravity


optional height: number

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6154

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

BasicImageTransformations.height


optional metadata: "keep" | "copyright" | "none"

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6405

What EXIF data should be preserved in the output image. Note that EXIF rotation and embedded color profiles are always applied (“baked in” into the image), and aren’t affected by this option. Note that if the Polish feature is enabled, all metadata may have been removed already and this option may have no effect.

  • keep: Preserve most of EXIF metadata, including GPS location if there’s any.
  • copyright: Only keep the copyright tag, and discard everything else. This is the default behavior for JPEG files.
  • none: Discard all invisible EXIF metadata. Currently WebP and PNG output formats always discard metadata.

optional origin-auth: "share-publicly"

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6427

Fetching image from authenticated origin. Setting this property will pass authentication headers (Authorization, Cookie, etc.) through to the origin.


optional quality: number | "low" | "medium-low" | "medium-high" | "high"

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6362

Quality setting from 1-100 (useful values are in 60-90 range). Lower values make images look worse, but load faster. The default is 85. It applies only to JPEG and WebP images. It doesn’t have any effect on PNG.


optional rotate: 0 | 90 | 180 | 270 | 360

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6213

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

BasicImageTransformations.rotate


optional saturation: number

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6467

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.


optional sharpen: number

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6411

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.


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

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6340

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

optional width: number

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6150

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

BasicImageTransformations.width