Inspired by this Gist and @coryodaniel's solution,
I put the script inside a babashka script, called pdf-like-fax.clj
:
#!/usr/bin/env bb
(defn pdf-like-fax [input output]
(let [sign (rand-nth ["+" "-"])
rotation (rand-int 1000)
cmd (format "convert -density 150 %s -rotate %s0.%s -attenuate 0.4 +noise Multiplicative -attenuate 0.03 +noise Multiplicative -sharpen 0x1.0 -colorspace Gray %s" input sign rotation output)
prepared-cmd (str/split cmd #" ")]
(apply shell/sh prepared-cmd)))
(let [[input output] *command-line-args*]
(pdf-like-fax input output))
Usage:
bb pdf-like-fax.clj input.pdf output.pdf
I think what's really good about it is, that the ability to explicitly reference Image Magick from nixpkgs as well as the ghostshell runtime input that's required by Image Magick. This way you don't need to remember to manually install both tools.