Skip to content

Make the blur an actual blur - #2

Merged
govindup63 merged 1 commit into
mainfrom
feat/real-blur
Aug 21, 2026
Merged

govindup63 merged 1 commit into
mainfrom
feat/real-blur

Conversation

@govindup63

Copy link
Copy Markdown
Contributor

style: 'blur' was a twelvefold downscale drawn back up with bilinear smoothing. That reads as a blocky smear rather than a blur, and the letter shapes stay faintly guessable in it.

What changed

Downsample first, then a real gaussian pass over the region. Keeping the two steps separate matters, because they do different jobs:

  • the downsample is what destroys the detail. At a twelfth of the size there is no glyph left to sharpen back up.
  • the gaussian is cosmetic. It is the difference between something that looks deliberate and something that looks like a broken thumbnail.

The blur reads a padded region rather than the box alone. Blurring the box on its own samples transparency past its edges, which leaves a pale halo just inside the border and makes the box look like a sticker. Only the box itself is written back; the padding is scaffolding.

Radius is tied to the height of what is being covered (box.height * 0.32, floor 3 px), so a page rendered at 300 dpi gets the same apparent softness as one at 150. No new option: the sensible radius is a function of the text size, not something a caller should have to guess.

pixelate keeps the same downsample with smoothing off, which is what it always wanted to be. The shared step is now one downsample() helper.

The warning was wrong

It said blurred and pixelated text "can often be recovered". That is not true of a twelvefold downsample, so the warning was overstating one risk and hiding the real one.

What these two styles actually leak is the shape of what was covered: how many words there were, how long each one was, and where the lines broke. That is enough to tell a short name from a long one, which is a genuine reason to prefer box when the output leaves your control. The warning and the README now say that instead.

Verified

Rendered all four styles on the test fixture at 150 dpi and compared against the previous implementation. The new blur is an even, soft band with no readable letter shapes and no edge halo; pixelate stays visibly distinct from it. Tests 13/13, typecheck clean.

Docs: the style note and the throws-and-warns table in the README are updated to match.

`style: 'blur'` was a twelvefold downscale drawn back up with bilinear
smoothing. That reads as a blocky smear rather than a blur, and the letter
shapes stay faintly guessable in it.

Now it downsamples first and then runs a real gaussian pass over the
region. The two steps do different jobs and it is worth keeping them
separate: the downsample is the one that destroys the detail, because at a
twelfth of the size there is no glyph left to sharpen back up, and the
gaussian is cosmetic.

The blur reads a padded region rather than the box alone. Blurring the box
on its own samples transparency past its edges, which leaves a pale halo
just inside the border and makes the box look like a sticker. Only the box
itself is written back.

Radius is tied to the height of what is covered, so a page rendered at 300
dpi gets the same apparent softness as one at 150.

`pixelate` keeps the same downsample with smoothing off, which is what it
always wanted to be, and the shared step is now one function.

The warning was wrong, so it is rewritten. It said blurred text "can often
be recovered", which is not true of a twelvefold downsample. What these two
styles actually leak is the shape of what was covered: how many words, how
long each was, and where the lines broke. That is enough to tell a short
name from a long one, which is a real reason to prefer `box`, just not the
reason the warning gave.

Signed-off-by: Govind Pandey <govindup63@gmail.com>
@govindup63
govindup63 merged commit 1a05fbc into main Aug 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant