Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

gatsby-transformer-sharp

gatsbyjs566.6kMIT5.15.0

Gatsby transformer plugin for images using Sharp

gatsby, gatsby-plugin, image, sharp

readme

gatsby-transformer-sharp

Creates ImageSharp nodes from image types that are supported by the Sharp image processing library and provides fields in their GraphQL types for processing your images in a variety of ways including resizing, cropping, and creating responsive images.

Live demo (source)

Install

npm install gatsby-transformer-sharp gatsby-plugin-sharp

How to use

// In your gatsby-config.js
module.exports = {
  plugins: [`gatsby-plugin-sharp`, `gatsby-transformer-sharp`],
}

Please note that you must have a source plugin (which brings in images) installed in your project. Otherwise, no ImageSharp nodes can be created for your files. Examples would be gatsby-source-filesystem or source plugins for (headless) CMSs like gatsby-source-wordpress.

Note: An exception to this is when using gatsby-source-contentful, as the source plugin and the assets are not downloaded to the local filesystem. By default, the gatsby-source-contentful plugin creates a ContentfulAsset node for every image with links to Contentful’s CDN, therefore it is not necessary to use gatsby-transformer-sharp together with gatsby-source-contentful.

Parsing algorithm

It recognizes files with the following extensions as images.

  • jpeg
  • jpg
  • png
  • webp
  • tif
  • tiff

Each image file is parsed into a node of type ImageSharp.

Configuration options

checkSupportedExtensions [boolean][optional]

Sharp only supports certain image formats (see the Parsing algorithm section above) and hence throws a warning when you e.g. use a .gif in an ImageSharp query. You'll need to use publicURL instead. With this option you can disable the warning behavior.

// In your gatsby-config.js
module.exports = {
  plugins: [
    `gatsby-plugin-sharp`,
    {
      resolve: `gatsby-transformer-sharp`,
      options: {
        // The option defaults to true
        checkSupportedExtensions: false,
      },
    },
  ],
}

Troubleshooting

Incompatible library version: sharp.node requires version X or later, but Z provides version Y

This means that there are multiple incompatible versions of the sharp package installed in node_modules. The complete error typically looks like this:

Something went wrong installing the "sharp" module

dlopen(/Users/misiek/dev/gatsby-starter-blog/node_modules/sharp/build/Release/sharp.node, 1): Library not loaded: @rpath/libglib-2.0.dylib
  Referenced from: /Users/misiek/dev/gatsby-starter-blog/node_modules/sharp/build/Release/sharp.node
  Reason: Incompatible library version: sharp.node requires version 6001.0.0 or later, but libglib-2.0.dylib provides version 5801.0.0

To fix this, you'll need to update all Gatsby plugins in the current project that depend on the sharp package. Here's a list of official plugins that you might need to update in case your projects uses them:

  • gatsby-plugin-sharp
  • gatsby-plugin-manifest
  • gatsby-remark-images-contentful
  • gatsby-source-contentful
  • gatsby-transformer-sharp
  • gatsby-transformer-sqip

To update these packages, run:

npm install gatsby-plugin-sharp gatsby-plugin-manifest gatsby-remark-images-contentful gatsby-source-contentful gatsby-transformer-sharp gatsby-transformer-sqip

If updating these doesn't fix the issue, your project probably uses other plugins from the community that depend on a different version of sharp. Try running npm list sharp or yarn why sharp to see all packages in the current project that use sharp and try updating them as well.

changelog

Changelog: gatsby-transformer-sharp

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

5.14.0 (2024-11-06)

🧾 Release notes

Bug Fixes

5.13.1 (2024-01-23)

Note: Version bump only for package gatsby-transformer-sharp

5.13.0 (2023-12-18)

🧾 Release notes

Chores

5.12.3 (2023-10-26)

Note: Version bump only for package gatsby-transformer-sharp

5.12.2 (2023-10-20)

Note: Version bump only for package gatsby-transformer-sharp

5.12.1 (2023-10-09)

Chores

5.12.0 (2023-08-24)

🧾 Release notes

Bug Fixes

5.11.0 (2023-06-15)

🧾 Release notes

