Skip to content

Instantly share code, notes, and snippets.

@leeeeeeeee2
Created February 3, 2023 13:40
Show Gist options
  • Save leeeeeeeee2/93c6bb4f7311399a6d9716d37e4c3508 to your computer and use it in GitHub Desktop.
Save leeeeeeeee2/93c6bb4f7311399a6d9716d37e4c3508 to your computer and use it in GitHub Desktop.
convert pdf to tiff in 600 dpi
#!/bin/sh
# from https://github.com/andrewpearce-digital/pdf2tiff/blob/master/pdf2tiff.sh
# Requires ghostscript
# ubuntu: sudo apt install ghostscript
FILECOUNT=0
TOTALSTARTTIME=$(date +"%s")
#Get all pdfs in process folder
for f in *.pdf
do
#Catch Process start time to calcuate process length
STARTTIME=$(date +"%s")
echo "Converting PDF to TIFF - $f..."
name=$(echo $f | cut -f 1 -d '.')
#Use GhostScript to convert pdf to tiff, resolution is 300dpi, file format is TIFFlzw
gs -dBATCH -dNOPAUSE -sDEVICE=tiff24nc -sCompression=lzw -r600 -dCOLORSCREEN=false -dNOINTERPOLATE -dNOTRANSPARENCY -dUseFastColor=true -sOutputFile=$name.tiff $f
#Catch process end time
ENDTIME=$(date +"%s")
#Calculate time difference and print result
echo "processed $f to TIFF in $(($ENDTIME - $STARTTIME)) seconds"
FILECOUNT=$((FILECOUNT + 1))
done
TOTALENDTIME=$(date +"%s")
echo "$FILECOUNT processed in $(($TOTALENDTIME - $TOTALSTARTTIME)) seconds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment