Skip to content

Image

An object representing a image.


properties

Data : buffer

The image data as a unsigned 8 bit interleaved buffer.

Width : number

The width of the image in pixels.

Height : number

The height of the image in pixels.

Channels : number

How many colour channels the image has.


methods

Encode -> buffer

Image:Encode(format : ImageFormat) : buffer

Encodes the image into a certain image format.

Dimensions -> Image

Image:Dimensions(
    width: number,
    height: number
) : Image

Sets the width and height of the image.
Returns itself.

Resize -> Image

Image:Resize(
    width: number,
    height: number,
    filter: ImageResizeFilter?
) : Image

Resizes the image to a new width & height.
Interpolation filters supported: Returns itself.

  • NEAREST - nearest neighbour
  • BILINEAR - bilinear interpolation between 4 points
  • LANCZOS3 - LANCZOS interpolation using 36 points

Flip -> Image

Image:Flip(channel: number?) : Image

Vertically mirrors the image.
Returns itself.

Flop -> Image

Image:Flop(channel: number?) : Image

Horizontally mirrors the image.
Returns itself.

Greyscale -> Image

Greyscale() : Image

Converts the image into greyscale using luminance.
Returns itself.

Convolve -> Image

Image:Convolve(
    width : number,
    height : number,
    kernel : {number}
) : Image

Performs a convolution on the image using the provided kernel.
Returns itself.

Clone -> Image

Clone() : Image    

Clones the image, returning its copy.

GradientMagnitude -> Image

Image:GradientMagnitude(other : Image) : Image

Computes the gradient magnitude between the image and another image.
Returns itself.

RemoveAlpha -> Image

Image:RemoveAlpha() : Image

Removes the alpha channel of the image.
Treated as a no-op if the image does not have a alpha channel.
Returns itself.


metamethods

__tostring -> string

Converts the image into a string in the format image [Width]x[Height]


types

ImageFormat

type ImageFormat = "PNG" | "JPEG" | "WEBP" | "PNM" | "TIFF" | "BMP" | "QOI"

ImageResizeFilter

type ImageResizeFilter = "NEAREST" | "BILINEAR" | "LANCZOS3"