Chores

5.10.0 (2023-05-16)

🧾 Release notes

Bug Fixes

5.9.0 (2023-04-18)

🧾 Release notes

Bug Fixes

5.8.0 (2023-03-21)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

5.7.0 (2023-02-21)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

5.6.0 (2023-02-07)

🧾 Release notes

Bug Fixes

Chores

5.5.0 (2023-01-24)

🧾 Release notes

Chores

5.4.0 (2023-01-10)

🧾 Release notes

Bug Fixes

Chores

5.3.1 (2022-12-14)

Note: Version bump only for package gatsby-transformer-sharp

5.3.0 (2022-12-13)

🧾 Release notes

Features

Chores

5.2.0 (2022-11-25)

🧾 Release notes

Chores

5.1.0 (2022-11-22)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

5.0.0 (2022-11-08)

🧾 Release notes

Chores

4.24.0 (2022-09-27)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

4.23.1 (2022-09-22)

Note: Version bump only for package gatsby-transformer-sharp

4.23.0 (2022-09-13)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

4.22.0 (2022-08-30)

🧾 Release notes

Chores

4.21.0 (2022-08-16)

🧾 Release notes

Chores

4.20.0 (2022-08-02)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

4.19.0 (2022-07-19)

🧾 Release notes

Chores

  • Update READMEs for better instructions (0890a5c)

4.18.1 (2022-07-12)

Note: Version bump only for package gatsby-transformer-sharp

4.18.0 (2022-07-05)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

4.17.0 (2022-06-21)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

4.16.0 (2022-06-07)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

4.15.1 (2022-06-01)

Note: Version bump only for package gatsby-transformer-sharp

4.15.0 (2022-05-24)

🧾 Release notes

Bug Fixes

  • Throw Typegen errors & add IGatsbyImageData to output #35683 (e7fc88b)

4.14.0 (2022-05-10)

🧾 Release notes

Bug Fixes

4.13.0 (2022-04-26)

🧾 Release notes

Features

4.12.1 (2022-04-13)

Note: Version bump only for package gatsby-transformer-sharp

4.12.0 (2022-04-12)

🧾 Release notes

Bug Fixes

  • update dependency probe-image-size to ^7.2.3 for gatsby-transformer-sharp #35290 (5d1a5e5)

Chores

4.11.0 (2022-03-29)

🧾 Release notes

Chores

  • replace all uses of gatsbyjs.org with gatsbyjs.com #35101 (16cff41)

4.10.0 (2022-03-16)

🧾 Release notes

Bug Fixes

  • Upgrade probe-image-size to fix memory leak warning fix #35009 (f98c9ba)

4.9.0 (2022-03-01)

🧾 Release notes

Chores

4.8.0 (2022-02-22)

🧾 Release notes

Bug Fixes

4.7.0 (2022-02-08)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

4.6.0 (2022-01-25)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

4.5.0 (2022-01-11)

🧾 Release notes

Chores

4.4.0 (2021-12-14)

🧾 Release notes

Bug Fixes

  • update dependency common-tags to ^1.8.2 for gatsby-transformer-sharp #34127 (f495563)

Chores

4.3.0 (2021-12-01)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

4.2.0 (2021-11-16)

🧾 Release notes

Bug Fixes

4.1.0 (2021-11-02)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

4.0.0 (2021-10-21)

🧾 Release notes

Chores

3.14.0 (2021-09-18)

🧾 Release notes

Chores

3.13.0 (2021-09-01)

🧾 Release notes

Features

Chores

3.12.0 (2021-08-18)

🧾 Release notes

Bug Fixes

  • update dependency semver to ^7.3.5 for gatsby-transformer-sharp #32591 (b428ae9)

Chores

3.11.0 (2021-08-04)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

3.10.0 (2021-07-20)

🧾 Release notes

Chores

3.9.0 (2021-07-07)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

3.8.0 (2021-06-23)

🧾 Release notes

Chores

3.7.1 (2021-06-10)

Chores

3.7.0 (2021-06-09)

🧾 Release notes

Chores

3.6.0 (2021-05-25)

🧾 Release notes

Bug Fixes

