Repository navigation
fix: round resized heights - #93
Merged
Merged
Conversation
Bun.Image truncates the height it calculates for a width, so a 1254x837 source at 960 came out 960x640 instead of 960x641, a slightly different aspect ratio than the source. bongo now passes the rounded height. The height is part of the cache key, so each resized image is encoded once more.
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.
Summary
Bun.Imagetruncates the height that it calculates for a width. A 1254×837 source at 960 came out 960×640, not 960×641, so its aspect ratio was a little off from the source and from thewidthandheightthat bongo writes. Withheight: auto, the image then renders a fraction of a pixel shorter than an image from another tool.Performance
A cold-cache build of a site with 195 resized WebP images,
mainagainst this branch, withhyperfine, in both orders: 1.04 ± 0.06 and 0.98 ± 0.07. No change.bun run bench site: 2.38 s, against 2.34 s onmain, in the range ofmainacross runs. No change.Test plan
maingives 501×375)bun run build,bun test,bunx tsc -p .,bunx tsc -p build