Compress locally

Info about the image

I got fed up. Looking for a simple solution that does one thing perfectly…and I ended up with bunch of apps that asked me to sacrifice my firstborn (which I don’t have by the way, so that was it…;>). But seriously. We all need to start thinking of saving space. There is really no point to keep PDFs that weigh like Mike Tyson after failed attempt at Ozempic (disclaimer: I have absolutely no idea if he ever took any).. BUUUUUT… we also do NOT want to send our data out there into online services, the privacy policy of which we cannot be sure of (or even understand). So. Do. It. Locally. Safely. One click. Simple script. And with a little help from our friend, the Automator.

Also, there is this nice phenomenon of place-based approach / place-based identity in humanities, social sciences, like visit local museum or buy at a local store. Do you think this idea could be considered as supporting the trend? πŸ™‚

compress_one() {
local in="$1"
[ -f "$in" ] || return 0
local ext="${in##*.}"
ext="$(printf '%s' "$ext" | tr '[:upper:]' '[:lower:]')"
....
[ "$ext" = "pdf" ] || return 0
local dir base stem out
dir="$(dirname "$in")"
base="$(basename "$in")"
stem="${base%.*}"
out="$dir/${stem}-compressed.pdf"
....
if gs -sDEVICE=pdfwrite \
-dPDFSETTINGS="/ebook" \
-dNOPAUSE -dQUIET -dBATCH \ ....etc.

Why the code? Why not. Enjoy the scribble. πŸ™‚ It’s not suppose to be a full working code. It’s suppose to be a non-working snippet of random fragments. Just fyi, so you don’t eat away at it thinking, it doesn’t make any sense.

Leave a comment