frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: Veil – Dark mode PDFs without destroying images, runs in the browser

https://veil.simoneamico.com/
29•simoneamico•12h ago
Hi HN! here's a tool I just deployed that renders PDFs in dark mode without destroying the images. Internal and external links stay intact, and I decided to implement export since I'm not a fan of platform lock-in: you can view your dark PDF in your preferred reader, on any device. It's a side project born from a personal need first and foremost. When I was reading in the factory the books that eventually helped me get out of it, I had the problem that many study materials and books contained images and charts that forced me, with the dark readers available at the time, to always keep the original file in multitasking since the images became, to put it mildly, strange. I hope it can help some of you who have this same need. I think it could be very useful for researchers, but only future adoption will tell.

With that premise, I'd like to share the choices that made all of this possible. To do so, I'll walk through the three layers that veil creates from the original PDF:

- Layer 1: CSS filter. I use invert(0.86) hue rotate(180deg) on the main canvas. I use 0.86 instead of 1.0 because I found that full inversion produces a pure black and pure white that are too aggressive for prolonged reading. 0.86 yields a soft dark grey (around #242424, though it depends on the document's white) and a muted white (around #DBDBDB) for the text, which I found to be the most comfortable value for hours of reading.

- Layer 2: image protection. A second canvas is positioned on top of the first, this time with no filters. Through PDF.js's public API getOperatorList(), I walk the PDF's operator list and reconstruct the CTM stack, that is the save, restore and transform operations the PDF uses to position every object on the page. When I encounter a paintImageXObject (opcode 85 in PDF.js v5), the current transformation matrix gives me the exact bounds of the image. At that point I copy those pixels from a clean render onto the overlay. I didn't fork PDF.js because It would have become a maintenance nightmare given the length of the codebase and the frequent updates. Images also receive OCR treatment: text contained in charts and images becomes selectable, just like any other text on the page. At this point we have the text inverted and the images intact. But what if the page is already dark? Maybe the chapter title pages are black with white text? The next layer takes care of that.

- Layer 3: already-dark page detection. After rendering, the background brightness is measured by sampling the edges and corners of the page (where you're most likely to find pure background, without text or images in the way). The BT.601 formula is used to calculate perceived brightness by weighting the three color channels as the human eye sees them: green at 58.7%, red at 29.9%, blue at 11.4%. These weights reflect biology: the eye evolved in natural environments where distinguishing shades of green (vegetation, predators in the grass) was a matter of survival, while blue (sky, water) was less critical. If the average luminance falls below 40%, the page is flagged as already dark and the inversion is skipped, returning the original page. Presentation slides with dark backgrounds stay exactly as they are, instead of being inverted into something blinding.

Scanned documents are detected automatically and receive OCR via Tesseract.js, making text selectable and copyable even on PDFs that are essentially images. Everything runs locally, no framework was used, just vanilla JS, which is why it's an installable PWA that works offline too.

Here's the link to the app along with the repository: https://veil.simoneamico.com | https://github.com/simoneamico-ux-dev/veil

I hope veil can make your reading more pleasant. I'm open to any feedback. Thanks everyone

Comments

gwern•2m ago
Have you considered, since you can extract the images via the mask, selectively inverting them?

One can fairly reliably use a small NN to classify images by whether they should be inverted or just dimmed, and I've used it with great success for years now on my site: https://invertornot.com/ https://gwern.net/invertornot

Show HN: I put an AI agent on a $7/month VPS with IRC as its transport layer

https://georgelarson.me/writing/2026-03-23-nullclaw-doorman/
48•j0rg3•1h ago•14 comments

Why so many control rooms were seafoam green (2025)

https://bethmathews.substack.com/p/why-so-many-control-rooms-were-seafoam
545•Amorymeltzer•1d ago•110 comments

Chicago artist creates tourism posters for city's neighborhoods

https://www.chicagotribune.com/2026/03/25/chicago-neighborhood-posters/
24•NaOH•1h ago•10 comments

DOOM Over DNS

https://github.com/resumex/doom-over-dns
201•Venn1•3d ago•64 comments

Judge blocks Pentagon effort to 'punish' Anthropic with supply chain risk label

https://www.cnn.com/2026/03/26/business/anthropic-pentagon-injunction-supply-chain-risk
65•prawn•1h ago•4 comments

Moving from GitHub to Codeberg, for lazy people

https://unterwaditzer.net/2025/codeberg.html
506•jslakro•11h ago•251 comments

New York City hospitals drop Palantir as controversial AI firm expands in UK

https://www.theguardian.com/technology/2026/mar/26/new-york-hospitals-palantir-ai
271•chrisjj•4h ago•118 comments

Show HN: Veil – Dark mode PDFs without destroying images, runs in the browser

https://veil.simoneamico.com/
30•simoneamico•12h ago•2 comments

My minute-by-minute response to the LiteLLM malware attack

https://futuresearch.ai/blog/litellm-attack-transcript/
279•Fibonar•8h ago•122 comments

Apple Discontinues Mac Pro

44•alifeinbinary•1h ago•17 comments

Anthropic Subprocessor Changes

https://trust.anthropic.com
24•tencentshill•3h ago•17 comments

CERN to host a new phase of Open Research Europe

https://home.cern/news/news/cern/cern-host-europes-flagship-open-access-publishing-platform
184•JohnHammersley•5h ago•16 comments

HyperAgents: Self-referential self-improving agents

https://github.com/facebookresearch/hyperagents
124•andyg_blog•2d ago•55 comments

John Bradley, author of xv, has died

https://voxday.net/2026/03/25/rip-john-bradley/
203•linsomniac•6h ago•61 comments

OpenTelemetry profiles enters public alpha

https://opentelemetry.io/blog/2026/profiles-alpha/
144•tanelpoder•8h ago•15 comments

Order Granting Preliminary Injunction – Anthropic vs. U.S. Department of War [pdf]

https://storage.courtlistener.com/recap/gov.uscourts.cand.465515/gov.uscourts.cand.465515.134.0.pdf
60•theindieman•1h ago•5 comments

Whistler: Live eBPF Programming from the Common Lisp REPL

https://atgreen.github.io/repl-yell/posts/whistler/
13•varjag•3d ago•0 comments

Using FireWire on a Raspberry Pi

https://www.jeffgeerling.com/blog/2026/firewire-on-a-raspberry-pi/
48•jandeboevrie•4h ago•22 comments

We haven't seen the worst of what gambling and prediction markets will do

https://www.derekthompson.org/p/we-havent-seen-the-worst-of-what
527•mmcclure•4h ago•363 comments

Show HN: Fio: 3D World editor/game engine – inspired by Radiant and Hammer

https://github.com/ViciousSquid/Fio
27•vicioussquid•3h ago•3 comments

How much precision can you squeeze out of a table?

https://www.johndcook.com/blog/2026/03/26/table-precision/
40•nomemory•4h ago•4 comments

Show HN: Turbolite – a SQLite VFS serving sub-250ms cold JOIN queries from S3

https://github.com/russellromney/turbolite
103•russellthehippo•5h ago•24 comments

Colibri – chat platform built on the AT Protocol for communities big and small

https://colibri.social/
99•todotask2•7h ago•53 comments

What Does a Hologram Trademark Signify When the Hologram Isn't There?

https://blog.ericgoldman.org/archives/2026/03/what-does-a-hologram-trademark-signify-when-the-hol...
7•hn_acker•3d ago•1 comments

Stripe Projects: Provision and manage services from the CLI

https://projects.dev/
102•piinbinary•8h ago•28 comments

Running Tesla Model 3's computer on my desk using parts from crashed cars

https://bugs.xdavidhu.me/tesla/2026/03/23/running-tesla-model-3s-computer-on-my-desk-using-parts-...
853•driesdep•1d ago•298 comments

From zero to a RAG system: successes and failures

https://en.andros.dev/blog/aa31d744/from-zero-to-a-rag-system-successes-and-failures/
280•andros•2d ago•86 comments

Fast regex search: indexing text for agent tools

https://cursor.com/blog/fast-regex-search
25•jxmorris12•2d ago•5 comments

DeployTarot.com – Tarot card reading for deployments

https://deploytarot.com/setup
162•rembish•3h ago•42 comments

My home network observes bedtime with OpenBSD and pf

https://ratfactor.com/openbsd/pf-gateway-bedtime
113•ibobev•3d ago•33 comments