Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

GNOME Desktop users can put this in a Bash script in ~/.local/share/nautilus/ for more convincing looking fake PDF scans, accessible from your right-click menu. I do not recall where I copied it from originally to give credit so thanks, random internet person (probably on Stack Exchange). It works perfectly.

  ROTATION=$(shuf -n 1 -e '-' '')$(shuf -n 1 -e $(seq 0.05 .5))

  for pdf in "$@";
    do magick  -density 150 $pdf \
              -linear-stretch '1.5%x2%' \
              -rotate 0.4 \
              -attenuate '0.01' \
              +noise  Multiplicative \
              -colorspace 'gray' \
              "${pdf%.*}-fakescan.${pdf##*.}"
  done




That seq is probably supposed to be $(seq 0.05 0.05 0.5). Right now it's always 0.05.

Note that you can get random numbers straight from bash with $RANDOM. It's 15 bit (0 to 32767) but good enough here; this would get between 0.05 and 0.5: $(printf "0.%.4d\n" $((500 + RANDOM % 4501)))


Shouldn't $ROTATION be set inside the loop and actually used in the magick command?

You know, now that you point it out that seems obvious. I think maybe I was experimenting with rotation and left that in, unused. I did this years ago. The loop works OK though. Thanks for the feedback (and now I have to finish editing that script ...)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: