gatsby-source-sanity icon indicating copy to clipboard operation
gatsby-source-sanity copied to clipboard

Images quality degraded when

Open laurage opened this issue 5 years ago • 3 comments
trafficstars

Hello,

When using getFluidGatsbyImage from gatsby-source-sanity, the images returned are degraded.

Using const fluidProps = getFluidGatsbyImage(node.asset._ref, {maxWidth: 3000}, clientConfig.sanity) returns images with a lowered quality. The smaller the image, the worst the compression.

Screen Shot 2020-01-19 at 11 47 58

Expected behavior

When resizing the same image with css instead, the image renders with a good quality (screenshot of the rendered image resized with css): Screen Shot 2020-01-19 at 11 48 11

Question Is there any way to enhance the quality of the images? What else can I do to remedy to this?

Sanity version @sanity/cli 0.147.3 (up to date)

laurage avatar Jan 19 '20 12:01 laurage

I too am having this problem. Any updates on this?

leevi978 avatar Aug 31 '20 10:08 leevi978

I have noticed this too; there is a configuration in gatsby-config.(js|ts) that may help, I have it set to the following:

{
  resolve: `gatsby-plugin-sharp`,
  options: {
    defaults: {
      formats: [`auto`, `webp`],
      placeholder: `none`,
      quality: 50,
      breakpoints: [640, 800, 1200, 1920],
    },
  },
},

Increasing the quality value may help, but will also increase image file size and slow down your page loads (depends on the priority of your project, quality vs. speed).

jfgilmore avatar Apr 04 '22 02:04 jfgilmore

@jfgilmore I don't think that images from Sanity ever go through sharp. They are served via the Sanity image pipeline as far as I understand.

Hahlh avatar Apr 17 '23 18:04 Hahlh