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

Responsive images generated with contain fit and an aspect ratio that causes pillarboxing are missing high resolution images #33647

Open
2 tasks done
teddybradford opened this issue Oct 23, 2021 · 9 comments
Labels
help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. 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

@teddybradford
Copy link

teddybradford commented Oct 23, 2021

Preliminary Checks

Description

Images that get transformed with imagesharp using fit: contain and an aspectRatio that causes pillarboxing should add the pillarboxes before resizing the image for each breakpoint. Otherwise, we end up losing higher resolution images due to the order of operations.

Steps to Reproduce

  1. Generate responsive images via a GraphQL query (or StaticImage works too) with the following settings:
    childImageSharp {
      gatsbyImageData(
        layout: FULL_WIDTH
        aspectRatio: 2
        transformOptions: { fit: CONTAIN }
      )
    }
    

Expected Result

As an example, for a portrait image with a resolution of 800x1000, and image breakpoints of [600, 900, 1200], the resulting responsive images should be:

  • 600x300
  • 900x450
  • 1200x600

We can get these resolutions if instead of sizing down first to conform to the breakpoint and aspect ratio, the pillarboxes were added to to the sides of the image first, and then the image resized (e.g. the 800x1000 image gets cropped to be 2000x1000, and then resized to each breakpoint after that).

Actual Result

Instead, the resulting responsive images are:

  • 600x300
  • 800x400

Environment

System:
    OS: macOS 11.6
    CPU: (8) arm64 Apple M1
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.8.0 - ~/.nvm/versions/node/v16.8.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.8.0/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.8.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Firefox: 93.0
    Safari: 15.0
  npmGlobalPackages:
    gatsby-cli: 3.14.2
@teddybradford teddybradford added the type: bug An issue or pull request relating to a bug in Gatsby label Oct 23, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Oct 23, 2021
@LekoArts LekoArts added status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Oct 25, 2021
@LekoArts
Copy link
Contributor

Hi!

Please provide a minimal reproduction showing this. Thanks!

@teddybradford teddybradford changed the title Portrait images with full width layout and aspect ratio with contain fit are missing high resolution responsive images Responsive images generated with contain fit and an aspect ratio that causes pillarboxing are missing high resolution responsive images Oct 25, 2021
@teddybradford teddybradford changed the title Responsive images generated with contain fit and an aspect ratio that causes pillarboxing are missing high resolution responsive images Responsive images generated with contain fit and an aspect ratio that causes pillarboxing are missing high resolution images Oct 25, 2021
@teddybradford
Copy link
Author

Hi @LekoArts, I've created a reproduction repo: https://github.com/teddybradford/gatsby-image-bug-repro/ and I updated the original post for clarity and to match the repo. Let me know if you have any questions.

@LekoArts LekoArts added gatsby 4 topic: media Related to gatsby-plugin-image, or general image/media processing topics and removed status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. labels Nov 8, 2021
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Nov 28, 2021
@teddybradford
Copy link
Author

Not stale

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Nov 29, 2021
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 19, 2021
@teddybradford
Copy link
Author

Not stale

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 19, 2021
@github-actions
Copy link

github-actions bot commented Jan 8, 2022

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 8, 2022
@teddybradford
Copy link
Author

Not stale 😄

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 9, 2022
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jan 29, 2022
@LekoArts LekoArts added help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. and removed stale? Issue that may be closed soon due to the original author not responding any more. gatsby 4 labels Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. 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

No branches or pull requests

2 participants