How to install jpegoptim and optipng in Linux
jpegoptim and optipng in Linux
In this article we will discuss about how to install the jpegoptim which is a utility tool to optimize/compress JPEG files without loosing its original quality and OptiPNG is a small program which helps to optimize PNG images to smaller size without losing information.
To Install jpegoptim
On Debian and its Derivatives
apt-get install jpegoptim
or
sudo apt-get install jpegoptim
On RedHat based Systems
You need to install and enable EPEL repository On RPM based systems like RHEL, CentOS, Fedora etc.,
yum install epel-release
On Fedora 22+ versions
dnf install epel-release
Next install jpegoptim program from the repository
yum install jpegoptim
On Fedora 22+ versions
dnf install jpegoptim
Installation
[root@linuxhelp ~]# yum install jpegoptim
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
&hellip
&hellip
&hellip
===========================================================================
Package Arch Version Repository Size
===========================================================================
Installing:
jpegoptim x86_64 1.4.3-1.el6 epel 27 k
Transaction Summary
===========================================================================
Install 1 Package(s)
Total download size: 27 k
Installed size: 53 k
Is this ok [y/N]: y
...
...
...
...
Installed:
jpegoptim.x86_64 0:1.4.3-1.el6
Complete
Now the Installation is completed.
Syntax of jpegoptim
jpegoptim [options] filename.jpeg
Now Let’ s Compress the language.jpg image using jpegoptim command and before that we can find out the actual size of the image using du command.
Example
[root@linuxhelp Desktop]# du -sh language.jpg 12K language.jpg [root@linuxhelp Desktop]# jpegoptim language.jpg language.jpg 18x21 24bit N Exif IPTC XMP Adobe JFIF [ok] 8490 --> 8068 bytes (4.9%), optimized [root@linuxhelp Desktop]# du -sh language.jpg 8.0k language.jpg
You can compress the given image to a specific size to, but it won’ t damage the actual picture density.
[root@linuxhelp Desktop]# du -sh image.jpg 684k image.jpg [root@linuxhelp Desktop]# jpegoptim --size=200k image.jpg image.jpg 2082x2975 24bit N Adobe JFIF [ok] 69661 --> 205079 bytes (70.56%), optimized [root@linuxhelp Desktop]# du -sh image.jpg 204k image.jpg
jpegoptim is also Possible to compress multiple png images.
To install Opti PNG
To install Opti PNG on your Linux systems, run the following command from your terminal.
On Debian and it' s Derivatives
apt-get install optipng
or
sudo apt-get install optipng
On RedHat based Systems
# yum install optipng
On Fedora 22+ versions
# dnf install optipng
You must have epel repository enabled on your RHEL/CentOS based systems to install opti png program.
Installation
[root@linuxhelp Desktop]# yum install optipng
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* epel: mirror.wanxp.id
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
Setting up Install Process
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
--> Running transaction check
---> Package opti png.x86_64 0:0.6.4-1.el6 will be installed
--> Finished Dependency Resolution
...
...
...
...
Installed:
opti png.x86_64 0:0.6.4-1.el6
Complete!
OptiPNG Image Optimizer
Syntax
optipng filename.png
optipng [options] filename.png
Now Let’ s Compress the image1.png image using optipng command and before that we can find out the actual size of the image using du command.
Example
[user1@linuxhelp Desktop]$ du -sh image1.png 280k image1.png [user1@linuxhelp Desktop]$ optipng image1.png Opti PNG 0.6.4: Advanced PNG optimizer. Copyright (C) 2001-2010 Cosmin Truta. ** Processing: image1.png 519x600 pixels, 3x8 bits/pixel, RGB Input IDAT size = 284820 bytes Input file size = 284973 bytes Trying: zc = 9 zm = 8 zs = 0 f = 0 IDAT size = 284202 zc = 9 zm = 8 zs = 0 f = 5 IDAT size = 183140 Selecting parameters: zc = 9 zm = 8 zs = 0 f = 5 IDAT size = 183140 Output IDAT size = 183140 bytes (101680 bytes decrease) Output file size = 183197 bytes (101776 bytes = 35.71% decrease) [user1@linuxhelp Desktop]$ du -sh image1.png 180k image1.png
optipng is also Possible to compress multiple png images.
#yum install jpegoptim
optipng filename.png
optipng [options] filename.png