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

Gatsby Image & Sharp background blur-up #25640

Closed
mirshko opened this issue Jul 9, 2020 · 2 comments · Fixed by #24999
Closed

Gatsby Image & Sharp background blur-up #25640

mirshko opened this issue Jul 9, 2020 · 2 comments · Fixed by #24999
Assignees
Labels
topic: media Related to gatsby-plugin-image, or general image/media processing topics type: bug An issue or pull request relating to a bug in Gatsby

Comments

@mirshko
Copy link

mirshko commented Jul 9, 2020

Description

When using fit: CONTAIN background: "#ffffff" on a childImageSharp with the ...GatsbyImageSharpFluid_withWebp fragment the initial blurred base64 image has a black background which changes to the white background with the image loaded.

Steps to reproduce

Using a GraphQL static query, add

childImageSharp {
  fluid(
    maxWidth: 512
    maxHeight: 512
    fit: CONTAIN
    background: "#ffffff"
  ) {
    ...GatsbyImageSharpFluid_withWebp
  }
}

query to your image,

see image blur up from black image to white.

Screen Recording 2020-07-09 at 12 27 37 PM

CodeSandbox Example

https://codesandbox.io/s/brave-chaplygin-p7tnw?file=/src/components/image.js

Expected result

Blurred up image should have a white background

Actual result

Blurred up image has a black background in Base64 image

Environment

System:
OS: macOS 10.15.5
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.5.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.5 - /usr/local/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 83.0.4103.116
Safari: 13.1.1
npmPackages:
gatsby: ^2.23.12 => 2.23.12
gatsby-image: ^2.4.9 => 2.4.9
gatsby-plugin-manifest: ^2.4.14 => 2.4.14
gatsby-plugin-postcss: ^2.3.9 => 2.3.9
gatsby-plugin-react-helmet: ^3.3.6 => 3.3.6
gatsby-plugin-sharp: ^2.6.14 => 2.6.14
gatsby-remark-images: ^3.3.17 => 3.3.17
gatsby-remark-normalize-paths: ^1.0.0 => 1.0.0
gatsby-remark-relative-images: ^0.3.0 => 0.3.0
gatsby-source-filesystem: ^2.3.14 => 2.3.14
gatsby-transformer-remark: ^2.8.23 => 2.8.23
gatsby-transformer-sharp: ^2.5.7 => 2.5.7

@mirshko mirshko added the type: bug An issue or pull request relating to a bug in Gatsby label Jul 9, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 9, 2020
@pieh pieh added topic: media Related to gatsby-plugin-image, or general image/media processing topics and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jul 9, 2020
@polarathene
Copy link
Contributor

I've identified the problem and will resolve this.

@polarathene polarathene self-assigned this Jul 19, 2020
@polarathene
Copy link
Contributor

I've appended it as a fix to a related PR that's waiting on review/merge: #24999

It just turned out to be that the option wasn't passed to the base64 sharp method. Alternatively if you want transparency in your base64 images, you can use PNG or WEBP formats instead, the linked PR adds documentation to explain how to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: media Related to gatsby-plugin-image, or general image/media processing topics type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants