[gatsby-plugin-image] Blurred placeholder does not respect attention cropping
See original GitHub issueDescription
I have a static image:
<StaticImage
alt="My alt"
aspectRatio={360 / 288}
formats={["auto", "webp", "avif"]}
layout="constrained"
width={640}
placeholder="blurred"
src="./my-image.jpg"
/>
having, by default, transformOptions={{fit: "cover", cropFocus: "attention"}}
.
The generated blurred placeholder image does not have the same cropping as the final image.
One can see that the wheel is not as the same place.
I tried the entropy, but it leads to a different cropping for the final image, and the placeholder one’s is still not the same.
Steps to reproduce
Take this picture:
Use it with a small size and an aspect ratio of 1
to emphasize the issue:
<StaticImage
alt="My alt"
aspectRatio={1}
layout="constrained"
width={300}
placeholder="blurred"
src="./my-image.jpg"
transformOptions={{fit: "cover", cropFocus: "attention"}}
/>
Expected result
Wheel should be aligned 😉
The plugin should apply the cropping, then generate the placeholder (wheither it’s blurred, traced svg…)
Actual result
Wheel are not aligned.
Environment
Run gatsby info --clipboard
in your project directory and paste the output here:
System:
OS: macOS 11.2.1
CPU: (8) arm64 Apple M1
Shell: 5.8 - /bin/zsh
Binaries:
Node: 15.11.0 - /var/folders/fc/fqf9t2nn1wb4fy216v7jkdyw0000gn/T/yarn--1615202496627-0.34340404333252783/node
Yarn: 1.22.10 - /var/folders/fc/fqf9t2nn1wb4fy216v7jkdyw0000gn/T/yarn--1615202496627-0.34340404333252783/yarn
npm: 7.6.0 - /opt/homebrew/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 88.0.4324.192
Safari: 14.0.3
npmPackages:
gatsby: 3.0.3 => 3.0.3
gatsby-plugin-canonical-urls: 3.0.0 => 3.0.0
gatsby-plugin-catch-links: 3.0.0 => 3.0.0
gatsby-plugin-eslint: 3.0.0 => 3.0.0
gatsby-plugin-image: 1.0.0 => 1.0.0
gatsby-plugin-react-helmet: 4.0.0 => 4.0.0
gatsby-plugin-react-svg: 3.0.0 => 3.0.0
gatsby-plugin-sass: 4.0.2 => 4.0.2
gatsby-plugin-sharp: 3.0.0 => 3.0.0
gatsby-plugin-sitemap: 3.0.0 => 3.0.0
gatsby-plugin-typescript: 3.0.0 => 3.0.0
gatsby-source-filesystem: 3.0.0 => 3.0.0
gatsby-transformer-remark: 3.0.0 => 3.0.0
gatsby-transformer-sharp: 3.0.0 => 3.0.0
Tell me if I can be of any help.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Gatsby Image plugin
This generates a very low-resolution version of the source image and displays it as a blurred background. None, "none", NONE, No placeholder. You...
Read more >gatsby-plugin-sharp | Yarn - Package Manager
Exposes several image processing functions built on the Sharp image processing library. This is a low-level helper plugin generally used by other Gatsby...
Read more >Gatsby Changelog | 5.3.0
gatsby -plugin-image : Ensure cache hash is unique, via PR #37087; gatsby : ... feature Gatsby automatically falls back to the default placeholder...
Read more >gatsby-image-plugin, StaticImage cannot override the default ...
This is a bug caused by gatsby-plugin-image outputting it's styles after user CSS (including Tailwind), which will override all classes of ...
Read more >React Hooks Handbook - Gatsby Plugin Image - Design+Code
If these values don't respect the original image's aspect ratio, the image will be cropped, and not stretched. <StaticImage src="../images/sleeping-kitten.jpg" ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This seems to be happening because running the attention algorithm on the 20px image yields a different result from the larger image. The way around this would be to use the main output image as the source for the placeholder, rather than the input image as we do now.
@marcelscruz That is a different issue
Hi!
I’m closing this as a stale issue as in the meantime Gatsby 4 and related packages were released. You can check our Framework Version Support Page to see which versions currently receive active support. If this is a feature request, please create a discussion as we moved feature requests from issues to GitHub Discussions.
Please try the mentioned issue on the latest version (using the
next
tag) and if you still see this problem, open a new bug report. It must include a minimal reproduction.Thanks!