Skip to content

Optimization#

Both parts are off until switched on in Media → Media index → Optimization.

Compression#

New image sizes are written as JPEG at quality 80 with 4:2:0 chroma subsampling. Original uploads are left as they are.

Why 4:2:0: most uploads on coalesce.io are 4:4:4 JPEGs, and ImageMagick keeps the source's sampling, so every size WordPress made from them carried full-resolution colour. That was most of the difference between WordPress's sizes and Smush Pro's.

Calibration on 48 sizes (large, medium_large, medium) of 16 Smush-compressed originals, through WordPress's own upload, with SSIM against a lossless resize of the original:

Bytes SSIM mean Worst
Smush Pro (the files on disk) 1,487 KB 0.9935 0.9831
BB Media JPEG 1,419 KB (−4.6%) 0.9936 0.9818
BB Media WebP copy 1,043 KB (−29.9%) 0.9939 0.9807

The worst-scoring file, viewed side by side at twice its size: no visible difference.

Compression stays paused while Smush Pro compresses uploads automatically, so nothing is compressed twice. To retire Smush: switch its automatic compression off (BB Media takes over new uploads), check a few uploads, then deactivate it. Files Smush already compressed stay as they are; wp bb-media optimize --recompress --include-smushed would remake their sizes from the originals, which is not needed.

WebP and AVIF copies#

A copy is made next to the main file and every size (photo.jpg → photo.jpg.webp), from the original and resized the way WordPress resized the size, at WebP quality 86. A copy is kept only when it is smaller than the file it copies (small PNG logos usually are not). Copies of new uploads are queued and made in timed background batches; Queue the whole library or wp bb-media optimize --all does the existing ones. A copy is deleted with the file it copies.

BB Cache serves the copies to browsers that accept them ("Serve WebP" in BB Cache's settings, a separate cache variant), asking BB Media which exist. When a run has made or removed copies, BB Media clears BB Cache's remembered answers and purges the page cache once.

The server must send .webp as image/webp. The Media index screen checks one copy; if it reports another type, add AddType image/webp .webp (Apache) or a types entry (nginx). An old local Docker image without that type sends them as image/jpeg.

Disk: WebP copies take about 70% of the bytes of the JPEG sizes they copy. On a nearly full disk, check the space first.

AVIF needs an ImageMagick built with AVIF (staging has one).