I'm searching best tool to compress images (png and jpeg) via command line.
After googling I found trimage which is good as it compresses both png and jepeg, but compression ratio is very poor in this case.
I came across jpeg-optimizer.com online tool which does the job way better than trimage. Can any one help to find the right tool for this.
To compress batch or multiple PNG images at once, just go the directory where all images resides and run the following command to compress. tecmint@tecmint ~ $ cd img/ tecmint@tecmint ~/img $ optipng *. png OptiPNG 0.6. 4: Advanced PNG optimizer.
Choose an image to compress, and click the Open option. Select RIOT's JPEG tab. Drag the Quality bar's slider left or right to increase or decrease the compression.
I'm using the following tools to perform lossless image compression:
pngcrush
gifsicle
jpegtran
For each of the programs, I've created two shortcuts:
I've 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
is very verbose. Redirect the output to /dev/null
if you're not interested in the progress.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With