Read a single pixel from an image
@eryx/image Module
JSON
Basic operations for reading and writing images.
Summary
Classes
Functions
API Reference
Classes
Image
Properties
The width of the image, in pixels
The height of the image, in pixels
The number of bytes each pixel uses. All images are currently loaded in 4-channel RGBA mode.
The raw buffer of pixel data, arranged in row-major order
Image:getPixel
Parameters
The x coordinate. 0-indexed
The y coordinate. 0-indexed
Returns
Tuple of {R, G, B, A}, all in range 0-255
Image:setPixel
Write a single pixel to an image
Parameters
The x coordinate. 0-indexed
The y coordinate. 0-indexed
Tuple of {R, G, B, A}, all in range 0-255
Image:save
Save this image to a file. The format is inferred from the filename.
Supported formats:
- PNG:
.png - JPEG:
.jpg/.jpeg - BMP:
.bmp - TGA:
.tga
Image:resize
Resize an image.
Downsampling an image uses the Mitchell filter, upsampling uses cubic interpolation.
Functions
image.open
Open an image from the filesystem. The format is inferred from the filename.
Supported formats: JPEG, PNG, TGA, BMP, PSD, GIF, HDR, PIC, PNM
image.fromRGBABuffer
Load an image from a buffer.
Parameters
The buffer containing raw pixel data in RGBA format
The width of the image in pixels
The height of the image in pixels
The number of bytes per pixel. The only legal value for this parameter is 4