|
Question: I have many digital cameras take photographs. I think before uploading to Dropbox, optimization and compression JPEG image. Is there any simple way to compress JPEG picture is not the loss of their quality?
Today photographing devices (such as smart phones, digital cameras) to shoot out of the picture resolution is growing. Even 36.3 million pixel Nikon D800 has been into the market, and this trend simply can not stop. Today, camera equipment and constantly improve the picture resolution, so we had to compress, and then upload it to have a storage limit, bandwidth limit of the cloud.
In fact, there is a very simple method here compressed JPEG image. One called "jpegoptim" command-line tool that can help you "lossless" beautification JPEG images, so you can compress JPEG pictures and without sacrificing their quality. In case your storage space and bandwidth budget is really very little, jpegoptim also supports "lossy" compression to adjust the image size.
If you want to compress PNG images, this reference guide example.
Installation jpegoptim
Ubuntu, Debian or Linux Mint:
$ Sudo apt-get install jpegoptim
Fedora:
$ Sudo yum install jpegoptim
CentOS / RHEL installation, first open the EPEL repository, and then run the following command:
$ Sudo yum install jpegoptim
Lossless compression jpeg image
In order to losslessly compress a JPG image, use:
$ Jpegoptim photo.jpg
photo.jpg 2048x153624bit N ICC JFIF [OK] 882178 -> 821064 bytes (6.93%), optimized.
Note that the original image is compressed image after covering.
If jpegoptim not lossless beautify the image, it will not cover:
$ Jpegoptim -v photo.jpg
photo.jpg 2048x153624bit N ICC JFIF [OK] 821064 -> 821064 bytes (0.00%), skipped.
If you want to protect the original image, using the "-d" parameter indicates the save directory
$ Jpegoptim -d ./compressed photo.jpg
Thus, the compressed image will be saved in ./compressed directory (with the same input file name)
If you want to protect the file modification time to create, use "-p" parameter. Such compressed image will be the same as the original image date and time.
$ Jpegoptim -d ./compressed -p photo.jpg
If you just want to see lossless compression not really want to compress them, use the "-n" parameter to simulate the compression and then it will show the compression ratio.
$ Jpegoptim -n photo.jpg
Lossy compression JPG image
In case you really need to be saved in the cloud space, you can also use lossy JPG image.
In this case, use the "-m " option, mass range 0-100. (0 is the best quality, 100 is the worst quality)
For example, 50% of the quality of the compressed image:
$ Jpegoptim -m50 photo.jpg
photo.jpg 2048x153624bit N ICC JFIF [OK] 882178 -> 301780 bytes (65.79%), optimized.
At the expense of the quality, you will get a smaller picture.
JPEG image compression more than once
The most common scenario is the need to compress multiple JPEG image files in a directory. To cope with this situation, you can use the following script.
#! / Bin / sh
# Compress all * .jpg files in the current directory
# Save ./compressed directory
# And the original file has the same modification date
for i in * .jpg; do jpegoptim -d ./compressed -p "$ i"; done |
|
|
|