Skip to main content

Mipmaps

The mipmap plugin generates mipmaps for images, creating multiple resolutions of the same image. This is particularly useful for optimizing graphics in web games, where different resolutions are needed for various screen sizes and device capabilities.

info

When generating multiple resolutions, the plugin assumes that the original image is at the highest resolution. The plugin will then generate lower-resolution versions of the image based on the specified template and resolutions.

Example

Original

Input Image
Input Image
import { mipmap } from "@assetpack/core/image";

export default {
...
pipes: [
...
// these options are the default values, all options shown here are optional
mipmap({
template: "@%%x",
resolutions: { default: 1, low: 0.5 }, // { high: 2, default: 1, low: 0.5 }
fixedResolution: "default",
}),
]
};

Example: custom resolution

Original

Input Image
Input Image
import { mipmap } from "@assetpack/core/image";

export default {
...
pipes: [
...
mipmap({
resolutions: { high: 2, default: 1, low: 0.5 },
}),
]
};

API

OptionTypeDescription
templatestringA template for denoting the resolution of the images.
Defaults to @%%x.
resolutionsobjectAn object containing the resolutions that the images will be resized to.
Defaults to { default: 1, low: 0.5 }.
fixedResolutionstringA resolution used if the fix tag is applied e.g.
Resolution must match one found in resolutions.
Defaults to default.

Tags

TagFolder/FileDescription
fixbothIf present the fixedResolution will be used. No other resolutions will be generated.

Example: fixed resolution

Original

Input Image
Input Image