News for hackers. Stuff that matters.
Re:Show HN: Make Your PDF Look Scanned by jmwilson on Tuesday May 12, 2020 @05:51PM (#23160387)
From the github repo, the site is a wrapper around exactly two shell commands. Instead of uploading your data to an untrusted site, you can run from the comfort and safety of your local computer:

  convert -density 150 input.pdf -colorspace gray -linear-stretch 3.5%x10% -blur 0x0.5 -attenuate 0.25 +noise Gaussian -rotate 0.5 temp.pdf
  gs -dSAFER -dBATCH -dNOPAUSE -dNOCACHE -sDEVICE=pdfwrite -sColorConversionStrategy=LeaveColorUnchanged dAutoFilterColorImages=true -dAutoFilterGrayImages=true -dDownsampleMonoImages=true -dDownsampleGrayImages=true -dDownsampleColorImages=true -sOutputFile=output.pdf temp.pdf
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!
Re:Show HN: Make Your PDF Look Scanned by miles on Tuesday May 12, 2020 @05:57PM (#23160466)
pmiller2 linked[0] to some alternatives[1], including this one[2] which only requires ImageMagick:

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

[0] https://news.ycombinator.com/item?id=23157979

[1] https://tex.stackexchange.com/questions/94523/simulate-a-sca...

[2] https://tex.stackexchange.com/a/94541/185219

Re:Show HN: Make Your PDF Look Scanned by baicunko on Tuesday May 12, 2020 @06:13PM (#23160662)
I'd recommend GS after ImageMagick as IM will hugely increase the size of the output due to rasterization!
Re:Show HN: Make Your PDF Look Scanned by derefr on Tuesday May 12, 2020 @06:51PM (#23161077)
But isn't rasterization necessary for this deception to work? Unless there's some magical scanner out there that's outputting vector images.
Re:Show HN: Make Your PDF Look Scanned by eru on Thursday May 14, 2020 @07:20AM (#23178129)
Whether leaving as vector works depends on how much your recipients care to investigate.
Re:Show HN: Make Your PDF Look Scanned by miles on Tuesday May 12, 2020 @06:45PM (#23161014)
The above convert command produced credible output only 6KB larger than the input PDF in my limited testing.
Re:Show HN: Make Your PDF Look Scanned by baicunko on Wednesday May 13, 2020 @02:24AM (#23164049)
When I tested using only IM I was getting 3x file size. I will further test your command to see how this improves the current situation, thanks!!
Re:Show HN: Make Your PDF Look Scanned by apetresc on Tuesday May 12, 2020 @07:09PM (#23161224)
But that in itself is a tell.
Re:Show HN: Make Your PDF Look Scanned by jschwartzi on Tuesday May 12, 2020 @07:14PM (#23161268)
Anyone unsophisticated enough to require you to print and handwrite a signature is also unsophisticated enough to not realize that the PDF size is a tell.
Re:Show HN: Make Your PDF Look Scanned by miles on Tuesday May 12, 2020 @07:13PM (#23161259)
The whole purpose is to make a new PDF that looks like it was scanned. The file size differing from the original is a feature, not a bug.
Re:Show HN: Make Your PDF Look Scanned by baicunko on Tuesday May 12, 2020 @06:08PM (#23160600)
In summary you could say yes but I wanted to simplify the process for the not-so-techy person. I will work on a Standalone app that simplifies the command and shows a nice GUI for more private documents
Re:Show HN: Make Your PDF Look Scanned by ryanwaggoner on Tuesday May 12, 2020 @09:24PM (#23162365)
I hope you don’t take the comment you’re responding to as anything negative. I’m a software engineer and I would use this myself rather than try and remember some arcane command line utility.
Re:Show HN: Make Your PDF Look Scanned by ARandomerDude on Wednesday May 13, 2020 @01:41AM (#23163822)
Make it a bash script! I have all kinds of scripts for things I don't want to remember in my ~/bin.
Re:Show HN: Make Your PDF Look Scanned by baicunko on Wednesday May 13, 2020 @04:08AM (#23164658)
Not at all, I'm actually quite happy with all the comments, ideas and feedback I've received on this, really encourages me to keep improving the project
Re:Show HN: Make Your PDF Look Scanned by cerved on Wednesday May 13, 2020 @03:31AM (#23164412)
A software engineer!?? On HN!?? IMPOSSIBLE
Re:Show HN: Make Your PDF Look Scanned by gdilla on Wednesday May 13, 2020 @01:08AM (#23163655)
i just tell people the dropbox app will scan docs for you. comes out looking like a photocopy. perfect for the bankers.
Re:Show HN: Make Your PDF Look Scanned by cristaloleg on Tuesday May 12, 2020 @09:53PM (#23162567)
Sounds like a plan to compile it into WASM and run locally inside any browser.

To be honest, I'm waiting for a boom of such services, that can be run in a separate tab without any network jumps.

Re:Show HN: Make Your PDF Look Scanned by mNovak on Tuesday May 12, 2020 @08:51PM (#23162106)
For other noobish windows users like myself, you can simply dump the following into a bat file. When run, it'll look for a file called "scanThis.pdf" and apply the conversion with ImageMagick.

   IF EXIST scanThis.pdf (magick convert -density 100 scanThis.pdf -colorspace gray +noise Gaussian -rotate 0.5 -depth 2 SCANNED.pdf) ELSE (ECHO File scanThis.pdf not found & PAUSE)
Re:Show HN: Make Your PDF Look Scanned by stormdennis on Wednesday May 13, 2020 @12:43AM (#23163546)
Sorry, I'm a long term Windows user but not very proficient. That can't be there entire contents of the bat file, can it? What else goes in there?
Re:Show HN: Make Your PDF Look Scanned by mNovak on Wednesday May 13, 2020 @12:58AM (#23163619)
Nope that's it. The bat file here is just a clickable shortcut so you don't have to remember the whole command. The interesting stuff is happening in ImageMagick, which has to be installed already.
Re:Show HN: Make Your PDF Look Scanned by stormdennis on Wednesday May 13, 2020 @01:26AM (#23163753)
Ok thanks, that's interesting. I might give it a shot
Re:Show HN: Make Your PDF Look Scanned by so_serious on Wednesday May 13, 2020 @02:25AM (#23164057)
It should be '-dAutoFilterColorImages=true' instead of 'dAutoFilterColorImages=true' for the gs command.