textureCompress

  • Optimizes images, optionally resizing or converting to JPEG, PNG, WebP, or AVIF formats.

    Requires sharp, and is available only in Node.js environments.

    Example:

    import { textureCompress } from '@gltf-transform/functions';
    import sharp from 'sharp';
    
    // (A) Optimize without conversion.
    await document.transform(
        textureCompress({encoder: sharp})
    );
    
    // (B) Optimize and convert images to WebP.
    await document.transform(
        textureCompress({
            encoder: sharp,
            targetFormat: 'webp',
            slots: /^(?!normalTexture).*$/ // exclude normal maps
        })
    );
    
Function symbol, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy Documented with greendoc © 2023 MIT License