JPEGOPTIM – To compress JPEG images with out loosing the quality.
OPTIPNG – To optimize and compress the images without loosing the quality.
Install jpegoptim in Linux
To install jpegoptim on your Linux systems, run the following command from your terminal.
On Debian and it’s Derivatives
# apt-get install jpegoptim or $ sudo apt-get install jpegoptim
On RedHat based Systems
On RPM based distros you need to enable to EPEL repo which can be installed directly with commandline.
# yum install epel-release # dnf install epel-release [On Fedora 22+ version]
Next install jpegoptim program from the repository as shown:
# yum install jpegoptim # dnf install jpegoptim [On Fedora 22+ version]
How to Use Jpegoptim Image Optimizers
The syntax of jpegoptm is:
$ jpegoptim filename.jpeg $ jpegoptim [options] filename.jpeg
Let’s now compress the following codingsec.jpeg
images, but before optimizing the image, first find out the actual size of the image using du command as shown.
$ du -sh codingsec.jpeg 6.2M codingsec.jpeg
Here the actual file size is 6.2MB, now compress this file by running:
$ jpegoptim codingsec.jpeg
Our file is compressed down by 30%
If you want more
jpegoptim --size=250k codingsec.jpeg
Compress or Optimize PNG Images from Command Line Program
OptiPNG is a command line tool used for optimize and compress PNG (portable network graphics) file without losing its original quality.
The installation and usage of OptiPNG is very same as to jpegoptim.
Install OptiPNG in Linux
To install OptiPNG 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 # dnf install optipng [On Fedora 22+ versions]
Note: You must have epel repository on your RHEL/CentOS based systems to install optipng program.
How to Use OptiPNG Image Optimizer
The general syntax of optipng is:
$ optipng filename.png $ optipng [options] filename.png
Let us compress the codingsec.png
image, but before optimizing, first check the actual size of the image as shown:
harry@codingsec~/img $ ls -lh codingsec.png -rw------- 1 codingsec codingsec 350K Jan 19 12:54 codingsec.png
Here the actual file size of above image is 350K, now compress this file by running:
harry@codingsec~/img $ optipng codingsec.png OptiPNG 0.6.4: Advanced PNG optimizer. Copyright (C) 2001-2010 Cosmin Truta. ** Processing: tecmint.png 1493x914 pixels, 4x8 bits/pixel, RGB+alpha Reducing image to 3x8 bits/pixel, RGB Input IDAT size = 357525 bytes Input file size = 358098 bytes Trying: zc = 9 zm = 8 zs = 0 f = 0 IDAT size = 249211 Selecting parameters: zc = 9 zm = 8 zs = 0 f = 0 IDAT size = 249211 Output IDAT size = 249211 bytes (108314 bytes decrease) Output file size = 249268 bytes (108830 bytes = 30.39% decrease)
As you see in the above output, the size of the codingsec.png file has been reduced up to 30.39%. Now verify the file size again using:
harry@codingsec~/img $ ls -lh codingsec.png -rw-r--r-- 1 codingsec codingsec 244K Jan 19 12:56 codingsec.png
Open the image is compressed in any image viewer application, you will not find any major differences between the original and compressed files. The source and compressed images will have the same quality.
Take your time to comment on this article.
'Computer > Linux' 카테고리의 다른 글
[Ubuntu] Arduino IDE 설치 (0) | 2020.03.29 |
---|---|
[우분투] nvm 이용, node js + npm 설치 (0) | 2020.03.29 |
[Linux] nmcli d 명령어 (0) | 2019.12.02 |
리눅스에서 모델 확인하기 (0) | 2019.11.30 |
linux cheatsheet (0) | 2017.11.25 |