News for hackers. Stuff that matters.
Re:Show HN: Make Your PDF Look Scanned by cs702 on Tuesday May 12, 2020 @07:59PM (#23161664)
Try this one-line ImageMagick command to make COMPACT pseudo-scanned files:

  convert -density 150 ORIGINAL.pdf -colorspace gray +noise Gaussian -rotate 0.5 -depth 2 SCANNED.pdf
Consider using `-depth 1`, `-depth 3` as a final parameter to map colors to only 2¹=2 or 2³=8 instead of 2²=4 gray levels. Using a small number of gray levels SIGNIFICANTLY reduces file size and also gives your pseudo-scanned document a more pixelated, it-just-came-out-of-my-old-printer look.

Also consider using `-density 100` or even `-density 75` for long text documents. Using a density of 75 dpi produces documents that are 4x smaller than 150 dpi (75²=150²/4) and doesn't affect the readability of normal-sized (10-12pt) text that much.

Finally, sometimes it works best not to add Gaussian noise.

Re:Show HN: Make Your PDF Look Scanned by miles on Tuesday May 12, 2020 @11:44PM (#23163268)
Rather than making a COMPACT version, your command created a file over twice the size of one created using the aforementioned

convert letter.pdf -colorspace gray \( +clone -blur 0x1 \) +swap -compose divide -composite -linear-stretch 5%x0% -rotate 1.5 as-scanned.pdf

However, that may be a useful feature, since many users end up inadvertently creating very large PDFs when scanning.

Re:Show HN: Make Your PDF Look Scanned by Moru on Wednesday May 13, 2020 @02:04AM (#23163942)
If you lower the resolution those auto-scanning services that does OCR on the documents will get problems converting the tex back to normal text. Which might or might not be the point of doing this in the first place... :-)
Re:Show HN: Make Your PDF Look Scanned by mwcampbell on Friday May 15, 2020 @08:32AM (#23191383)
Just remember that if you make it harder for OCR to produce accurate text from an image, you also make it harder for blind people to read it.
Re:Show HN: Make Your PDF Look Scanned by cs702 on Wednesday May 13, 2020 @11:51AM (#23168133)
The output file size relative to other approaches will depend on the contents of the input file (e.g., does it embed any bitmaps, or is it only text in non-rasterized fonts?), the density you use (e.g., 150 dpi is 4x greater than 75 dpi), the bit depth you use (3 bits is 4x greater than 1 bit), and whether you add noise or not. Also, the one-line command above your comment is short/easy to remember and reasonably fast -- which is useful if you're impatient like me.

All that said, note that you can always add a `-compress <compression method>` to the convert command, although this could make it noticeably slower, say, for a directory full of long documents. There's even a Fax TIFF compression method that makes the document look like it came out of one of those fax machines you see in movies from the 1980's. To get a list of supported compression methods, type `convert -list compress` at the command line.

Re:Show HN: Make Your PDF Look Scanned by baicunko on Wednesday May 13, 2020 @02:21AM (#23164032)
I'm taking notes on all comments, I will test what you mentioned to see how the document ends up looking, thanks!