Command line image compression tools

I am looking for the best tool to compress images (png and jpeg) through the command line.
After googling, I found a trimage that is good, as it compresses both png and jepeg, but the compression ratio in this case is very poor.

I came across an online tool jpeg-optimizer.com that does a better job than a trim. Can anyone help finding the right tool for this.

+44
optimization image-processing image-compression
03 Oct '13 at 7:20
source share
3 answers

I use the following lossless compression tools:

For each of the programs I created two shortcuts:

  • The one that performs the actual compression and shows the file size of both files.
  • The one that replaces the original file with a compressed one (if I'm satisfied, I will make an up arrow, prefix my previous command with "m" and press enter).

I put this in my .bashrc :

 # Image optimization tools png() { pngcrush -brute "$1"{,.} && du -b "$1"{,.} } gif() { gifsicle -O "$1" -o "$1." && du -b "$1"{,.} } jpeg() { jpegtran "$1" > "$1." && du -b "$1"{,.} } # Just for easy access in history mpng() { mv "$1"{.,} } mgif() { newsize=$(wc -c <"$1.") oldsize=$(wc -c <"$1") if [ $oldsize -gt $newsize ] ; then mv "$1"{.,} else rm "$1." fi } mjpeg() { mv "$1"{.,} } 

Note: pngcrush -brute very verbose. Transfer the output to /dev/null if you are not interested in progress.

+32
Oct 11 '13 at 21:20
source share
+26
Oct 24 '13 at 18:08
source share

If you are running Linux, try the mogrify imagemagick suite tool

This is very convenient on the command line.

Example:

mogrify -resize 50% rose.jpg

 mogrify -format jpg *.png 
+9
Jul 21 '14 at 11:19
source share



All Articles