RequestInitCfPropertiesImageDraw
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6280
Extends
Section titled “Extends”Properties
Section titled “Properties”background?
Section titled “background?”
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.)
Inherited from
Section titled “Inherited from”BasicImageTransformations
.background
bottom?
Section titled “bottom?”
optional
bottom:number
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6315
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
Inherited from
Section titled “Inherited from”gravity?
Section titled “gravity?”
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.
Inherited from
Section titled “Inherited from”BasicImageTransformations
.gravity
height?
Section titled “height?”
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.
Inherited from
Section titled “Inherited from”BasicImageTransformations
.height
optional
left:number
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6314
opacity?
Section titled “opacity?”
optional
opacity:number
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6292
Floating-point number between 0 (transparent) and 1 (opaque). For example, opacity: 0.5 makes overlay semitransparent.
repeat?
Section titled “repeat?”
optional
repeat:true
|"x"
|"y"
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6301
- 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?
Section titled “right?”
optional
right:number
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6316
rotate?
Section titled “rotate?”
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.
Inherited from
Section titled “Inherited from”BasicImageTransformations
.rotate
optional
top:number
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6313
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.
url:
string
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20250823.0/node_modules/@cloudflare/workers-types/index.ts:6287
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?
Section titled “width?”
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.