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

Add image processing options #1768

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions docusaurus/docs/dev-docs/plugins/upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,66 @@ export default ({ env }) => ({
Breakpoint changes will only apply to new images, existing images will not be resized or have new sizes generated.
:::

### Image processing options

When the _Enable size optimization (without quality loss)_ setting is enabled in the settings panel, the plugin will generate images using [sharp](https://sharp.pixelplumbing.com/). The [default format options](https://sharp.pixelplumbing.com/api-output) can be overridden in `./config/plugins.js`:

<Tabs groupId="js-ts">

<TabItem value="javascript" label="JAVASCRIPT">

```js title="path: ./config/plugins.js"

module.exports = ({ env }) => ({
upload: {
config: {
formats: {
jpeg: {
chromaSubsampling: '4:4:4',
quality: 95
},
png: {
compressionLevel: 9,
progressive: true
}
}
}
},
});
```

</TabItem>

<TabItem value="typescript" label="TYPESCRIPT">

```js title="path: ./config/plugins.ts"

export default ({ env }) => ({
upload: {
config: {
formats: {
jpeg: {
chromaSubsampling: '4:4:4',
quality: 95
},
png: {
compressionLevel: 9,
progressive: true
}
}
}
},
});
```

</TabItem>

</Tabs>

:::caution
Format changes will only apply to new images, existing images will not be reprocessed.
:::

## Endpoints

<style lang="stylus">
Expand Down