3.5.0 (2021-05-12)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

3.4.0 (2021-04-28)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

3.3.0 (2021-04-14)

🧾 Release notes

Chores

3.2.0 (2021-03-30)

🧾 Release notes

Note: Version bump only for package gatsby-transformer-sharp

3.1.0 (2021-03-16)

🧾 Release notes

Chores

Other Changes

3.0.0 (2021-03-02)

🧾 Release notes

Bug Fixes

Chores

Other Changes

2.12.1 (2021-03-08)

Other Changes

2.12.0 (2021-02-02)

🧾 Release notes

Features

Chores

  • update minor and patch for gatsby-transformer-sharp #28969 (4cf7b43)

2.11.0 (2021-01-20)

🧾 Release notes

Features

Bug Fixes

  • update vulnerable packages, include React 17 in peerDeps #28545 (18b5f30)
  • PathPrefix isn't being passed/set for GatsbyImage fix #28845 (5874414)

Chores

2.10.1 (2021-01-13)

Bug Fixes

2.10.0 (2021-01-06)

🧾 Release notes

Features

  • Add AVIF image support to beta image plugin #28742 (2058775)
  • Make dimensions optional and default to constrained #28662 (f24a23d)

Bug Fixes

  • update minor and patch for gatsby-transformer-sharp #28510 (b712950)

2.9.0 (2020-12-15)

🧾 Release notes

Chores

2.8.0 (2020-12-02)

🧾 Release notes

Chores

  • update minor and patch for gatsby-transformer-sharp #27158 (4c148f0)

2.7.0 (2020-11-20)

🧾 Release notes

Bug Fixes

Chores

2.6.0 (2020-11-12)

🧾 Release notes

Features

Bug Fixes

2.5.21 (2020-11-02)

Features

2.5.20 (2020-10-26)

