Installing and Using the Utilities to Optimize Images on the Servers for Shared Hosting: jpegoptim and optipng

Images are one of those most important parameters which influence the website’s loading times. Nowadays, images take up the bigger part of the overall ‘weight’ of the website. 

jpegoptim and optipng are some of the best console image optimization utilities. Let’s look at their installation for the account on the server with shared hosting. 

JPEGOPTIM:

  1. First, you need to connect to the server via SSH.
  2. Next, we create a folder for binary files of utilities: 

[email protected] [~]# mkdir work_bin

3. Then move to the directory and download the source files of the utility:

[email protected] [~]# cd work_bin/

[email protected] [~/work_bin]# wget https://github.com/tjko/jpegoptim/archive/master.zip

4. Unpack the given archive:

[email protected] [~/work_bin]# unzip master.zip

5. We build the utility by changing the standard installation path of the binary file to the directory created earlier:

[email protected] [~/work_bin/jpegoptim-master]# ./configure --prefix=/home/user/work_bin

[email protected] [~/work_bin/jpegoptim-master]# make

[email protected] [~/work_bin/jpegoptim-master]# make install

6. To make it convenient to use, we add alias

[email protected] [~/work_bin/jpegoptim-master]# vim ~/.bashrc

alias jpegoptim='/home/user/work_bin/bin/jpegoptim'

7. Reconnect via SSH and check:

[email protected] [~]# jpegoptim -V

jpegoptim v1.4.4 x86_64-unknown-linux-gnu

Copyright (c) 1996-2016, Timo Kokkonen

libjpeg version: 6b 27-Mar-1998

Copyright (C) 1991-2010 Thomas G. Lane, Guido Vollbeding

Copyright (C) 1999-2006 MIYASAKA Masaru

Copyright (C) 2009 Pierre Ossman for Cendio AB

Copyright (C) 2009-2012 D. R. Commander

Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)

8. Check how the utility works:

[email protected] [~]# jpegoptim public_html/screenshots/*.jpg

public_html/screenshots/free_2013_full_js_2-1-big.jpg 662x662 24bit P Exif IPTC XMP Adobe JFIF [OK] 451545 --> 443608 bytes (1.76%), optimized.

public_html/screenshots/free_2013_full_js_2-1-origin-1200.jpg 1200x1200 24bit P Exif IPTC XMP Adobe JFIF [OK] 1034086 --> 1000150 bytes (3.28%), optimized.

public_html/screenshots/free_2013_full_js_2-1-original-1200.jpg 1200x1200 24bit P Exif IPTC XMP Adobe JFIF [OK] 1003198 --> 970113 bytes (3.30%), optimized.

public_html/screenshots/free_2013_full_js_2-1-original.jpg 1200x1200 24bit P Exif IPTC XMP Adobe JFIF [OK] 1003198 --> 970113 bytes (3.30%), optimized.

public_html/screenshots/free_2013_full_js_2-1-origin.jpg 1200x1200 24bit P Exif IPTC XMP Adobe JFIF [OK] 1034076 --> 1000140 bytes (3.28%), optimized.

OPTIPNG:

  1. Download the source files of the utility:

[email protected] [~/work_bin]# wget http://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.7/optipng-0.7.7.tar.gz

  1. Unpack the archive:

[email protected] [~/work_bin]# tar -xzf optipng-0.7.7.tar.gz

Go to the directory:

[email protected] [~/work_bin]# cd optipng-0.7.7/

  1. Start building the utility:

[email protected] [~/work_bin/optipng-0.7.7]# ./configure --prefix=/home/user/work_bin

[email protected] [~/work_bin/optipng-0.7.7]# make

[email protected] [~/work_bin/optipng-0.7.7]# make install

  1. Check:

[email protected] [~/work_bin/optipng-0.7.7]# /home/user/work_bin/bin/optipng -V

OptiPNG version 0.7.7

Copyright (C) 2001-2017 Cosmin Truta and the Contributing Authors.

This program is open-source software. See LICENSE for more details.

Portions of this software are based in part on the work of:

Jean-loup Gailly and Mark Adler (zlib)

Glenn Randers-Pehrson and the PNG Development Group (libpng)

Miyasaka Masaru (BMP support) David Koblas (GIF support)

Using libpng version 1.6.34 and zlib version 1.2.11-optipng

  1. To make it convenient, add alias:

[email protected] [~/work_bin/optipng-0.7.7]# vim ~/.bashrc

alias optipng='/home/user/work_bin/bin/optipng'

  1. Reconnect via SSH and check:

[email protected] [~/work_bin/optipng-0.7.7]# optipng -V

OptiPNG version 0.7.7

Copyright (C) 2001-2017 Cosmin Truta and the Contributing Authors.

This program is open-source software. See LICENSE for more details.

Portions of this software are based in part on the work of:

Jean-loup Gailly and Mark Adler (zlib)

Glenn Randers-Pehrson and the PNG Development Group (libpng)

Miyasaka Masaru (BMP support)

David Koblas (GIF support)

Using libpng version 1.6.34 and zlib version 1.2.11-optipng

  1. Check how the utility works:

[email protected] [~]# optipng -o7 public_html/screenshots/5eeda46fbc1e4348a00915c00ebe7bb7.png
** Processing: public_html/screenshots/5eeda46fbc1e4348a00915c00ebe7bb7.png
1920x1080 pixels, 3x8 bits/pixel, RGB
Input IDAT size = 376200 bytes
Input file size = 376812 bytes
Trying:
zc = 9 zm = 9 zs = 0 f = 0 IDAT size = 330921
zc = 9 zm = 8 zs = 0 f = 0 IDAT size = 329760
Selecting parameters:
zc = 9 zm = 8 zs = 0 f = 0 IDAT size = 329760
Output IDAT size = 329760 bytes (46440 bytes decrease)
Output file size = 329832 bytes (46980 bytes = 12.47% decrease)

Mind that the -o7 key uses the highest level of optimization: it can take a lot of time and can create a big load on the CRU servers of your account when processing a big amount of images. 

Was this answer helpful? 5 Users Found This Useful (16 Votes)