The image's RGBA pixel data. It can be replaced by any 8-bit array with width * height * 4 bytes (it is used as is, without copying)
Replaces the pixel data, the array has to hold width * height * 4 bytes
The images height
StaticRESIZE_Area averaging (box filter): every output pixel is the average of the source pixels it covers. Meant for shrinking
StaticRESIZE_Used for automatically preserving an images aspect ratio when resizing.
StaticRESIZE_Bicubic (Catmull-Rom) resizing, sharper than bilinear, especially when enlarging
StaticRESIZE_Bilinear resizing (the default). When shrinking, the filter widens with the scale factor, so every source pixel contributes
StaticRESIZE_Use Nearest-neighbor resizing.
StaticSVG_Scale the SVG to fit the given height. For use with Image.renderSVG
StaticSVG_Scale the SVG by the given amount. For use with Image.renderSVG
StaticSVG_Scale the SVG to fit the given width. For use with Image.renderSVG
The images width
Gets the average color of the image, weighting each pixel by its opacity
The average color (fully opaque), black for fully transparent images
Scales or sets the blue channel
The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
Whether to scale the current value (false) or set every pixel's blue channel to factor * 255 (true)
Blurs the image with a gaussian blur (transparent pixels don't bleed their color)
The blur radius: the gaussian's standard deviation in pixels, like CSS' blur()
Multiplies the color channels, e.g. 1.2 makes the image 20% brighter
The factor (>= 0, 1 keeps the image)
Clones the current image
StaticcolorConverts a color value to an array of RGB values (ignoring the colors alpha)
The color value to convert
The RGB values ([R, G, B])
StaticcolorConverts a color value to an array of RGBA values
The color value to convert
The RGBA values ([R, G, B, A])
Composites (overlays) the source onto this image at the specified coordinates
The image to place
Optionalx: number = 0The x position to place the image at
Optionaly: number = 0The y position to place the image at
Opacity and blend mode, see CompositeOptions
Resizes the image so it is contained in the given bounding box. Can return an image with one axis smaller than the given bounding box.
The width of the bounding box
The height of the bounding box
Optionalmode: ResizeMode = Image.RESIZE_BILINEARThe resizing mode to use
The resized image
Scales the color channels' distance from mid grey, e.g. 1.5 increases the contrast, 0.5 reduces it
The factor (>= 0, 1 keeps the image, 0 makes it grey)
Resizes the image so it covers the given bounding box, cropping the overflowing edges. Always returns the exact dimensions of the bounding box.
The width of the bounding box
The height of the bounding box
Optionalmode: ResizeMode = Image.RESIZE_BILINEARThe resizing mode to use
The resized image
Crops an image to the specified dimensions. The region is clipped to the image, so the result can be smaller than the requested size
The x offset (0-based)
The y offset (0-based)
The new images width
The new images height
Crops the image into a circle with an antialiased edge
Optionaloptions: CropCircleOptionsCrops the image into a circle with an antialiased edge
Optionalmax: booleanWhether to use the larger dimension for the size. Default: false
Optionalfeathering: numberShare of the radius (0..1) over which the edge fades out. Default: 0
StaticdecodeDecodes an image (PNG, JPEG or TIFF)
The binary data to decode
See DecodeOptions. JPEGs, TIFFs and PNGs are rotated/mirrored as their orientation tag (Exif, for PNGs also XMP) says by default: photos taken with a rotated camera are stored sideways
The decoded image
Gets the image's dominant color: the colors are grouped into a few clusters (median cut and k-means), the average color of the largest one is returned
Optionaloptions: DominantColorOptionsWhich colors to ignore, see DominantColorOptions
The image's dominant color (fully opaque); mostly transparent pixels are ignored. If every pixel is ignored as black or white, the filter is dropped
Gets the image's dominant color, see the variant with options
OptionalignoreBlack: booleanWhether to ignore dark colors (all channels below the threshold). Default: true
OptionalignoreWhite: booleanWhether to ignore light colors (all channels above 255 minus the threshold). Default: true
OptionalbwThreshold: numberThe black/white threshold (0-64, in steps of 4 channel values). Default: 15
The image's dominant color (fully opaque)
Draws a box at the specified coordinates (0-based), clipped to the image
The x offset
The y offset
The box width
The box height
The color to fill the box in with, a function gets coordinates relative to the box
Draws an antialiased circle around the center of the specified pixel (0-based)
The center x position
The center y position
The circles radius in pixels
The color, a function gets coordinates relative to the circle's bounding box
Encodes the image into a PNG, with the smallest lossless color type (a palette for up to 256 colors, greyscale or RGB, alpha only if needed). Uses the runtime's native zlib when available
Optionalcompression: numberThe compression level (0-9). Default: 1
Optionalmetadata: PNGMetadataText metadata to include
The encoded data
Encodes the image into a PNG with compression level 1
Optionalmetadata: PNGMetadataText metadata to include
The encoded data
Encodes the image into a JPEG
Optionalquality: number = 90The JPEG quality to use (1-100), chroma subsampling is disabled above 90
Encodes the image into a PNG, an alias of Image.encode
Optionalcompression: numberOptionalmetadata: PNGMetadataEncodes the image into a PNG, an alias of Image.encode
Optionalmetadata: PNGMetadataApplies a fisheye (barrel distortion) effect
Optionalstrength: number = 2The distortion strength (exponent of the radial mapping), higher values bulge the center more
Resizes the image so it is contained in the given bounding box, placing it in the center of the given bounding box. Always returns the exact dimensions of the bounding box.
The width of the bounding box
The height of the bounding box
Optionalmode: ResizeMode = Image.RESIZE_BILINEARThe resizing mode to use
The resized image
Flips / mirrors the image horizontally or vertically
The direction to flip
Applies a gamma correction, values above 1 brighten the dark tones, values below 1 darken them
The gamma (> 0, 1 keeps the image)
Gets the pixel color at the specified position (0-based)
The color value
Gets a view of the RGBA components of the pixel at the specified position (0-based)
The RGBA value
StaticgradientCreates a multi-point gradient generator
The gradient points to use (e.g. {0: 0xff0000ff, 1: 0x00ff00ff})
The gradient generator. The function argument is the position in the gradient (0..1).
Scales or sets the green channel
The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
Whether to scale the current value (false) or set every pixel's green channel to factor * 255 (true)
Converts the image to greyscale by its luma (ITU-R 601, like Pillow), keeping the alpha
StatichslaConverts HSLA colors to RGBA colors
hue (0..1)
saturation (0..1)
lightness (0..1)
opacity (0..1)
color
StatichslConverts HSL colors to RGBA colors (assuming an opacity of 255)
hue (0..1)
saturation (0..1)
lightness (0..1)
color
Shifts the images hue
How many degrees to shift the hue by
Inverts the images colors
Inverts the images lightness (HSL), keeping hue and saturation: dark colors become light and vice versa
Inverts the images value (HSV), keeping hue and saturation: the brightest channel v becomes 255 - v
and the others scale along, black becomes white
Sets the brightness of the image
The lightness to apply (0..1)
Whether to scale the current lightness (false) or just set the new lightness (true)
Sets the images opacity
The opacity to apply (0..1)
Whether to scale the current opacity (false) or just set the new opacity (true)
Scales or sets the red channel
The factor to multiply the channel with (>= 0, results are clamped), or the value (0..1) to set it to
Whether to scale the current value (false) or set every pixel's red channel to factor * 255 (true)
StaticrenderSVGCreates a new image from the given SVG Supports shapes, paths, transforms, use/symbol, CSS styles, gradients, strokes, clip paths, masks and opacity; text, images, filters and patterns are not rendered
The SVG content
The size to use
The SVG resizing mode to use (one of SVG_MODE_SCALE, SVG_MODE_WIDTH, SVG_MODE_HEIGHT)
The rendered SVG graphic
StaticrenderCreates a new image containing the rendered text.
TrueType (ttf/ttc) or OpenType (otf) font buffer to use
Font size in pixels (per em)
Text to render
Optionalcolor: number = 0xffffffffText color to use
Optionallayout: TextLayout = ...The text layout to use
Outline, see TextStyle; the image grows by the outline width on every side
The rendered text
Resizes the image to the given dimensions. Use Image.RESIZE_AUTO as either width or height to automatically preserve the aspect ratio.
The new width
The new height
Optionalmode: ResizeMode = Image.RESIZE_BILINEARThe resizing mode to use
The resized image
StaticrgbaConverts RGBA components to an RGBA value, values are rounded and clamped to 0..255
red (0..255)
green (0..255)
blue (0..255)
alpha (0..255)
RGBA value
StaticrgbaConverts an RGBA value to an array of HSLA values
{number} (0..255)
{number} (0..255)
{number} (0..255)
{number} (0..255)
The HSLA values ([H, S, L, A])
StaticrgbConverts RGB components to an RGBA value (assuming alpha = 255)
red (0..255)
green (0..255)
blue (0..255)
RGBA value
Rotates the image counterclockwise by the given amount of degrees
The angle to rotate the image for (in degrees)
Optionaloptions: RotateOptionsSee RotateOptions
Rotates the image counterclockwise by the given amount of degrees
The angle to rotate the image for (in degrees)
Optionalresize: booleanWhether to resize the image so it fits all pixels or just ignore outlying pixels. Default: true
Rounds the images corners, with antialiased edges
Optionalradius: number = ...The radius of the corners
Sets the saturation of the image
The saturation to apply (0..1)
Whether to scale the current saturation (false) or just set the new saturation (true)
Resizes the image by the given factor
The factor to resize the image with
Optionalmode: ResizeMode = Image.RESIZE_BILINEARThe resizing mode to use
Applies a sepia tone
Sets the pixel color for the specified position (0-based)
Sharpens the image with an unsharp mask: the difference to a blurred copy is amplified
Optionalamount: number = 1How strongly to sharpen (0 does nothing)
Optionalradius: number = 1The radius of the blur the image is compared with (larger values sharpen coarser details)
An RGBA image; provides the codecs and the manipulation functions. Methods that change the image modify it in place and return it, so calls can be chained