April 25, 2009

Compressing PICS in Linux using command line !!!

I have stored some pictures in /tmp/images/pundir.Following example shows how I brought a 32 MB album to 7.6 MB.

root@station3:/tmp/images/pundir# ls -lh
total 32M
-rwx------ 1 root root 1.4M 2009-01-18 00:38 DSC00949.JPG
-rwx------ 1 root root 1.5M 2009-01-18 00:38 DSC00950.JPG
-rwx------ 1 root root 1.4M 2009-01-18 00:38 DSC00951.JPG
-rwx------ 1 root root 1.4M 2009-01-18 00:38 DSC00952.JPG
-rwx------ 1 root root 1.4M 2009-01-18 00:38 DSC00953.JPG
-rwx------ 1 root root 1.4M 2009-01-18 00:38 DSC00954.JPG
-rwx------ 1 root root 1.3M 2009-01-18 00:38 DSC00955.JPG
-rwx------ 1 root root 1.4M 2009-01-18 00:38 DSC00956.JPG
-rwx------ 1 root root 1.3M 2009-01-18 00:38 DSC00957.JPG
-rwx------ 1 root root 1.4M 2009-01-18 00:38 DSC00958.JPG
-rwx------ 1 root root 1.4M 2009-01-18 00:38 DSC00959.JPG
-rwx------ 1 root root 1.5M 2009-01-18 00:38 DSC00960.JPG
-rwx------ 1 root root 1.4M 2009-01-18 00:38 DSC00961.JPG
-rwx------ 1 root root 1.2M 2009-01-18 00:38 DSC00962.JPG
-rwx------ 1 root root 1.2M 2009-01-18 00:38 DSC00963.JPG
-rwx------ 1 root root 1.2M 2009-01-18 00:38 DSC00964.JPG
-rwx------ 1 root root 1.4M 2009-01-18 00:38 DSC00965.JPG
-rwx------ 1 root root 1.4M 2009-01-18 00:38 DSC00966.JPG
-rwx------ 1 root root 1.3M 2009-01-18 00:38 DSC00967.JPG
-rwx------ 1 root root 1.3M 2009-01-18 00:38 DSC00968.JPG
-rwx------ 1 root root 1.3M 2009-01-18 00:38 DSC00969.JPG
-rwx------ 1 root root 1.3M 2009-01-18 00:38 DSC00970.JPG
-rwx------ 1 root root 1.3M 2009-01-18 00:38 DSC00971.JPG
-rw-r--r-- 1 root root 1.1M 2009-01-18 00:38 DSCN3857.JPG

root@station3:/tmp/images/
pundir# mogrify -verbose *JPG -quality 60 *JPG

root@station3:/tmp/images/
pundir# ls -lh
total 7.8M
-rwx------ 1 root root 435K 2009-01-18 00:40 DSC00949.JPG
-rwx------ 1 root root 363K 2009-01-18 00:40 DSC00950.JPG
-rwx------ 1 root root 269K 2009-01-18 00:40 DSC00951.JPG
-rwx------ 1 root root 253K 2009-01-18 00:40 DSC00952.JPG
-rwx------ 1 root root 331K 2009-01-18 00:40 DSC00953.JPG
-rwx------ 1 root root 334K 2009-01-18 00:40 DSC00954.JPG
-rwx------ 1 root root 285K 2009-01-18 00:40 DSC00955.JPG
-rwx------ 1 root root 349K 2009-01-18 00:40 DSC00956.JPG
-rwx------ 1 root root 314K 2009-01-18 00:40 DSC00957.JPG
-rwx------ 1 root root 380K 2009-01-18 00:40 DSC00958.JPG
-rwx------ 1 root root 312K 2009-01-18 00:40 DSC00959.JPG
-rwx------ 1 root root 305K 2009-01-18 00:40 DSC00960.JPG
-rwx------ 1 root root 258K 2009-01-18 00:40 DSC00961.JPG
-rwx------ 1 root root 204K 2009-01-18 00:40 DSC00962.JPG
-rwx------ 1 root root 274K 2009-01-18 00:40 DSC00963.JPG
-rwx------ 1 root root 270K 2009-01-18 00:40 DSC00964.JPG
-rwx------ 1 root root 286K 2009-01-18 00:40 DSC00965.JPG
-rwx------ 1 root root 259K 2009-01-18 00:40 DSC00966.JPG
-rwx------ 1 root root 305K 2009-01-18 00:40 DSC00967.JPG
-rwx------ 1 root root 313K 2009-01-18 00:40 DSC00968.JPG
-rwx------ 1 root root 307K 2009-01-18 00:40 DSC00969.JPG
-rwx------ 1 root root 312K 2009-01-18 00:40 DSC00970.JPG
-rwx------ 1 root root 252K 2009-01-18 00:40 DSC00971.JPG
-rw-r--r-- 1 root root 874K 2009-01-18 00:40 DSCN3857.JPG
root@station3:/tmp/images/
pundir#

Alternatively we can also use:
root@station3:/tmp/images/pundir#
mogrify -verbose -resize 800x600 *JPG

Now it's time to further compress the album.
root@station3:/tmp/images/
pundir# cd .. ; tar -czvf pundir.gz pundir
pundir/
pundir/DSC00954.JPG
pundir/DSC00961.JPG
pundir/DSC00953.JPG
pundir/DSC00956.JPG
pundir/DSC00949.JPG
pundir/DSC00958.JPG
pundir/DSC00965.JPG
pundir/DSC00962.JPG
pundir/DSC00969.JPG
pundir/DSC00963.JPG
pundir/DSC00967.JPG
pundir/DSC00951.JPG
pundir/DSC00952.JPG
pundir/DSC00970.JPG
pundir/DSC00964.JPG
pundir/DSC00968.JPG
pundir/DSC00971.JPG
pundir/DSC00950.JPG
pundir/DSC00955.JPG
pundir/DSC00966.JPG
pundir/DSC00960.JPG
pundir/DSC00957.JPG
pundir/DSCN3857.JPG
pundir/DSC00959.JPG

root@station3:/tmp/pundir# ls -lh
total
7.6M
drwxr-xr-x 2 root root 4.0K 2009-01-18 00:24 pundir
-rw-r--r-- 1 root root
7.6M 2009-01-18 00:45 pundir.tar.gz
root@station3:/tmp/pundir#

Alternatively you can also convert all the pics into pdf as shown below:
root@station3:/tmp/pundir#
convert -verbose *JPG all_in_one.pdf

No comments:

Post a Comment