An image loader module for nuxt.js that allows you to configure image style derivatives.
The Nuxt Image Loader module is a powerful tool that allows users to automatically resize, rotate, blur, watermark, and crop images based on defined rules. By intercepting image requests on the server side, the module can respond with the original image or a processed image if a query string is appended to the image URL. This module works for all Nuxt deployment modes and uses the GraphicsMagick for node package for image processing capabilities.
<nuxt-img> component, making it easy to display different versions of an image based on device size.To install the Nuxt Image Loader module, follow these steps:
graphicsmagick package is installed on the same host system or container where your application lives.npm install nuxt-image-loader.Next, in your nuxt.config.js file, include the following configuration:
{
modules: [
'nuxt-image-loader'
],
... // Other configurations
}
In the same nuxt.config.js file, you can define the image processing settings by adding the imageStyles option. For example:
{
imageStyles: {
thumbnail: {
actions: ['resize|100|100', 'crop|50|50'],
macros: ['scaleAndCrop'],
responsiveStyles: {
small: {
srcset: 'thumbnail'
},
medium: {
srcset: 'thumbnail',
sizes: '50vw'
}
}
}
},
... // Other configurations
}
The Nuxt Image Loader module is a powerful tool that simplifies image processing and handling in Nuxt applications. By defining custom image styles and utilizing the GraphicsMagick package, users can automatically resize, rotate, blur, watermark, and crop images based on defined rules. The module seamlessly works with all Nuxt deployment modes and provides support for responsive image handling.