JPG file format is recommended for high resolution photographic-style images. You need to use jpegoptim command. It is used to optimize/compress jpeg files. Program supports lossless optimization, which is based on optimizing the Huffman tables. And so called “lossy” optimization where in addition to optimizing Huffman tables user can specify upperlimit for image quality.
Type the following command:
$ apt-get install jpegoptim
[sudo] password for vivek: Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libavutil-extra-51 libggiwmh0-target-x libggi2 libgii1 libvo-aacenc0 libgii1-target-x mplayer-skin-blue libggiwmh0 libggi-target-x libvo-amrwbenc0 Use 'apt-get autoremove' to remove them. The following NEW packages will be installed: jpegoptim 0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded. Need to get 14.0 kB of archives. After this operation, 77.8 kB of additional disk space will be used. Get:1 http://mirror.anl.gov/debian/ squeeze/main jpegoptim amd64 1.2.3-2+b1 [14.0 kB] Fetched 14.0 kB in 1s (11.2 kB/s) Selecting previously deselected package jpegoptim. (Reading database ... 333683 files and directories currently installed.) Unpacking jpegoptim (from .../jpegoptim_1.2.3-2+b1_amd64.deb) ... Processing triggers for man-db ... Setting up jpegoptim (1.2.3-2+b1) ...
The syntax is:
jpegoptim file.jpeg jpegoptim [options] file.jpeg
Type the following command to optimize photo.jpeg, enter:
$ jpegoptim photo.jpeg
photo.jpeg 1312x948 24bit JFIF [OK] 25226 --> 10744 bytes (57.41%), optimized.
How do I process files in batch?
for i in one.jpeg two.jpeg foo.jpeg; do jpegoptim "$i"; done
## process all *.jpeg in the current directory for i in *.jpeg; do jpegoptim "$i"; done
From the man page:
, --dest= Sets alternative destination directory where to save optimized files (default is to overwrite the originals). Please note that unchanged files won't be added to the destination directory. This means if the source file can't be compressed, no file will be created in the destinaâ€ tion path. -f, --force Force optimization, even if the result would be larger than the original file. -h, --help Displays short usage information and exits. -m[0..100], --max=[0..100] Sets the maximum image quality factor (disables lossless optimization mode, which is by default enabled). This option will reduce quality of those source files that were saved using higher quality setting. While files that already have lower quality setting will be compressed using the lossless optimization method. -n, --noaction Don't really optimize files, just print results. -o, --overwrite Overwrite target file even if it exists (when using -d option). -p, --preserve Preserve file modification times. -q, --quiet Quiet mode. -t, --totals Print totals after processing all files. -v, --verbose Enables verbose mode (positively chatty). --strip-all Strip all (Comment & Exif) markers from output file. (NOTE! by default only Comment & Exif markers are kept, everything else is discarded) --strip-com Strip Comment (COM) markers from output file. --strip-exif Strip EXIF markers from output file. --strip-iptc Strip IPTC markers from output file. --strip-icc Strip ICC profiles from output file.