Click here to Skip to main content
13,150,385 members (30,141 online)
Click here to Skip to main content
Add your own
alternative version


Posted 10 Aug 2012

Shell script for converting progressive JPEGs to baseline

, 10 Aug 2012
Rate this:
Please Sign up or sign in to vote.
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Alex Fotios
Software Developer Upwork
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.


You may also be interested in...


Comments and Discussions

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
mvpSandeep 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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170924.2 | Last Updated 10 Aug 2012
Article Copyright 2012 by Alex Fotios
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid