Compression
The compress plugin uses the Sharp library to compress images into different formats, such as JPEG, PNG, WebP, and AVIF. This helps reduce file sizes while maintaining image quality, ensuring faster load times and better performance. This plugin also supports compressing images using the ASTC, ETC, ETC2, BCn (DXTn) and Basis supercompressed (ETC1S, UASTC) texture compression standard.
Example
Original
import { compress } from "@assetpack/core/image";
export default {
...
pipes: [
...
// these options are the default values, all options shown here are optional
compress({
jpg: {},
png: { quality: 90 },
webp: { quality: 80, alphaQuality: 80, },
avif: false,
bc7: false,
astc: false,
basis: false,
}),
]
};
API
Option | Type | Description |
---|---|---|
jpg | object | false | Any settings supported by sharp jpeg. |
png | object | false | Any settings supported by sharp png. |
webp | object | false | Any settings supported by sharp webp. |
avif | object | false | Any settings supported by sharp avif. Defaults to false . |
bc7 | object | false | Any settings supported by bc7. Defaults to false . |
astc | object | false | Any settings supported by astc. Defaults to false . |
basis | object | false | Any settings supported by basis. Defaults to false . |
Tags
Tag | Folder/File | Description |
---|---|---|
nc | both | If present the image(s) will not be compressed. |
Example
Original