Click here to Skip to main content
15,065,044 members
Articles / Operating Systems / Linux
Technical Blog
Posted 10 Aug 2012

Tagged as

Stats

12.7K views

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
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$`
do
  idout=`identify -verbose $img | grep -i interlace | grep -i none$`

  if [[ -z $idout ]]
  then
    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!"
  #else
    #echo "$img is non-progressive"
  fi
done
This article was originally posted at http://fotios.org/node/2668

License

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

Share

About the Author

Alex Fotios
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
MemberMember 1395909723-Aug-18 3:12 
QuestionThis is great, but fails on whitespaces in filenames. Pin
Member 116733647-May-15 11:44
MemberMember 116733647-May-15 11:44 
SuggestionA Tip... Pin
Sandeep Mewara9-Aug-12 18:18
mvaSandeep 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.