Created
April 24, 2014 03:01
-
-
Save vphill/11239998 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in * | |
do | |
echo "processing $i =======" | |
echo "creating pdfs for" | |
find "$i" -maxdepth 1 -name "*.tif" | xargs -i -n 1 -P 6 convert -density 200x200 -compress jpeg -quality 80 "{}" "{}".pdf | |
echo "compressing pdfs" | |
find "$i" -maxdepth 1 -name "*.tif.pdf" | xargs -i -n 1 -P 5 gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile={}_out.pdf {} | |
cd "$i" | |
echo "concatinating pdfs" | |
pdftk *_out.pdf cat output temp.pdf | |
echo "linerizing pdf" | |
qpdf --linearize temp.pdf $i.pdf | |
rm *.tif.pdf | |
rm *_out.pdf | |
rm temp.pdf | |
mkdir 01_tif | |
mv *.tif 01_tif | |
mkdir 02_pdf | |
mv "$i".pdf 02_pdf | |
cd .. | |
echo "finding all tif files" | |
find -name "*.tif" -exec identify {} \; > stats.txt | |
#removing compression on non-bitonal images | |
echo "removing compression on non-bitonal images" | |
cat stats.txt | awk -F" TIFF" '{ print $1 }' | xargs -i -n1 -P5 mogrify +compress | |
#compress bitonal files | |
echo "compressing bitonal images" | |
grep "1-bit" stats.txt | awk -F" TIFF" '{ print $1 }' | xargs -i -n1 -P5 mogrify -compress Group4 {} | |
rm stats.txt | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment