Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / operating-systems / Linux

Shell script for converting progressive JPEGs to baseline

0.00/5 (No votes)
10 Aug 2012CPOL 15.2K  
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

License

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