resize-with-sharp-or-jimp
Advanced tools
Comparing version 0.1.4 to 0.1.5
10
index.js
try { | ||
const sharp = require("sharp"); | ||
module.exports = async ({ fromFileName, width, toFileName }) => { | ||
await sharp(fromFileName).resize({ width }).toFile(toFileName); | ||
module.exports = async ({ fromFileName, width, height, toFileName }) => { | ||
await sharp(fromFileName) | ||
.resize(width, height || undefined) | ||
.toFile(toFileName); | ||
}; | ||
} catch (e) { | ||
const Jimp = require("jimp"); | ||
module.exports = async ({ fromFileName, width, toFileName }) => { | ||
module.exports = async ({ fromFileName, width, height, toFileName }) => { | ||
const file = await Jimp.read(fromFileName); | ||
await file.resize(width, Jimp.AUTO).writeAsync(toFileName); | ||
await file.resize(width, height || Jimp.AUTO).writeAsync(toFileName); | ||
}; | ||
} |
{ | ||
"name": "resize-with-sharp-or-jimp", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Resize images with sharp. Switch to the slower jimp if sharp cannot be installed", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
2125
14