-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gatsby-plugin-manifest): improve SVG->PNG fidelity #11608
Conversation
…tion when rasterizing SVGs for favicons.
Does |
@pieh According to the Sharp docs it does not, and I've tried running a JPG through it with the change and came out just fine. |
Also, any help in diagnosing the failing e2e_tests_production_runtime test would be much appreciate since the tests prescribed in How to Contribute passed for me locally. They're failing in the same way on a number of other unrelated PRs as well, it seems (not that I necessarily want to shrug them off). |
@rgiese those errors shouldn't be related to your PR, but I'm not sure yet. The test does use |
Hey @pieh, I updated the PR from upstream and now all tests are passing. Could you kindly take another look and/or sign off? |
@DSchau, want to review? |
Hey, sorry for late reply - was on issue duty last week and wasn't reviewing any PRs then. But I'll do this now |
Looks good - I added just some sanity clamping of density - with totally unreasonable test case of producing icon with 4096 size I got:
from |
Hmm, there seem to be some github hiccup - extra commits pushed to the branch doesn't show up here https://github.com/rgiese/gatsby/commits/topics/svg-favicon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rgiese!
Holy buckets, @rgiese — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
Thanks everyone for your help! |
Description
gatsby-plugin-manifest
resizes a user-provided icon to PNGs of various resolutions required for favicons using Sharp. This change allows SVGs to be usable as the user-provided icon.Sharp is already capable of ingesting an SVG and rasterizing it to PNGs; however, in its default configuration, it first rasterizes the provided SVG to a pixel image of default density (e.g. 72dpi) and then upscales it to the desired size (e.g. 512x512), which can create really poor upscaling artifacts.
This change instructs Sharp to use a rasterizing density equal to the size of the desired output image which eliminates the upscaling problems.