rollup-generate-image-sizes
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -25,3 +25,3 @@ 'use strict'; | ||
dir = null, // directory string or strings | ||
size = null, // image size or sizes | ||
size = [1400, 1024, 640, 320], // image size or sizes | ||
inputFormat = ['jpg', 'jpeg', 'png'], // image input formats | ||
@@ -60,2 +60,3 @@ outputFormat = ['jpg'], // image output formats | ||
const imagePathPre = imagePathSplit.slice(0, -1).join('.'); | ||
const imageFormat = imagePathSplit[imagePathSplit.length - 1]; | ||
@@ -70,5 +71,14 @@ // Read the sharp metadata so we know what the input width is. | ||
// Process output format list and dedup | ||
const outputFormats = Array.from(new Set( | ||
arrayify(outputFormat) | ||
// If format is match, we match to the input format | ||
.map((format) => (format === 'match' ? imageFormat : format)) | ||
// If format is jpeg, we map to jpg | ||
.map((format) => (format === 'jpeg' ? 'jpg' : format)), | ||
)); | ||
// Save all of the output images | ||
return Promise.all( | ||
(arrayify(outputFormat)) | ||
(outputFormats) | ||
.map((format) => sharpObj | ||
@@ -75,0 +85,0 @@ .clone() |
@@ -18,3 +18,3 @@ import globby from 'globby'; | ||
dir = null, // directory string or strings | ||
size = null, // image size or sizes | ||
size = [1400, 1024, 640, 320], // image size or sizes | ||
inputFormat = ['jpg', 'jpeg', 'png'], // image input formats | ||
@@ -53,2 +53,3 @@ outputFormat = ['jpg'], // image output formats | ||
const imagePathPre = imagePathSplit.slice(0, -1).join('.'); | ||
const imageFormat = imagePathSplit[imagePathSplit.length - 1]; | ||
@@ -63,5 +64,14 @@ // Read the sharp metadata so we know what the input width is. | ||
// Process output format list and dedup | ||
const outputFormats = Array.from(new Set( | ||
arrayify(outputFormat) | ||
// If format is match, we match to the input format | ||
.map((format) => (format === 'match' ? imageFormat : format)) | ||
// If format is jpeg, we map to jpg | ||
.map((format) => (format === 'jpeg' ? 'jpg' : format)), | ||
)); | ||
// Save all of the output images | ||
return Promise.all( | ||
(arrayify(outputFormat)) | ||
(outputFormats) | ||
.map((format) => sharpObj | ||
@@ -68,0 +78,0 @@ .clone() |
{ | ||
"name": "rollup-generate-image-sizes", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Automatically generate image sizes for use in srcsets.", | ||
@@ -5,0 +5,0 @@ "main": "dist/rollup-generate-image-sizes.cjs.js", |
@@ -37,3 +37,3 @@ # rollup-generate-image-sizes | ||
`size` (required | `int` or `[int]`) An integer or array of integers specifying the width in pixel of our output image. | ||
`size` (default: [1400, 1024, 640, 320] | `int` or `[int]`) An integer or array of integers specifying the width in pixels of our output image. | ||
@@ -44,3 +44,3 @@ `hook` (default: renderStart) [the rollup hook](https://rollupjs.org/guide/en/#build-hooks) that this plugin should use. | ||
`inputFormat` (default: ['jpg', 'jpeg', 'png'] | `string` or `[string]`): The file extensions of the images we care about. Must be a format supported by [sharp](https://sharp.pixelplumbing.com/api-output#toformat). | ||
`inputFormat` (default: ['jpg', 'jpeg', 'png'] | `string` or `[string]`): The file extensions of the images we care about. Must be a format supported by [sharp](https://sharp.pixelplumbing.com/api-output#toformat), or `match`, which matches the input format of the image. | ||
@@ -47,0 +47,0 @@ `outputFormat` (default: 'jpg' | `string` or `[string]`): The file extensions of the images we want to output. Must be a format supported by [sharp](https://sharp.pixelplumbing.com/api-output#toformat). |
@@ -18,3 +18,3 @@ import globby from 'globby'; | ||
dir = null, // directory string or strings | ||
size = null, // image size or sizes | ||
size = [1400, 1024, 640, 320], // image size or sizes | ||
inputFormat = ['jpg', 'jpeg', 'png'], // image input formats | ||
@@ -53,2 +53,3 @@ outputFormat = ['jpg'], // image output formats | ||
const imagePathPre = imagePathSplit.slice(0, -1).join('.'); | ||
const imageFormat = imagePathSplit[imagePathSplit.length - 1]; | ||
@@ -63,5 +64,14 @@ // Read the sharp metadata so we know what the input width is. | ||
// Process output format list and dedup | ||
const outputFormats = Array.from(new Set( | ||
arrayify(outputFormat) | ||
// If format is match, we match to the input format | ||
.map((format) => (format === 'match' ? imageFormat : format)) | ||
// If format is jpeg, we map to jpg | ||
.map((format) => (format === 'jpeg' ? 'jpg' : format)), | ||
)); | ||
// Save all of the output images | ||
return Promise.all( | ||
(arrayify(outputFormat)) | ||
(outputFormats) | ||
.map((format) => sharpObj | ||
@@ -68,0 +78,0 @@ .clone() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14894
234