After the development of the website, it is mandatory to give a user an overall excellent experience such as less loading time, or receiving the top rankings in search engine optimization. This can be completed by the performance optimization of the website. Optimized images are a vital component of website optimization.
Drupal has a built in feature that optimizes and compresses JPEG images. However, Drupal does not offer a feature that allows optimization of PNG format images that develop via Image style. Instead, in order to optimize PNG format of images, Drupal uses ImageAPI Otimize contributed model. Below is the URL of ImageAPI Optimize module:
https://www.drupal.org/project/imageapi_optimize
After downloading and enabling the ImageAPI Optimize module, navigate to admin/config/media/image-toolkit. You will be able to see this in the Drupal admin of your site. You can then proceed to select the ImageAPI Optimize radio button, and then click Save.
Following this, you should be sure to configure the ImageAPI Optimize Service settings.
You can use either commands RHEL or Debian based on Linux variants below to install image compressors on a server.
Debian: apt-get install advancecomp
RHEL: yum install advancecomp
Debian: apt-get install optipng (ensure you are using a version 0.7.5 or higher)
RHEL: yum install optipng
Debian: apt-get install pngcrush (ensure you are using a version 0.7.5 or higher)
RHEL: yum install pngcrush
Debian: download binary archive and extract to /usr/local/bin
RHEL: download binary archive and extract to /usr/ bin
Debian: apt-get install pngcrush (ensure you are using a version 0.7.5 or higher)
RHEL: yum install pngquant
Debian: apt-get install jpegoptim
RHEL: yum install jpegoptim
Debian: apt-get install libjpeg-progs
RHEL: yum install libjpeg
It would need to be compiled after compilation copy it into your path:
wget http://lyncd.com/files/imgopt/jfifremove.c
gcc -o jfifremove jfifremove.c
mv jfifremove /usr /bin
After the installation of an image compressor, you can then add path of all the compressors in appropriate fields and conclude by saving the configuration.
We have completed the setup of ImageAPI Optimization. Now, we need to flush the existing image styles by using below Drush command:
drush image-flush
OR
You can install Image Style Flush module.