Repository navigation
Conversation
- resampleOpaqueFast and resampleTransparentFast become one resampleFast (red+blue and green+alpha lanes work for opaque pixels too), split into a vertical and a horizontal pass. Transparency in the middle of an image is found by the vertical pass, which then reruns premultiplied. - src/util/alpha.ts: isOpaque, premultiply8 and unpremultiply8 (lookup table, rounding like the clamped arrays), used by resample and blur; one littleEndian flag. - Blur results are unchanged (corpus). Fast resizing of transparent images differs by 1 only where unpremultiplying hits exactly .5 (0.003-0.007% of the values). Doubling a photo with alpha: 117 -> 103 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR cleans up the fast resampling from #71 and the 8-bit alpha code it duplicated from
blur().Changes
resampleOpaqueFastandresampleTransparentFastare merged intoresampleFast.verticalFastandhorizontalFast.src/util/alpha.ts:isOpaque,premultiply8,unpremultiply8, and a singlelittleEndianflag.resampleandblur.unpremultiply8uses a 64K lookup table that rounds like the clamped arrays, soblur()gives the same results as before.blur()'s 8-bit path now explicitly requires little endian, because the helpers work on 32-bit words. On big-endian machines it falls back to the float path.Verified
blur()is bit-identical to master on 1313 corpus images, 5 sigmas each, with and without alpha.tests/resize.jsadds an image whose only transparent pixel is in the middle, which exercises the rerun path.Speed (
resize()of a 1920×1080 photo, master → this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01YJgRK5qpwJEbHPuFv6kgAQ