Click here to Skip to main content
15,877,573 members
Articles / Operating Systems / Linux
Technical Blog

Shell script for converting progressive JPEGs to baseline

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
10 Aug 2012CPOL 14.7K   3
Identify all progressive JPEGs in a directory tree and batch convert them to baseline.

The following Linux shell script will identify all progressive JPEGs, in the directory tree under the directory it resides in, and batch convert them to baseline.

It requires ImageMagick to be installed (on Fedora install it like this: yum install ImageMagick)

for img in `find . -name "*" | egrep *\.jpe?g$`
  idout=`identify -verbose $img | grep -i interlace | grep -i none$`

  if [[ -z $idout ]]
    echo "-------------------------"
    echo "$img is progressive"
    echo "....making copy of original with .prog extension"
    /bin/cp -f $img $img.prog
    echo "....converting to baseline"
    convert $img -interlace none $img 
    echo "....done!"
    #echo "$img is non-progressive"
This article was originally posted at


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer
South Africa South Africa
I have a keen interest in IT Security, Internet applications, and systems/embedded development. My recent research interests have included secure networks, models of trust, trusted agents, information exchange, and software development methodologies.

Comments and Discussions

Questionfolder names with spaces Pin
Member 1395909723-Aug-18 3:12
Member 1395909723-Aug-18 3:12 
QuestionThis is great, but fails on whitespaces in filenames. Pin
Member 116733647-May-15 11:44
Member 116733647-May-15 11:44 
I realize this is a very old post, and you may well have moved on from paying attention to it, but would it be possible to modify this script to handle whitespaces in filenames?

Thank you very much!
SuggestionA Tip... Pin
Sandeep Mewara9-Aug-12 18:18
mveSandeep Mewara9-Aug-12 18:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.