self:convert

Client

Converts the image to a different pixel format, reducing VRAM by lowering color depth or channel count


Syntax

local status = self:convert(
    format
)

Converting changes pixel format only — the image stays uncompressed in VRAM.
Unlike self:compress, it doesn't use GPU block-compression, so it can be converted again — or compressed later — at any time.

  • Use convert — for quick, reversible VRAM savings, or a specific channel layout.
  • Use compress — for maximum VRAM savings on a finished asset that won't need further format changes.
  • Combining both — convert first if you need a specific format, then compress; compression locks the image afterward.
  • Filter overrides — any self:set_filter override stays applied after conversion; the image is updated in place, not replaced.

Parameters

TypeNameDescription
core.image.texel_formatformatTarget pixel format

Returns

TypeNameDescription
boolstatustrue on successful execution, false otherwise

Examples

Reduce VRAM by converting to RGB565
local entity = core.image.create("assets/background.png")

entity:convert(core.image.texel_format.RGB565)
Convert to RGBA4444 for a low-quality mode
local entity = core.image.create("assets/sprite.png")

entity:convert(core.image.texel_format.RGBA4444)
Convert a grayscale mask to L8
local entity = core.image.create("assets/mask.png")

entity:convert(core.image.texel_format.L8)

On this page