- Create image scans using any method(this one is good)
- Pass images to this script(tested on ubuntu)
- Script requirements(tested with
apt
install on Ubuntu):exiftool imagemagick img2pdf ghostscript qpdf
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Input images to convert"
else
for i in "$@"; do
if [ ! -f $i ]; then
echo "File ${i} does not exist"
exit
fi
done
RED='\033[0;31m'
NC='\033[0m'
exiftool -overwrite_original -all:all= $@
mogrify -quality 70 $@
img2pdf $@ > middle.pdf
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf middle.pdf
rm middle.pdf
exiftool -overwrite_original -all:all= output.pdf
echo -e "${RED}Done"
qpdf --linearize --replace-input output.pdf
echo -e "Remaining embedded exif data:${NC}"
exiftool -ee -all:all output.pdf
echo -e "${RED}Remaining pdf exif data:${NC}"
exiftool -all:all output.pdf
fi