Comparing version 0.13.1 to 0.14.0
{ | ||
"name": "impro", | ||
"version": "0.13.1", | ||
"version": "0.14.0", | ||
"description": "Image processing engine", | ||
@@ -21,6 +21,7 @@ "author": "Andreas Lind <andreaslindpetersen@gmail.com>", | ||
"coverage": "nyc --reporter=lcov --reporter=text -- npm test && echo Coverage Report written to coverage/lcov-report/index.html", | ||
"docs": "evaldown --inplace README.md", | ||
"test": "mocha", | ||
"lint": "eslint . && prettier --check '**/*.{js,json,md}'", | ||
"clean": "rm -rf lib coverage .nyc_output", | ||
"version": "offline-github-changelog --next=${npm_new_version} > CHANGELOG.md && git add CHANGELOG.md" | ||
"version": "npm run docs && git add README.md && offline-github-changelog --next=${npm_package_version} > CHANGELOG.md && git add CHANGELOG.md" | ||
}, | ||
@@ -38,5 +39,7 @@ "devDependencies": { | ||
"eslint-plugin-standard": "^5.0.0", | ||
"evaldown": "^2.0.0", | ||
"file-type": "^12.3.0", | ||
"gifsicle-stream": "1.0.0", | ||
"gifsicle": "^5.3.0", | ||
"gm-papandreou": "1.23.0-patch1", | ||
"impro": "file:./", | ||
"inkscape": "3.0.0", | ||
@@ -48,7 +51,7 @@ "jpegtran": "2.0.0", | ||
"offline-github-changelog": "^1.7.0", | ||
"optipng": "2.1.0", | ||
"optipng": "^4.0.0", | ||
"pngcrush": "^3.0.0", | ||
"pngquant": "3.0.0", | ||
"pngquant": "^4.0.0", | ||
"prettier": "~2.2.1", | ||
"sharp": "~0.30.0", | ||
"sharp": "~0.32.0", | ||
"sinon": "^9.2.4", | ||
@@ -58,11 +61,9 @@ "svgfilter": "4.1.0", | ||
"unexpected-dom": "^5.0.0", | ||
"unexpected-resemble": "^5.0.0", | ||
"unexpected-sinon": "^11.0.1" | ||
}, | ||
"dependencies": { | ||
"createerror": "1.1.0", | ||
"exif-reader": "^1.0.3", | ||
"icc": "^1.0.0", | ||
"mime": "^2.5.2" | ||
"icc": "^3.0.0", | ||
"mime": "^3.0.0" | ||
} | ||
} |
@@ -12,15 +12,39 @@ # Impro | ||
Support for the following libraries is included: | ||
This library supports and is tested against node version **14** and above and | ||
includes support for the following image conversion tools: | ||
<!-- evaldown hide:true,console:true --> | ||
```js | ||
const pkg = require('./package.json'); | ||
const engineLibs = Object.keys(require('./src/engines')).filter( | ||
(name) => name !== 'metadata' | ||
); | ||
const engineNameToDepName = { | ||
gm: 'gm-papandreou', | ||
}; | ||
for (const engineLib of engineLibs) { | ||
const depName = engineNameToDepName[engineLib] || engineLib; | ||
let depVersion = pkg.devDependencies[depName]; | ||
if (!/^[~^]/.test(depVersion)) depVersion = `^${depVersion}`; | ||
console.log(`- ${engineLib} (npm install ${depName}@${depVersion})`); | ||
} | ||
``` | ||
- Gifsicle (npm install gifsicle-stream@^1.0.0) | ||
- GraphicsMagick (npm install gm-papandreou@^1.23.0-patch1) | ||
- Inkscape (npm install inkscape@^3.0.0) | ||
- JpegTran (npm install jpegtran@^2.0.0) | ||
- OptiPNG (npm install optipng@^2.1.0) | ||
- Pngcrush (npm install pngcrush@^2.0.1) | ||
- Pngquant (npm install pngquant@^3.0.0) | ||
- Sharp (npm install sharp@~0.30.0) | ||
- SvgFilter (npm install svgfilter@^4.1.0) | ||
<!-- evaldown output:true --> | ||
``` | ||
- gifsicle (npm install gifsicle@^5.3.0) | ||
- gm (npm install gm-papandreou@^1.23.0-patch1) | ||
- inkscape (npm install inkscape@^3.0.0) | ||
- jpegtran (npm install jpegtran@^2.0.0) | ||
- optipng (npm install optipng@^4.0.0) | ||
- pngcrush (npm install pngcrush@^3.0.0) | ||
- pngquant (npm install pngquant@^4.0.0) | ||
- sharp (npm install sharp@~0.32.0) | ||
- svgfilter (npm install svgfilter@^4.1.0) | ||
``` | ||
@@ -105,2 +129,4 @@ > callers must install the libraries and if present they will be enabled | ||
```js | ||
const impro = require('impro'); | ||
impro | ||
@@ -129,2 +155,4 @@ .createPipeline({ type: 'png' }) | ||
```js | ||
const impro = require('impro'); | ||
const pipeline = impro.createPipeline({ type: 'png' }, [ | ||
@@ -131,0 +159,0 @@ { name: 'grayscale', args: [] }, |
const errors = require('../errors'); | ||
const requireOr = require('../requireOr'); | ||
const StdinoutStream = require('../StdinoutStream'); | ||
const { requireOr } = require('../requireOr'); | ||
const { whichSyncSafe } = require('../which'); | ||
const Gifsicle = requireOr('gifsicle-stream'); | ||
function findBinary() { | ||
let binary; | ||
if ((binary = requireOr('gifsicle', null))) return binary; | ||
if ((binary = whichSyncSafe('gifsicle'))) return binary; | ||
return null; | ||
} | ||
@@ -10,2 +17,3 @@ function isNumberWithin(num, min, max) { | ||
const defaultBinPath = findBinary(); | ||
const maxDimension = 16384; | ||
@@ -15,3 +23,3 @@ | ||
name: 'gifsicle', | ||
unavailable: !Gifsicle, | ||
unavailable: defaultBinPath === null, | ||
operations: [ | ||
@@ -67,12 +75,13 @@ 'crop', | ||
const allGifsicleArgs = []; | ||
let gifsicleArgs = []; | ||
const binPath = module.exports._binPath; | ||
let args = []; | ||
let seenOperationThatMustComeBeforeExtract = false; | ||
function flush() { | ||
if (gifsicleArgs.length > 0) { | ||
pipeline._attach(new Gifsicle(gifsicleArgs)); | ||
if (args.length > 0) { | ||
pipeline._attach(new StdinoutStream('gifsicle', binPath, args)); | ||
seenOperationThatMustComeBeforeExtract = false; | ||
if (allGifsicleArgs.length > 0) allGifsicleArgs.push(';'); | ||
allGifsicleArgs.push(...gifsicleArgs); | ||
gifsicleArgs = []; | ||
allGifsicleArgs.push(...args); | ||
args = []; | ||
} | ||
@@ -113,3 +122,3 @@ } | ||
if (operation.args[0] !== null && operation.args[1] !== null) { | ||
gifsicleArgs.push( | ||
args.push( | ||
'--resize' + (ignoreAspectRatio ? '' : '-fit'), | ||
@@ -119,5 +128,5 @@ operation.args[0] + 'x' + operation.args[1] | ||
} else if (operation.args[1] === null) { | ||
gifsicleArgs.push('--resize-width', operation.args[0]); | ||
args.push('--resize-width', operation.args[0]); | ||
} else if (operation.args[0] === null) { | ||
gifsicleArgs.push('--resize-height', operation.args[1]); | ||
args.push('--resize-height', operation.args[1]); | ||
} | ||
@@ -128,3 +137,3 @@ } else if (operation.name === 'extract') { | ||
} | ||
gifsicleArgs.push( | ||
args.push( | ||
'--crop', | ||
@@ -143,6 +152,6 @@ operation.args[0] + | ||
) { | ||
gifsicleArgs.push('--rotate-' + operation.args[0]); | ||
args.push('--rotate-' + operation.args[0]); | ||
seenOperationThatMustComeBeforeExtract = true; | ||
} else if (operation.name === 'progressive') { | ||
gifsicleArgs.push('--interlace'); | ||
args.push('--interlace'); | ||
} | ||
@@ -157,2 +166,4 @@ }, this); | ||
}, | ||
_binPath: defaultBinPath, | ||
_findBinary: findBinary, | ||
}; |
@@ -1,5 +0,9 @@ | ||
const createError = require('createerror'); | ||
class OutputDimensionsExceeded extends Error { | ||
constructor(...args) { | ||
super(...args); | ||
this.name = 'OutputDimensionsExceeded'; | ||
this[this.name] = true; // createerror compatiblity | ||
} | ||
} | ||
module.exports = { | ||
OutputDimensionsExceeded: createError({ name: 'OutputDimensionsExceeded' }), | ||
}; | ||
exports.OutputDimensionsExceeded = OutputDimensionsExceeded; |
@@ -1,2 +0,2 @@ | ||
module.exports = function requireOr(id) { | ||
function requireOr(id, defaultValue) { | ||
try { | ||
@@ -8,3 +8,7 @@ return module.parent.require(id); | ||
} | ||
return defaultValue; | ||
} | ||
}; | ||
} | ||
module.exports = requireOr; | ||
module.exports.requireOr = requireOr; |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
96149
3
26
2086
168
31
2
+ Addedicc@3.0.0(transitive)
+ Addedmime@3.0.0(transitive)
- Removedcreateerror@1.1.0
- Removedcreateerror@1.1.0(transitive)
- Removedicc@1.0.0(transitive)
- Removedmime@2.6.0(transitive)
Updatedicc@^3.0.0
Updatedmime@^3.0.0