PHPackages                             heyday/silverstripe-optimisedimage - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. heyday/silverstripe-optimisedimage

ActiveSilverstripe-module[Image &amp; Media](/categories/media)

heyday/silverstripe-optimisedimage
==================================

Uses various binary tools like jpegoptim and optipng to optimise resampled images create by SilverStripe

2.2.2(10y ago)3033.3k7[3 issues](https://github.com/heyday/silverstripe-optimisedimage/issues)[1 PRs](https://github.com/heyday/silverstripe-optimisedimage/pulls)MITPHP

Since Nov 10Pushed 8y ago27 watchersCompare

[ Source](https://github.com/heyday/silverstripe-optimisedimage)[ Packagist](https://packagist.org/packages/heyday/silverstripe-optimisedimage)[ RSS](/packages/heyday-silverstripe-optimisedimage/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (2)Versions (14)Used By (0)

SilverStripe Optimised Image
============================

[](#silverstripe-optimised-image)

This module provides two image manipulation services that can be configured independently:

- Run command-line image optimisation tools on images resampled by SilverStripe: reduces the file size of the generated images without reducing fidelity in a noticeable way
- Resize images on upload to fit within configured dimensions: prevents images with massive dimensions entering the assets and becoming a memory problem when resampling.

For a SilverStripe `2.4` version check the `0.1` branch.

Configurations for some common image optimisation tools (eg. jpegoptim and optipng) are provided as part of this module, though any command line program can be used with the image optimisation service. No optimisation program binaries are bundled with this module, so you'll need to install any programs you want to use on the target system.

Note that only resampled images are optimised by the optimisation service module (eg. using CroppedImage, SetWidth, SetHeight, PaddedResize, etc). If you want to optimise images without resizing them, [there is currently a workaround to trigger optimisation](https://github.com/heyday/silverstripe-optimisedimage/issues/4#issuecomment-60821831).

Installation (with composer)
----------------------------

[](#installation-with-composer)

```
$ composer require heyday/silverstripe-optimisedimage

```

Usage
-----

[](#usage)

### Resampling Images on upload

[](#resampling-images-on-upload)

By default, resampling on upload is not enabled. To activate it, the `ResampleImage` extension needs to be added to `Image`. In your `mysite/_config/config.yml` add:

```
Image:
  extensions:
    - ResampleImage
```

The default maximum width &amp; height for uploaded images is **1024 x 1024** pixels. Images larger than this will be scaled to fit their largest dimension to this size.

You can set your own maximum height and width for uploaded images by overriding the default config in your `mysite/_config/config.yml`:

```
ResampleImage:
  max_x: 2000
  max_y: 2500
```

Note that resampling on upload is a destructive process: the original uploaded image is discarded.

### Optimising SilverStripe Resampled Images - Selecting a backend

[](#optimising-silverstripe-resampled-images---selecting-a-backend)

The image backend that SilverStripe uses needs to be changed to either `OptimisedGDBackend` or `OptimisedImagickBackend` depending on whether you want to us GD or Imagick. To do this, in your `mysite/_config/config.yml` add:

```
Image:
    backend: OptimisedGDBackend

// or

Image:
    backend: OptimisedImagickBackend
```

Configuration options:

- enabledCommands
- availableCommands
- binDirectory
- optimisingQuality

At the very least `enabledCommands` needs to be overridden in your own config in order to enable the optimising of images resampled by SilverStripe.

This can be done as follows,

1. Create a file `mysite/_config/optimisedimage.yml`
2. Add the following contents

```
---
After: 'silverstripe-optimisedimage/config#core'
---
ImageOptimiserService:
  enabledCommands:
    - jpegoptim
    - optipng
```

If you want to add your own commands, you can override `availableCommands` e.g.

```
---
After: 'silverstripe-optimisedimage/config#core'
---
ImageOptimiserService:
  enabledCommands:
    - jpegoptim
    - optipng
  availableCommands:
    jpg:
      jpegoptim: '%s/jpegoptim -p --strip-all --all-progressive %s'
    png:
      optipng: '%s/optipng %s -o 1 -strip all -i 1'
    gif:
      optipng: '%s/optipng %s -o 1 -strip all'
```

If your binaries are not located at `/usr/local/bin/` you can override this by setting `binDirectory`

```
---
After: 'silverstripe-optimisedimage/config#core'
---
ImageOptimiserService:
  enabledCommands:
    - jpegoptim
    - optipng
  binDirectory: '/home/user/bin/'
```

If your binaries aren't all located in the same directory you will need to manually enter the command by overriding `availableCommands`

```
---
After: 'silverstripe-optimisedimage/config#core'
---
ImageOptimiserService:
  enabledCommands:
    - jpegoptim
    - optipng
  availableCommands:
    jpg:
      jpegoptim: '/my/special/path/jpegoptim -p -m%3$d --strip-all %2$s'
```

Commands have certain variables exposed to them when they are built, this is done by `sprintf`, the variables available are in the following order:

1. `binDirectory`
2. File path to be optimised
3. `optimisingQuality`

If when defining a custom command you need to use these arguments in a different order, you will need to use a position specifier, see [PHP sprintf](http://php.net/manual/en/function.sprintf.php#example-4811)

License
-------

[](#license)

Optimised image is licensed under an [MIT license](http://heyday.mit-license.org/)

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 74.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~116 days

Recently: every ~215 days

Total

12

Last Release

3695d ago

Major Versions

0.1.x-dev → 1.0.02013-07-14

1.0.x-dev → 2.0.02013-09-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/de4d8d61f202a03e88c3ed30cce3bfedbc6f56a16e3f3b25546c61aadc51bca2?d=identicon)[heyday](/maintainers/heyday)

---

Top Contributors

[![camspiers](https://avatars.githubusercontent.com/u/51294?v=4)](https://github.com/camspiers "camspiers (20 commits)")[![stecman](https://avatars.githubusercontent.com/u/2230769?v=4)](https://github.com/stecman "stecman (5 commits)")[![mschilder](https://avatars.githubusercontent.com/u/1308968?v=4)](https://github.com/mschilder "mschilder (1 commits)")[![sn4h](https://avatars.githubusercontent.com/u/131519602?v=4)](https://github.com/sn4h "sn4h (1 commits)")

### Embed Badge

![Health badge](/badges/heyday-silverstripe-optimisedimage/health.svg)

```
[![Health](https://phpackages.com/badges/heyday-silverstripe-optimisedimage/health.svg)](https://phpackages.com/packages/heyday-silverstripe-optimisedimage)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k16.8k](/packages/prestashop-prestashop)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[mindkomm/timmy

Advanced image manipulation for Timber.

17737.1k](/packages/mindkomm-timmy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
