core.image.create

Client

Creates a new image instance from a file path


Syntax

local instance = core.image.create(
    path,
    mipmaps = false
)

Only needed if you already know a mipmap-based filter is coming.

  • Use it when — an image is going to use NEAREST_MIPMAP, LINEAR_MIPMAP, or an ANISOTROPIC filter variant.
  • Before compressing — if both mipmaps and compression are needed, pass true here; self:compress cannot generate mipmaps, so this is the only opportunity.

Parameters

TypeNameDescription
stringpathFile path to a supported image asset
Refer Formats section
boolmipmapsDetermines whether to generate a mipmap chain for the underlying image

Returns

TypeNameDescription
imageinstanceCreated image instance

Formats

FormatExtensionDescription
JPEG.jpg | .jpegLossy compressed image, best for photos
PNG.pngLossless compressed image, supports transparency
WebP.webpModern format, supports both lossy and lossless
BMP.bmpUncompressed bitmap, no lossy artifacts
DDS.ddsGPU-native compressed format, ideal for 3D assets
KTX.ktx | .ktx2Khronos texture format, supports GPU compression and mipmaps

Examples

Create an image instance from a JPEG file
local entity = core.image.create("assets/photo.jpg")
Create an image instance from a PNG file
local entity = core.image.create("assets/sprite.png")
Create an image instance from a WebP file
local entity = core.image.create("assets/image.webp")
Create an image instance from a DDS file
local entity = core.image.create("assets/terrain.dds")
Create an image with mipmaps
local entity = core.image.create("assets/terrain/cliff_diffuse.png", true)

entity:set_filter(core.image.texture_filter.LINEAR_MIPMAP_ANISOTROPIC)

On this page