Zodinet

Optimize images with JPEG/PNG

You are wondering about your images size can flood your server disk space and doesn’t want to optimize one by one image.So, you can use JpegOptim and PngOptim tool now on CentOS & Ubuntu.

 

I. Prerequisites

 

You need to install following linux tool

 

1. JPEGOPTIM

 

Install JpegOptim with Centos

 

yum -y install https://extras.getpagespeed.com/release-latest.rpm
sudo yum update
sudo yum install -y jpegoptim

 

Install JpegOptim with Ubuntu

 

sudo apt-get update -y
sudo apt-get install -y jpegoptim

 

Install JpegOptim with HomeBrew

 

brew install jpegoptim

 

2. OPTIPNG

 

Install OptiPng with CentOS

 

sudo yum update
sudo yum install -y optipng

 

Install OptiPng with Ubuntu

 

sudo apt-get update -y
sudo apt-get install -y optipng

 

Install OptiPng with HomeBrew

 

brew install optipng

 

 

 

3. ImageMagic

 

Install ImageMagic with CentOS

 

yum install ImageMagick ImageMagick-devel ImageMagick-perl

 

Install ImageMagic with Ubuntu

 

NOT YET

 

Install ImageMagic with MacOSX Brew

 

brew install imagemagick

 

II. Optimize images

 

Run following command to optimize your images

 

cd WEBROOT
find . -iname '*.jpeg' -print0 |  xargs -0 -n 1 -P 6 jpegoptim --max=82 --all-progressive --strip-all --preserve --totals --force
find . -iname '*.jpg' -print0 |  xargs -0 -n 1 -P 6 jpegoptim --max=82 --all-progressive --strip-all --preserve --totals --force
find . -iname '*.png' -print0 | xargs -0 -n 1 -P 6 optipng -o7 -preserve

 

Run following command to resize your images width into 1500 for maximum

 

find . -iname '*.jpeg' -print0 | xargs -0 -n 1 -P 6 mogrify -format jpeg -flatten -resize 1500\>
find . -iname '*.png' -print0 | xargs -0 -n 1 -P 6 mogrify -format png -flatten -resize 1500\>
find . -iname '*.jpg' -print0 | xargs -0 -n 1 -P 6 mogrify -format jpg -flatten -resize 1500\>

 

 

 

 

Exit mobile version