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

Bug found when trying to generate two versions of the same image in a graphql query #35054

Closed
2 tasks done
mrbjjackson opened this issue Mar 4, 2022 · 1 comment · Fixed by #35075
Closed
2 tasks done
Labels
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

@mrbjjackson
Copy link

mrbjjackson commented Mar 4, 2022

Preliminary Checks

Description

This is a bug I found while trying to produce two versions of the same image from a graphql repo. I used two graphql aliases to return the same image with different settings for transformOptions: {duotone }.

I found that if all parameters in the graphql query are the same, except for the transformOptions: { duotone } settings, two different images are not generated. Rather the same image is displayed twice.

In my case, I was able to bypass this bug by adding different quality settings to each of the query parameters. If I add quality settings to each image query, then the different images display correctly. I have commented out some alternative graphql queries in the index.js that demonstrate this fix.

Reproduction Link

https://github.com/mrbjjackson/gatsby-plugin-image-transformOptions-bug

Steps to Reproduce

  1. Install the gatsby project and run it.
  2. Navigate to "/"

Expected Result

Two images with different duotone settings to be displayed.
Screenshot 2022-03-04 at 11 05 01

Actual Result

The same image is displayed twice.
Screenshot 2022-03-04 at 11 04 38

Environment

System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 15.11.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.6.0 - /usr/local/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 99.0.4844.51
    Firefox: 97.0.1
    Safari: 12.1.2
  npmPackages:
    gatsby: ^4.9.0 => 4.9.0 
    gatsby-plugin-image: ^2.9.0 => 2.9.0 
    gatsby-plugin-manifest: ^4.9.0 => 4.9.0 
    gatsby-plugin-react-helmet: ^5.9.0 => 5.9.0 
    gatsby-plugin-sass: ^5.9.0 => 5.9.0 
    gatsby-plugin-sharp: ^4.9.0 => 4.9.0 
    gatsby-plugin-sitemap: ^5.9.0 => 5.9.0 
    gatsby-source-filesystem: ^4.9.0 => 4.9.0 
    gatsby-transformer-sharp: ^4.9.0 => 4.9.0 
  npmGlobalPackages:
    gatsby-cli: 4.6.1

Config Flags

No response

@mrbjjackson mrbjjackson added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 4, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Mar 4, 2022
@LekoArts LekoArts added 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 and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Mar 7, 2022
@LekoArts
Copy link
Contributor

LekoArts commented Mar 7, 2022

Hi, thanks for the issue!

I simplified your reproduction to this and can also reproduce this:

import * as React from "react";
import { graphql } from "gatsby";
import { GatsbyImage, getImage } from "gatsby-plugin-image";

// markup
const IndexPage = ({ data }) => {
   return (
      <main>
         <h1>Hello</h1>
         <GatsbyImage image={getImage(data.duotone1.childImageSharp)} />
         <GatsbyImage image={getImage(data.duotone2.childImageSharp)} />
      </main>
   );
};

export default IndexPage;

export const pageQuery = graphql`
   query MyQuery {
      duotone1: file(name: {eq: "test"}) {
         childImageSharp {
            gatsbyImageData(
               width: 500
               transformOptions: {
                  duotone: { highlight: "#BBFFE6", shadow: "#51758D" }
               }
            )
         }
      }
      duotone2: file(name: {eq: "test"}) {
         childImageSharp {
            gatsbyImageData(
               width: 500
               transformOptions: {
                  duotone: { highlight: "#F1D283", shadow: "#000000" }
               }
            )
         }
      }
   }
`

When you look at the generated <picture> element its the same image, we don't respect the diff transformOptions. I'll look into it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

Successfully merging a pull request may close this issue.

2 participants