ImageService

Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.

ShotInstanceservicenot creatablecomingImages and GPU

Up and coming

Open any image file, check its size without loading it, and pack sprite sheets.

Write use ImageService. LoadAsync opens PNG, JPEG, BMP, TGA and WEBP files into an EditableImage, and GetInfoAsync reads only the header. CreateColorAtlas turns a list of colours into a grid with a UV for each, Pack lays images out as one sprite sheet for ImageRectOffset and ImageRectSize, and ToDataUri gives a base64 data URI.

A service: write use ImageService.

Passes shot check todayLuau
local function example(x : ImageService)
	local image, why = x:LoadAsync("icon.png")
	print(image and image.Size, why)
end

Methods

NameArgumentsReturnsDescription
LoadAsync
yields
(source: string | buffer)(EditableImage?, string?)Opens a PNG, JPEG, BMP, TGA or WEBP image, from a path or the file's bytes, as an EditableImage.
GetInfoAsync
yields
(path: string)({ Size: Vector2, Format: "PNG" | "JPEG" | "BMP" | "TGA" | "WEBP", Bytes: number }?, string?)Reads an image file's size, format and byte count from its header alone, without decoding it.
CreateColorAtlas(colors: { Color3 }, cellSize: number?)(EditableImage, { [Color3]: Vector2 })Makes a square grid with one cell per colour and each colour's UV at its cell centre; bigger cells keep filtering from bleeding.
Pack(images: { EditableImage }, options: { Padding: number?, MaxSize: number?, PowerOfTwo: boolean? }?)({ Image: EditableImage, Rects: { Rect } }?, string?)Packs images into one sprite sheet; Rects come in input order, ready for ImageRectOffset and ImageRectSize, and nil when they don't fit MaxSize.
ToDataUri(image: EditableImage | buffer)stringReturns the image as a data:image/png;base64 URI.
From ShotInstance 33