How to Optimize and Compress JPEG or PNG Images in Linux Commandline

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux course in 5 Days

We are thankful for your never ending support.

Senthil Kumar

A Linux Consultant, living in India. He loves very much to write about Linux, Open Source, Computers and Internet. Apart from that, He'd like to review Internet tools and web services.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Introduction to Linux - A Hands on Guide

You may also like...

8 Responses

  1. Giorgos says:

    Hi! :-)
    Take also a look, at Trimage.

    • Ravi Saive says:


      Thanks for the tip about Trimage tool, but we’re getting 404 error while accessing the page, seems no more development and also I found that the last update was 5 years ago on Github

  2. Yavor says:

    I use ‘convert’
    With a small script take all the files from ./orig and create thumbnails in ./pics and a larger picture in ./pics-big
    it also creates the entries for the html file
    it reduces the image to 28% and 64% of their original dimensions – but that is how my camera is set up

    cd orig;
    for file in *; do convert -strip -scale 64%x64% -quality 75 $file “../pics-big/”$file;
    convert -strip -scale 28%x28% -quality 75 $file “../pics/”$file;
    echo ” ” >> ../html.txt;

    • Ravi Saive says:


      Thanks a ton for sharing the script with us, I was looking for such script since long time for my camera images, which are huge in size..let me try and get back to you..

  3. Jalal Hajigholamali says:

    Thanks a lot…
    very useful article….

  4. nicu says:

    with OptiPNG i was familiar with, so after reading your article, I gave a try to jpegoptim: it was useless for my final JPEGs, which are produced with GIMP, and are destined to web use – 0.00% improvement. on a batch of JPEGs taken straight from the camera, for the batch I tested, the average space savings was 2.36%
    my conclusion: it would be useless for a webmaster trying to minimize bandwidth use, it wasn’t able to do a thing.

    • Ravi Saive says:


      I totally agree with your point that jpegoptim not a best tool for JPEG or JPG compression, it just reduce the size around 5-10% that’s totally useless to use, whereas OptinPNG works great it optimize images nearly 30-40% but still I can say it’s not a good choice to use for websites, where speed is more important. Even I tried different online jpeg or png compression tools, still not a good results specially for jpeg images…

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

Join Over 150K+ Linux Users
  1. 100,756
  2. 5,113
  3. 36,418

Enter your email to get latest Linux Howto's