Skip to content
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

Merged
merged 4 commits into from
Feb 19, 2019
Merged

fix(gatsby-plugin-manifest): improve SVG->PNG fidelity #11608

merged 4 commits into from
Feb 19, 2019

Conversation

rgiese
Copy link
Contributor

@rgiese rgiese commented Feb 6, 2019

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.

@pieh pieh changed the title gatsby-plugin-manifest: Improve SVG->PNG fidelity fix(gatsby-plugin-manifest): improve SVG->PNG fidelity Feb 6, 2019
@pieh
Copy link
Contributor

pieh commented Feb 6, 2019

Does density option have any impact on non-vector formats?

@rgiese
Copy link
Contributor Author

rgiese commented Feb 6, 2019

@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.

@rgiese
Copy link
Contributor Author

rgiese commented Feb 6, 2019

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).

@pieh
Copy link
Contributor

pieh commented Feb 6, 2019

@rgiese those errors shouldn't be related to your PR, but I'm not sure yet. The test does use gatsby-plugin-manifest, but at least to me it might be flake - I'll restart just this test and see if this happens again, and will dive more if it fails again with similiar error

@DSchau
Copy link
Contributor

DSchau commented Feb 6, 2019

Yikes @rgiese don't worry about fixing the failing tests, unrelated to this PR.

It looks like I possibly broke them in #11581. We'll get a fix out diagnosing the issue or fixing the test. Working on that now!

@rgiese
Copy link
Contributor Author

rgiese commented Feb 13, 2019

Hey @pieh, I updated the PR from upstream and now all tests are passing. Could you kindly take another look and/or sign off?

@rgiese
Copy link
Contributor Author

rgiese commented Feb 17, 2019

@DSchau, want to review?

@DSchau DSchau added the status: awaiting reviewer response A pull request that is currently awaiting a reviewer's response label Feb 18, 2019
@pieh pieh self-assigned this Feb 18, 2019
@pieh
Copy link
Contributor

pieh commented Feb 18, 2019

Hey, sorry for late reply - was on issue duty last week and wasn't reviewing any PRs then. But I'll do this now

@pieh
Copy link
Contributor

pieh commented Feb 18, 2019

Looks good - I added just some sanity clamping of density - with totally unreasonable test case of producing icon with 4096 size I got:

Error: Invalid density (1 to 2400) 4096

from sharp

@pieh
Copy link
Contributor

pieh commented Feb 18, 2019

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

Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rgiese!

@pieh pieh merged commit e9345cd into gatsbyjs:master Feb 19, 2019
@gatsbot
Copy link

gatsbot bot commented Feb 19, 2019

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:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (Currently we’ve got a couple t-shirts available, plus some socks that are really razzing our berries right now.)
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

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!

@rgiese
Copy link
Contributor Author

rgiese commented Feb 20, 2019

Thanks everyone for your help!

@rgiese rgiese deleted the topics/svg-favicon branch February 20, 2019 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: awaiting reviewer response A pull request that is currently awaiting a reviewer's response
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants