Skip to content

Instantly share code, notes, and snippets.

@oneyb
Created August 15, 2018 14:52
Show Gist options
  • Save oneyb/391246fa448ae26fc5a6fb11b1315065 to your computer and use it in GitHub Desktop.
Save oneyb/391246fa448ae26fc5a6fb11b1315065 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# I can't stand online photo albums that don't have a proper export mechanism
# Here is my solution for Shutterfly's shitty export mechanism.
# I hope this helps someone
if [[ -z $(which pdfcrop) ]]; then exit "Please install texlive for pdfcrop"; fi
if [[ -z $(which pdftk) ]]; then exit "Please install pdftk"; fi
# This is somehow translated to 'PREVIEW' and deleting it makes the watermark dissappear
pattern=50524556494557
for f in $*; do
tmp_log=$(tempfile)
tmp=$(tempfile)
tmp2=$(tempfile)
tmp3=$(tempfile)
pdftk $f cat output $tmp uncompress
sed -i 's/'"$pattern"'//' $tmp
# sed -i 's/50524556494557//' $tmp
pdfcrop --clip --margins "0 -20 0 0" $tmp $tmp2 &> $tmp_log
pdfcrop $tmp2 $tmp3 &>> $tmp_log
pdftk $tmp3 cat output ${f/.pdf/-scrubbed.pdf} compress
echo -e "\t${f/.pdf/-scrubbed.pdf} should be clean :)\n Log file is in $tmp_log"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment