How to compress and optimize JPG and PNG images under Linux

Source: Internet
Author: User

Jpegotim compression jpg picture
Install Jpegotim
If you have a epel yum source, use the following command

The code is as follows:
# yum Install Jpegoptim

Compress picture Commands

The code is as follows:
# Jpegoptim Ttlsa.jpg

Ttlsa.jpg 1425x823 24bit N JFIF [OK] 1074449--> 853514 bytes (20.56%), optimized.
You can see that the ttlsa.jpg is automatically compressed by 20.56%.
Compress once more

The code is as follows:
# Jpegoptim Ttlsa.jpg

Ttlsa.jpg 1425x823 24bit N JFIF [OK] 853514--> 853514 bytes (0.00%), skipped.
The picture has been compressed, so the prompt skips and does not need to be compressed.
Provides a script for bulk compression

The code is as follows:
For I in/data/site/image.ttlsa.com/images/*.jpg; Do Jpegoptim $i; Done

Pngcrush to optimize PNG pictures
Project Address: http://pmt.sourceforge.net/pngcrush/

The code is as follows:
# wget http://downloads.sourceforge.net/project/pmt/pngcrush/1.7.88/pngcrush-1.7.88.tar.gz
# TAR-XZVF Pngcrush-1.7.88.tar.gz
# CD pngcrush-1.7.88
# make
# CP Pngcrush/usr/bin

Pngcrush using syntax

The code is as follows:
Usage:pngcrush [Options except FOR-E-d] infile.png outfile.png
PNGCRUSH-E ext [Other options] file.png ...
Pngcrush-d dir/[Other options] file.png ...
Pngcrush-ow [Other options] file.png [Tempfile.png]
Pngcrush-n-V file.png ...
Options
-bail (bail out of trial when size exceeds best size found
-bit_depth Depth (deprecated)
-blacken (zero samples underlying fully-transparent pixels)
-brute (use Brute-force:try 148 different methods)
........ More content please see Help yourself ...

Pngcrush Simple Command

The code is as follows:
Pngcrush-brute-e "Myimage_compressed.png" myimage.png
......... Omitted.....
Best Pngcrush method = 123 (WS FM 4 ZL 9 ZS 1) = 124820
For output to Ttlsattlsa_new.png
(1.63% critical chunk reduction)
(1.63% filesize reduction)
CPU time decoding 1.560, encoding 7.640, other 0.030, total 9.230 sec.

Bulk optimize PNG pictures

The code is as follows:

Pngcrush-brute-d "/data/site/image.ttlsa.com/images" *.png

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.