Bug Fixes

  • gatsby-source-filesystem,gatsby-transformer-sharp: Use custom errors (#27576) (752e27a)

2.5.19 (2020-10-20)

Performance Improvements

  • implement shouldOnCreateNode for all our plugins/benchmarks (#27545) (df914d9)

2.5.18 (2020-10-16)

Performance Improvements

  • gatsby: test sync before calling onCreateNode (#27442) (6400383)

2.5.17 (2020-10-06)

Note: Version bump only for package gatsby-transformer-sharp

2.5.16 (2020-09-28)

Note: Version bump only for package gatsby-transformer-sharp

2.5.15 (2020-09-15)

Note: Version bump only for package gatsby-transformer-sharp

2.5.14 (2020-08-31)

Note: Version bump only for package gatsby-transformer-sharp

2.5.13 (2020-08-11)

Note: Version bump only for package gatsby-transformer-sharp

2.5.12 (2020-07-30)

Note: Version bump only for package gatsby-transformer-sharp

2.5.11 (2020-07-09)

Note: Version bump only for package gatsby-transformer-sharp

2.5.10 (2020-07-02)

Note: Version bump only for package gatsby-transformer-sharp

2.5.9 (2020-07-01)

Note: Version bump only for package gatsby-transformer-sharp

2.5.8 (2020-07-01)

Note: Version bump only for package gatsby-transformer-sharp

2.5.7 (2020-06-24)

Note: Version bump only for package gatsby-transformer-sharp

2.5.6 (2020-06-22)

Note: Version bump only for package gatsby-transformer-sharp

2.5.5 (2020-06-09)

Note: Version bump only for package gatsby-transformer-sharp

2.5.4 (2020-06-02)

Note: Version bump only for package gatsby-transformer-sharp

2.5.3 (2020-05-20)

Note: Version bump only for package gatsby-transformer-sharp

2.5.2 (2020-05-07)

Bug Fixes

  • gatsby-image: Fix fluid not respecting maxWidth/maxHeight (#17006) (ad7cd6b)

2.5.1 (2020-05-05)

Note: Version bump only for package gatsby-transformer-sharp

2.5.0 (2020-04-27)

Note: Version bump only for package gatsby-transformer-sharp

2.4.7 (2020-04-24)

Note: Version bump only for package gatsby-transformer-sharp

2.4.6 (2020-04-17)

Bug Fixes

2.4.5 (2020-04-16)

Note: Version bump only for package gatsby-transformer-sharp

2.4.4 (2020-04-04)

Bug Fixes

2.4.3 (2020-03-27)

Bug Fixes

  • gatsby-transformer-sharp: Add checkSupportedExtensions… (#22565) (91e7bfb)

2.4.2 (2020-03-23)

Note: Version bump only for package gatsby-transformer-sharp

2.4.1 (2020-03-20)

Note: Version bump only for package gatsby-transformer-sharp

2.4.0 (2020-03-20)

Features

2.3.19 (2020-03-16)

Note: Version bump only for package gatsby-transformer-sharp

2.3.18 (2020-03-10)

Features

2.3.17 (2020-03-06)

Note: Version bump only for package gatsby-transformer-sharp

2.3.16 (2020-02-27)

Note: Version bump only for package gatsby-transformer-sharp

2.3.15 (2020-02-26)

Bug Fixes

  • gatsby-transformer-sharp: Warn when using unsupported ext… (#20782) (4519c05)

2.3.14 (2020-02-01)

Note: Version bump only for package gatsby-transformer-sharp

2.3.13 (2020-01-17)

Bug Fixes

  • gatsby-transformer-sharp: prevent duplicate copy of the same file (#20620) (93f0645)

2.3.12 (2020-01-09)

Note: Version bump only for package gatsby-transformer-sharp

2.3.11 (2020-01-09)

Bug Fixes

  • gatsby-transformer-sharp: define required image fields as non-null in schema (#20314) (e3026c9)

2.3.10 (2020-01-09)

Bug Fixes

  • gatsby-transformer-sharp: define required image fields as non-null in schema (#20314) (e3026c9)

2.3.9 (2019-12-10)

Note: Version bump only for package gatsby-transformer-sharp

2.3.8 (2019-12-10)

Note: Version bump only for package gatsby-transformer-sharp

2.3.7 (2019-12-05)

Note: Version bump only for package gatsby-transformer-sharp

2.3.6 (2019-11-26)

Note: Version bump only for package gatsby-transformer-sharp

2.3.5 (2019-11-15)

Note: Version bump only for package gatsby-transformer-sharp

2.3.4 (2019-11-13)

Bug Fixes

  • gatsby-transformer-sharp: explicitly register enum types (#19343) (fdc7ccd)

2.3.3 (2019-11-10)

Note: Version bump only for package gatsby-transformer-sharp

2.3.2 (2019-10-29)

Bug Fixes

2.3.1 (2019-10-28)

Bug Fixes

2.3.0 (2019-10-21)

Note: Version bump only for package gatsby-transformer-sharp

2.2.23 (2019-10-14)

Note: Version bump only for package gatsby-transformer-sharp

2.2.22 (2019-10-14)

Note: Version bump only for package gatsby-transformer-sharp

2.2.21 (2019-10-09)

Note: Version bump only for package gatsby-transformer-sharp

2.2.20 (2019-10-04)

Bug Fixes

2.2.19 (2019-09-26)

Bug Fixes

2.2.18 (2019-09-26)

Bug Fixes

2.2.17 (2019-09-24)

Note: Version bump only for package gatsby-transformer-sharp

2.2.16 (2019-09-20)

Note: Version bump only for package gatsby-transformer-sharp

2.2.15 (2019-09-18)

Note: Version bump only for package gatsby-transformer-sharp

2.2.14 (2019-09-09)

Note: Version bump only for package gatsby-transformer-sharp

2.2.13 (2019-09-01)

Bug Fixes

  • update minor updates in packages except react, babel and eslint (#17254) (252d867)

2.2.12 (2019-08-24)

Bug Fixes

2.2.11 (2019-08-23)

Note: Version bump only for package gatsby-transformer-sharp

2.2.10 (2019-08-22)

Note: Version bump only for package gatsby-transformer-sharp

2.2.9 (2019-08-22)

Note: Version bump only for package gatsby-transformer-sharp

2.2.8 (2019-08-21)

Bug Fixes

2.2.7 (2019-08-20)

Note: Version bump only for package gatsby-transformer-sharp

2.2.6 (2019-08-08)

Bug Fixes

  • docs: add note for exception when using gatsby-source-con… (#15926) (810174d)

2.2.5 (2019-07-29)

Features

  • gatsby-transformer-sharp: ImageSharp as child of File type(#16109) (272d22f)

2.2.4 (2019-07-17)

Bug Fixes

  • gatsby-transformer-sharp: mark highlight/shadow duotone args as required (#15829) (f838d00)

2.2.3 (2019-07-12)

Bug Fixes

2.2.2 (2019-07-11)

Note: Version bump only for package gatsby-transformer-sharp

2.2.1 (2019-07-02)

Features

  • gatsby-transformer-sharp: Add default types for ImageSha… (#15285) (44580c6)

2.2.0 (2019-06-20)

Note: Version bump only for package gatsby-transformer-sharp

2.1.21 (2019-05-31)

Features

2.1.20 (2019-05-29)

Bug Fixes

  • cache tracedSVG calculations when cache is present (#12044) (c40bc4b)

2.1.19 (2019-05-03)

Note: Version bump only for package gatsby-transformer-sharp

2.1.18 (2019-04-11)

Features

2.1.17 (2019-03-12)

Features

2.1.16 (2019-03-11)

Note: Version bump only for package gatsby-transformer-sharp

2.1.15 (2019-02-28)

Note: Version bump only for package gatsby-transformer-sharp

2.1.14 (2019-02-19)

Features

  • gatsby-plugin-sharp: add defaultQuality option (8af9826)

2.1.13 (2019-01-29)

Note: Version bump only for package gatsby-transformer-sharp

2.1.12 (2019-01-24)

Bug Fixes

  • gatsby-transformer-sharp: Pick extension from file prop (#11166) (0a8b189)

2.1.11 (2019-01-23)

Features

  • gatsby-plugin-sharp: Add support for pngquant speed option (#9563) (b789689)

2.1.10 (2018-12-31)

Note: Version bump only for package gatsby-transformer-sharp

2.1.9 (2018-11-29)

Note: Version bump only for package gatsby-transformer-sharp

2.1.8 (2018-11-06)

Features

2.1.7 (2018-10-29)

Features

2.1.6 (2018-10-29)

Note: Version bump only for package gatsby-transformer-sharp

2.1.5 (2018-10-24)

Note: Version bump only for package gatsby-transformer-sharp

2.1.4 (2018-10-16)

Features

2.1.3 (2018-09-28)

Features

2.1.2 (2018-09-24)

Features

  • gatsby-transformer-sharp: expose sizes argument for fluid query (#8466) (efe95a4)

2.1.1 (2018-09-17)

Note: Version bump only for package gatsby-transformer-sharp

2.1.1-rc.3 (2018-09-07)

Note: Version bump only for package gatsby-transformer-sharp

2.1.1-rc.2 (2018-08-29)

Note: Version bump only for package gatsby-transformer-sharp

2.1.1-rc.1 (2018-08-29)

Note: Version bump only for package gatsby-transformer-sharp

2.1.1-rc.0 (2018-08-21)

Note: Version bump only for package gatsby-transformer-sharp

2.1.1-beta.7 (2018-08-13)

Note: Version bump only for package gatsby-transformer-sharp

2.1.1-beta.6 (2018-07-21)

Note: Version bump only for package gatsby-transformer-sharp

2.1.1-beta.5 (2018-07-17)

Note: Version bump only for package gatsby-transformer-sharp

2.1.1-beta.4 (2018-07-16)

Features

  • sharp: move gatsby-plugin-sharp to peerDependencies (#6487) (4cdd3bf)

2.1.1-beta.3 (2018-06-26)

Note: Version bump only for package gatsby-transformer-sharp

2.1.1-beta.2 (2018-06-20)

Note: Version bump only for package gatsby-transformer-sharp

2.1.1-beta.1 (2018-06-17)

Note: Version bump only for package gatsby-transformer-sharp

2.1.1-beta.0 (2018-06-17)

Note: Version bump only for package gatsby-transformer-sharp