Automaticly optimise all uploaded & resampled images in SilverStripe

Installs: 6 784

Dependents: 1

Suggesters: 0

Security: 0

Stars: 7

Watchers: 1

Forks: 2

Open Issues: 0


1.0.4 2019-06-12 20:38 UTC

This package is auto-updated.

Last update: 2021-11-14 07:01:39 UTC


A module to automatically optimise/compress both uploaded as well as any resampled (cropped, scaled etc) images in SilverStripe. Images (JPG, PNG & GIF) are automatically optimised, provided you have the correct binaries installed (see "Installation" below).

The module overrides the default FlysystemAssetStore to first optimise the image before adding the image to the store. It works transparently, and includes a task to optimise all existing (previously created) images.


  • silverstripe/assets ^4.0
  • spatie/image-optimizer - automatically installed
  • JpegOptim, Optipng, Pngquant 2 & Gifsicle binaries (see below)

Optimisation tools

The module uses spatie/image-optimizer and will use the following optimisers if they are both present and in your default path on your system:


composer require axllent/silverstripe-image-optimiser

Installing the utilities on Ubuntu:

sudo apt-get install jpegoptim optipng pngquant gifsicle

Installing the utilities on Alpine Linux:

apk add jpegoptim optipng pngquant gifsicle


Assuming you have the necessary binaries installed, it should "just work" with the default settings once you have flushed your SilverStripe installation.

If you need to optimise any previously-uploaded images, see dev/tasks/ImageOptimiser. This should only be needed once for older images as any new images uploaded will get automatically optimised. Currently this has been disabled as it causes corruption due to filehash mismatches (and upgrade issues to >= 4.4.0). Once I have thought of a more elgant method I will enable it. In the meantime pull requests are welcome.

For custom optimisation settings, please refer to the Configuration documentation.