How VPS - How to use/setup VPS
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

Compressing Images On The Linux Command Line

How VPS by How VPS
January 1, 2020
in Linux
0
0
SHARES
247
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Installing jpegoptim and OptiPNG
  2. Using jpegoptim to compress JPEG files
  3. Using OptiPNG to optimize PNG, BMP, GIF, PNM, and TIFF files
  4. Want to contribute?


If you have a lot of high-resolution images stored on your Linux computer, you may be running out of storage due to the large amount of disk space used by your photo library. In this case, you may be looking for a solution that allows you to compress these images to conserve disk space without affecting their quality.

Further, traditional compression solutions often allow compressing image files one-by-one, which can be a rather cumbersome and time-consuming process. Therefore, compressing your images in batches may be a great idea to save time and effort.

That’s where jpegoptim and OptiPNG come in handy. Both jpegoptim and OptiPNG are command line-based utilities that can be used to optimize and compress pictures in batches without affecting their original quality (also known as lossless compression). Jpegoptim handles JPEG files while OptiPNG processes pictures in the format of PNG, BMP, GIF, PNM, and TIFF.

Let’s go over the process of installing jpegoptim and OptiPNG to compress pictures in Linux using the command line.

Note: This tutorial assumes you are using a non-root user with sudo privileges.

Installing jpegoptim and OptiPNG

On CentOS or other RPM-based Linux distributions:

sudo yum install epel-release
sudo yum install jpegoptim optipng

On Debian or other APT-based Linux distributions:

sudo apt-get install jpegoptim optipng

Using jpegoptim to compress JPEG files

In this example, your original JPEG (.jpg) files are stored ~/jpeg.

a) If you want to compress a single file, let’s say example.jpg you would be using the below command:

cd ~/jpeg
jpegoptim example.jpg

Notice: The original example.jpg will be replaced with a compressed version by default.

b) If you want to compress all .jpg files in the source directory:

cd ~/jpeg
jpegoptim *.jpg

All the original files will be overwritten and replaced with the compressed version.

c) If you wish to keep the original files, you can specify a target directory to store the compressed version to as follows:

cd ~/jpeg
mkdir optim
jpegoptim *.jpg -d ~/jpeg/optim

d) For more information on how to use the jpegoptim command, you can use the -h flag to view its help file:

jpegoptim -h

Using OptiPNG to optimize PNG, BMP, GIF, PNM, and TIFF files

Just like jpegoptim, OptiPNG will overwrite the original files and replace then with the compressed version in the source directory by default. Meanwhile, for BMP, GIF, PNM, and TIFF files, OptiPNG will generate optimized .png version of the file with the same name, leaving the original files in tact. These file would have to be manually removed one the compression process is compelted.

Below are a few examples on how to use OptiPNG to apply lossless compression to your images:

In this example, your original JPEG (.jpg) files are stored ~/pic.

a) If you want to compress a single file, let’s say example.png you would be using the below command:

cd ~/pic
optipng example.png

Notice: The original example.png file will be replaced with a optimized version.

b) Optimize a .bmp file example.bmp:

cd ~/pic
optipng example.bmp

A file named example.png will be created in the source directory while the original example.bmp stays in tact.

c) If you want to compress all .png files in the source directory:

cd ~/pic
optipng *.png

All the original files will be overwritten and replaced with the compressed version.

d) If you prefer to keep the original files in tact, you can do so by using the -keep flag as follows:

cd ~/pic
optipng -keep *.png

The original files will remain in tact and suffixed with a .bak. For example example.png.bak.

e) If you wish to keep the original files, you can specify a target directory to store the compressed version to as follows:

cd ~/pic
optipng -dir ~/pic/optim *.png

All the original files will remain in tact in the source directory while the compressed version will be saved in target directory.

f) For more information on how to use the OptiPNG command, you can use the -h flag to view its help file:

optipng -h

This concludes our tutorial.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
How VPS

How VPS

Related Posts

How to Install Apache Tomcat 8 on CentOS 7
Linux

How to Install Apache Tomcat 8 on CentOS 7?

February 11, 2020
Linux

Setup IonCube Loader on Ubuntu 14

January 1, 2020
Linux

Converting from MySQL to MariaDB on Ubuntu

January 1, 2020
Next Post

Install Nginx + PHP FPM + Caching + MySQL on Ubuntu 12.04

How to Install and Secure phpMyAdmin on Ubuntu 14.04 and 16.04

Install BitTorrent Sync on Ubuntu 14.04

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

Installing Naxsi On Ubuntu 14.04

3 years ago

Host1Plus Review

4 years ago

Setup Grav CMS On Ubuntu 14

3 years ago

Clustering RabbitMQ on CentOS 7

3 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8 February 25, 2022
  • How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.