vivomedia / neos-jpeg-pagespeed-optimization
Neos CMS optimization of JPEGs for Google PageSpeed (4:2:0 chroma subsampling)
Package info
github.com/VIVOMEDIA/neos-jpeg-pagespeed-optimization
Type:neos-package
pkg:composer/vivomedia/neos-jpeg-pagespeed-optimization
Requires
- imagine/imagine: ^1.0
- neos/media: ^8.0 || ^9.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
As the Google PageSpeed docs suggest, this Neos CMS package saves JPEG thumbnails with a chroma subsampling of 4:2:0. Colour information is stored at half resolution, which makes JPEGs noticeably smaller. On photos the difference is not visible; on hard coloured edges (e.g. white text on red) it can be.
The behavior of this package has changed with 3.0. It does not contain code anymore, it only sets the Neos option jpeg_sampling_factors, which Neos passes to
Imagine when a thumbnail is saved.
Works very well in addition to moc/imageoptimizer.
Supported Imagine drivers:
The GD driver ignores the option.
Install
Install with composer
composer require vivomedia/neos-jpeg-pagespeed-optimization
The setting only applies to newly created thumbnails. To regenerate existing ones, clear all thumbnails and the cache:
./flow media:clearthumbnails
./flow flow:cache:flush --force
Configuration
The package sets this configuration:
Neos: Media: image: defaultOptions: jpeg_sampling_factors: [2]
Imagine casts the values to integers, so write them as numbers, not as 2x2 strings:
| Value | Result |
|---|---|
[2] |
4:2:0 (default of this package) |
[2, 1, 1] |
4:2:2 |
[1] |
4:4:4 (full colour resolution) |
Disable
To disable the subsampling, e.g. in development context, unset the option in your
/Configuration/Development/Settings.yaml:
Neos: Media: image: defaultOptions: jpeg_sampling_factors: ~
The image library then decides on its own. Current ImageMagick versions use 4:4:4 for a quality of 90 or higher and 4:2:0 below.
Upgrade from 2.x
Version 3.0 replaces the AOP aspect with plain configuration. It is a breaking change.