Better image optimisation in Drupal maintenance support plans

When optimising a site for performance, one of the options with the best effort-to-reward ratio is image optimisation. Crunching those images in your Front End workflow is easy, but how about author-uploaded images through the CMS?

by
Tony Comben
/ 24 January 2020

Recently, a client of ours was looking for ways to reduce the size of uploaded images on their site without burdening the authors. To solve this, we used the module Image Optimize which allows you to use a number of compression tools, both local and 3rd party.
The tools it currently supports include:
Local
PNG 
AdvDef (Lossless)
AdvPng (Lossless)
OptiPng (Lossless)
PngCrush (Lossless)
PngOut (Lossless)
PngQuant (Lossy)

JPEG
JfifRemove (Lossless)
JpegOptim (Lossy or Lossless)
JpegTran (Lossless)

3rd Party 
Resmush.it (General)
TinyPng (PNG & JPEG)

We decided to avoid the use of 3rd party services, as processing the images on our servers could reduce processing time (no waiting for a third party to reply) and ensure reliability.
Picking your server-side compression tool
In order to pick the tools which best served our we picked an image that closely represented the type of image the authors often used. We picked an image featuring a person’s face with a complex background – one png and one jpeg, and ran it through each of the tools with a moderately aggressive compression level.
PNG Results
Compression Library
Compressed size
Percentage saving
Original (Drupal maintenance support plans 8 default resizing)
234kb

AdvPng
234kb
0%
OptiPng
200kb
14.52%
PngCrush
200kb
14.52%
PngOut
194kb
17.09%
PngQuant
63kb
73.07%
Compression Library
Compressed size
Percentage saving
Original
1403kb

AdvPng
1403kb
0%
OptiPng
1288kb
8.19%
PngCrush
1288kb
8.19%
PngOut
1313kb
6.41%
PngQuant
445kb
68.28%
JPEG Results
Compression Library
Compressed size
Percentage saving
Original (Drupal maintenance support plans 8 default resizing)
57kb

JfifRemove
57kb
0%
JpegOptim
49kb
14.03%
JpegTran
57kb
0%
Compression Library
Compressed size
Percentage saving
Original
778kb

JfifRemove
778kb
0%
JpegOptim
83kb
89.33%
JpegTran
715kb
8.09%
Using a combination of PngQuant and JpegOptim, we could save anywhere between 14% and 89% in file size, with larger images bringing greater percentage savings.
Setting up automated image compression in Drupal maintenance support plans 8
The Image Optimize module allows us to set up optimisation pipelines and attach them to our image styles. This allows us to set both site-wide and per-image style optimisation.
After installing the Image Optimize module, head to the Image Optimize pipelines configuration (Configuration > Media > Image Optimize pipeline) and add a new optimization pipeline.
Now add the PngQuant and JpegOptim processors. If they have been installed to the server Image Optimize should pick up their location automatically, or you can manually set the location if using a standalone binary.
JpegOptim has some additional quality settings, I’m setting “Progressive” to always and “Quality” to a sweet spot of 60. 70 could also be used as a more conservative target.
The final pipeline looks like the following:
Back to the Image Optimize pipelines configuration page, we can now set the new pipeline as the sitewide default:
And boom! Automated sitewide image compression!
Overriding image compression for individual image styles
If the default compression pipeline is too aggressive (or conservative) for a particular image style, we can override it in the Image Styles configuration (Configuration > Media > Image styles). Edit the image style you’d like to override, and select your alternative pipeline:
Applying compression to existing images
Flushing the image cache will recreate existing images with compression the next time the image is loaded. This can be done with the drush command 
drush image-flush –all
Conclusion
Setting up automated image optimisation is a relatively simple process, with potentially large impacts on site performance. If you have experience with image optimisation, I would love to hear about it in the comments.

Tagged

Image Optimisation


Source: New feed

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Better image optimisation in Drupal maintenance support plans

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.