You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Defaults used for gatsbyImageData and StaticImage
36
+
defaults: {},
37
+
// Relates to "options.failOn" in https://sharp.pixelplumbing.com/api-constructor#parameters
38
+
failOn:`warning`,
39
+
},
45
40
},
46
-
},
47
-
]
41
+
]
42
+
}
48
43
```
49
44
50
45
## Options
51
46
52
-
-`defaults`: default values used for `gatsbyImageData` and `StaticImage` from [gatsby-plugin-image](https://www.gatsbyjs.com/plugins/gatsby-plugin-image).
47
+
-`defaults`: Default values used for `gatsbyImageData` and `StaticImage` from [gatsby-plugin-image](https://www.gatsbyjs.com/plugins/gatsby-plugin-image).
53
48
Available options are: `formats`,`placeholder`,`quality`,`breakpoints`,`backgroundColor`,`tracedSVGOptions`,`blurredOptions`,`jpgOptions`,`pngOptions`,`webpOptions`,`avifOptions`.
54
49
For details of these, see [the reference guide](https://www.gatsbyjs.com/docs/reference/built-in-components/gatsby-plugin-image).
55
-
-`failOn`: default = `warning`. By default builds will fail if there is a corrupted image. Set to `none` to continue the build on error. The image will return `undefined`. You can customize this option, see [`options.failOn`](https://sharp.pixelplumbing.com/api-constructor#parameters).
56
-
57
-
Other options are deprecated, and should only be used for the legacy `fixed` and `fluid` functions.
50
+
-`failOn`: default = `warning`. By default, builds will fail if sharp finds an image with corrupted pixel values. When setting `failOn` to `none` the image will return `undefined` instead. You can customize this option, see [`options.failOn`](https://sharp.pixelplumbing.com/api-constructor#parameters). Images with corrupt image headers/metadata will always fail, regardless of this setting.
58
51
59
52
## Methods
60
53
@@ -215,8 +208,8 @@ Rotate the image (after cropping). See Sharp's [rotate][7].
215
208
216
209
#### grayscale
217
210
218
-
Uses Sharp's [greyscale][8] to convert the source image to 8-bit greyscale, 256
219
-
shades of grey, e.g.
211
+
Uses Sharp's [grayscale][8] to convert the source image to 8-bit grayscale, 256
212
+
shades of gray, e.g.
220
213
221
214
```graphql
222
215
allImageSharp {
@@ -287,67 +280,9 @@ quoting the Sharp documentation:
Generates a traced SVG of the image (see [the original GitHub issue][9]) and
293
-
returns the SVG as "[optimized URL-encoded][10]" `data:` URI. It used in
294
-
[gatsby-image](/plugins/gatsby-image/) to provide an
295
-
alternative to the default inline base64 placeholder image.
296
-
297
-
Uses [node-potrace][11] and [SVGO][12] under the hood. Default settings for
298
-
node-potrace:
299
-
300
-
```javascript
301
-
{
302
-
color:`lightgray`,
303
-
optTolerance:0.4,
304
-
turdSize:100,
305
-
turnPolicy:TURNPOLICY_MAJORITY,
306
-
}
307
-
```
308
-
309
-
All [node-potrace `Potrace` parameters][13] are exposed and can be set via the
310
-
`traceSVG` argument:
311
-
312
-
```javascript
313
-
fixed(
314
-
traceSVG: {
315
-
color:"#f00e2e"
316
-
turnPolicy:TURNPOLICY_MINORITY
317
-
blackOnWhite:false
318
-
}
319
-
) {
320
-
src
321
-
srcSet
322
-
tracedSVG
323
-
}
324
-
```
325
-
326
-
### Setting a default quality
327
-
328
-
You can pass a default image quality to `sharp` by setting the `defaultQuality` option.
329
-
330
-
### Using MozJPEG
331
-
332
-
You can opt-in to use [MozJPEG][16] for jpeg-encoding. MozJPEG provides even
333
-
better image compression than the default encoder used in `gatsby-plugin-sharp`.
334
-
However, when using MozJPEG the build time of your Gatsby project will increase
335
-
significantly.
336
-
337
-
To enable MozJPEG, you can set the `useMozJpeg` plugin option to `true` in
338
-
`gatsby-config.js`.
339
-
340
-
For backwards compatible reasons, if `useMozJpeg` is not defined in the plugin
341
-
options, the [environment variable](/docs/environment-variables/#environment-variables)
342
-
`GATSBY_JPEG_ENCODER` acts as a fallback if set to `MOZJPEG`:
343
-
344
-
```shell
345
-
GATSBY_JPEG_ENCODER=MOZJPEG
346
-
```
347
-
348
-
### Allow build to continue on image processing error
283
+
### Setting sharp's level of sensitivity to invalid images
349
284
350
-
By default, the build will fail when it encounters an error while processing an image. You can change this so that it continues the build process by setting the plugin option `failOnError`to `false`. Sharp will still throw an error and display it in the console as a GraphQL error, but it will not exit the process. It is important to note that any images that would have otherwise failed will not be accessible via `childImageSharp` until the underlying issue with the image is addressed.
285
+
By default, the build will fail when sharp encounters an error while processing an image. You can change parts of this behavior by changing the `failOn` setting to `none`. In that case sharp will then ignore any errors relating to the pixel values/file structure of your file. However, if your image has corrupt image headers/metadata the build will still fail. It is important to note that any images that would have otherwise failed will not be accessible via `childImageSharp` until the underlying issue with the image is addressed.
0 commit comments