Optimizing images

Aside from the basic optimizations that the Pillow backend provides, Willow supports using dedicated libraries to optimize images. Out of the box, Willow comes with optimizers for gifsicle, jpegoptim, optipng, pngquant and cwebp.

They can be enabled by setting the WILLOW_OPTIMIZERS environment variable to true. To enable a specific subset of optimizers, set the WILLOW_OPTIMIZERS environment variable to a comma-separated list of their library names. For example, to enable only jpegoptim and optipng:

WILLOW_OPTIMIZERS=jpegoptim,optipng

or if using Django:

WILLOW_OPTIMIZERS = "jpegoptim,optipng"
# or as a list of optimizer library names
WILLOW_OPTIMIZERS = ["jpegoptim", "optipng"]