In this era of self-timer, the photos are very inconvenient to process, sometimes need to be compressed, but the JPEG image may be distorted after compression, the following small series will give Everyone introduces the way Linux compresses JPEG images through the command line, which satisfies the needs of users who need to compress JPEG images.
In fact, there is a very simple way to compress JPEG images. A command line tool called "jpegoptim" can help you "lossless" landscaping of JPEG images so that you can compress JPEG images without sacrificing their quality. In case your storage space and bandwidth budget are really small, jpegoptim also supports "damage" compression to adjust image size.
Install jpegoptim
Ubuntu, Debian or Linux Mint:
$ sudo apt-get install jpegoptim
Fedora:
$ sudo Yum install jpegoptim
CentOS/RHEL installation, first open the EPEL library, then run the following command:
$ sudo yum install jpegoptim
lossless compression jpeg image
To compress a JPG image without loss, use:
$ jpegoptim photo.jpg
photo.jpg 2048x1536 24bit N ICC JFIF [OK] 882178 --" 821064 bytes (6.93%) , optimized.
Note that the original image will be overwritten by the compressed image.
If jpegoptim can't beautify the image, it won't overwrite it:
$ jpegoptim -v photo.jpg
photo.jpg 2048x1536 24bit N ICC JFIF [OK] 821064 --" 821064 bytes (0.00%), skipped.
If you want to protect the original image, use the “-d” parameter to specify the save directory
$ jpegoptim -d . /compressed photo.jpg
This way, the compressed image will be saved. /compressed directory (with the same input file name)
If you want to protect the creation time of the file, use the “-p” parameter. This compressed image will get the same date and time as the original image.
$ jpegoptim -d . /compressed -p photo.jpg
If you just want to see the lossless compression ratio instead of really wanting to compress them, use the “-n” parameter to simulate compression, and then it will show the compression ratio.
$ jpegoptim -n photo.jpg
Lossy Compressed JPG Image
In case you really need to save it in the cloud space, you can also use lossy compression. JPG picture.
In this case, use the “-m "Quality" & rdquo; option, the mass range is 0 to 100. (0 is the best quality, 100 is the worst quality)
For example, compress the picture with 50% quality:
$ jpegoptim -m50 photo.jpg
photo.jpg 2048x1536 24bit N ICC JFIF [OK] 882178 --" 301780 bytes (65.79%),
optimized.
On the basis of sacrificing quality, you will get a smaller picture.
more than once compressed JPEG images
The most common situation is the need to compress a directory of multiple JPEG image files. To cope with this situation, you can use the next script.
#! /bin/sh
# Compress all *.jpg files in the current directory
# Save in. /compressed directory
# and has the same modification date as the original file
for i in *.jpg; do jpegoptim -d . /compressed -p “$i”; done
The above is a way to compress JPEG images through the command line. Lossless compression can guarantee the quality of the image, but the compression package is large, lossy compression The image can be compressed to a smaller size and selected according to user needs.
As long as people who understand the program know the assert, write it in VC under Windows. After us
The Apache server is the most widely used web server software, so Linux users need
In Linux, users sometimes encounter garbled characters after SecureCRT connects to
Management of Linux system squadron user accounts refers to adding, modifying, and
How Linux uses commands in sysstat
Instructions for using the Linux system xlsatom command
What if Ubuntu can't start Eclipse?
Linux system how to set up security management
Linux method of establishing dmg file through command line
Linux configuration yum.conf method
Linux software lacks dynamic link library. So what to do?
What if CentOS can't use the scp command?
Linux function library creation method
Backtrack how to open SSH service
Let Windows 7 system boot, shut down more quickly
How Linux prohibits specific ip address access
What to do with Win8? Three steps to build a personal computer
Learn seven points of advice using Linux systems
Win10 preview version 9879 update step
Win10 landing Xbox One time later than PC cross-platform game into the biggest highlight