Discussion
Loading...

#Tag

Log in
  • About
  • Code of conduct
  • Privacy
  • About Bonfire
Nathan Vander Wilt
Nathan Vander Wilt
@natevw@toot.cafe  ·  activity timestamp 5 days ago

@rl_dane the surprising steps are the lossy ones ;-)

* the (lossy) downsampling to 1bpp and (lossy) thresholding enabled "lossless" run-length encoding or whatnot to compress at such a high ratio

* the OCR step likely also wasn't lossless — for every very-slightly-unique splotch on the page with a visual pattern _close enough_ to a prototypical `a`/`b`/`c`/… (visually) it probably got replaced with a shared version of said ~letter instead

R.L. Dane :Debian: :OpenBSD: :FreeBSD: 🍵 :MiraLovesYou:
R.L. Dane :Debian: :OpenBSD: :FreeBSD: 🍵 :MiraLovesYou:
@rl_dane@polymaths.social replied  ·  activity timestamp 2 days ago

@natevw

To your first point, you're absolutely right. Thresholding yeilds far more than an 8:1 compression because PNG is far more able to crunch bilevel graphics vs. grayscale.

To your second point, you're describing the #JBIG lossy compressor for scanned documents and monochrome images, and yeah, that's super cursed. I'd be surprised if that's what ocrmypdf is doing, but it's possible? ¯\_(ツ)_/¯

  • Copy link
  • Flag this comment
  • Block
Screwtapello
Screwtapello
@Screwtapello@teh.entar.net  ·  activity timestamp 5 days ago

@rl_dane I know PDF can store 1-bit images with more specialised compression formats developed for fax machines and the like, I wonder if they outperform PNG for that specific use-case.

R.L. Dane :Debian: :OpenBSD: :FreeBSD: 🍵 :MiraLovesYou:
R.L. Dane :Debian: :OpenBSD: :FreeBSD: 🍵 :MiraLovesYou:
@rl_dane@polymaths.social replied  ·  activity timestamp 2 days ago

@Screwtapello

The fax compression algorithms are very limited, designed for a time where RAM was scarce. They basically compressed a couple rows of pixels at a time, nothing more, AFAIK.

There is #JBIG, which is a LOSSY 1-bit monochrome image compression algorithm. Yes, it is exactly as cursed as that sounds, there have been many cases where numbers and figures were changed by JBIG because a 6 looked like an 8. Horrifying. XD

I'm not totally sure what happened in this example, because I realized after I posted this that the pdfimages utility is converting whatever the PDF stored the images as into PNGs, not just extracting any embedded PNGs it finds.

  • Copy link
  • Flag this comment
  • Block

BT Free Social

BT Free is a non-profit organization founded by @ozoned@btfree.social . It's goal is for digital privacy rights, advocacy and consulting. This goal will be attained by hosting open platforms to allow others to seamlessly join the Fediverse on moderated instances or by helping others join the Fediverse.

BT Free Social: About · Code of conduct · Privacy ·
Bonfire social · 1.0.1 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Code of Conduct