The quality of the optimized image, an integer between `1` and `100`, where `100` is the best quality and therefore largest file size. Defaults to `75`.
The quality of the optimized image, an integer between `1` and `100`, where `100` is the best quality and therefore largest file size. Defaults to `75`.
If the [`qualities`](#qualities) configuration is defined in `next.config.js`, the `quality` prop must match one of the values defined in the configuration.
> **Good to know**: If the original source image was already low quality, setting the quality prop too high could cause the resulting optimized image to be larger than the original source image.
### `priority`
### `priority`
```js
```js
...
@@ -672,6 +676,20 @@ module.exports = {
...
@@ -672,6 +676,20 @@ module.exports = {
}
}
```
```
### `qualities`
The default [Image Optimization API](#loader) will automatically allow all qualities from 1 to 100. If you wish to restrict the allowed qualities, you can add configuration to `next.config.js`.
```js filename="next.config.js"
module.exports = {
images: {
qualities: [25, 50, 75],
},
}
```
In this example above, only three qualities are allowed: 25, 50, and 75. If the [`quality`](#quality) prop does not match a value in this array, the image will fail with 400 Bad Request.
### `formats`
### `formats`
The default [Image Optimization API](#loader) will automatically detect the browser's supported image formats via the request's `Accept` header.
The default [Image Optimization API](#loader) will automatically detect the browser's supported image formats via the request's `Accept` header.
One of your pages that leverages the `next/image` component, passed a `quality` value that isn't defined in the `images.qualities` property in `next.config.js`.
## Possible Ways to Fix It
Add an entry to `images.qualities` array in `next.config.js` with the expected value. For example: