optimizationLevel 0 Error in file
thisconnect opened this issue · comments
tcme commented
Hi I am testing and comparing all plugins and I am wondering if this is the correct behavior.
From the readme
optimizationLevel
Type: number
Default: 3
Select an optimization level between 0 and 7.
with optimizationLevel: 0
I got the following error:
{ Error: Error in file: images/imagemin.png
** Processing: /var/folders/vc/g0g62cj15vg3vwyn3pdbp6bc0000gp/T/cce3c2b8-f207-44d9-8190-b364455560ed
Warning: Extraneous data found after IEND
400x400 pixels, 4x8 bits/pixel, RGB+alpha
Recoverable errors found in input. Fixing...
IDAT recoding is necessary, but is disabled by the user.
Error: Can't continue
** Status report
1 file(s) have been processed.
1 error(s) have been encountered.
at ChildProcess.exithandler (child_process.js:202:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:850:16)
at Socket.<anonymous> (internal/child_process.js:323:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:492:12)
killed: false,
code: 1,
signal: null,
cmd: '/Users/me/project/node_modules/optipng-bin/vendor/optipng -strip all -clobber -force -fix -o 0 -out /var/folders/vc/g0g62cj15vg3vwyn3pdbp6bc0000gp/T/401ab274-d280-49f7-b6f3-2f3bd0d558bb /var/folders/vc/g0g62cj15vg3vwyn3pdbp6bc0000gp/T/cce3c2b8-f207-44d9-8190-b364455560ed',
stdout: '',
stderr: '** Processing: /var/folders/vc/g0g62cj15vg3vwyn3pdbp6bc0000gp/T/cce3c2b8-f207-44d9-8190-b364455560ed\nWarning: Extraneous data found after IEND\n400x400 pixels, 4x8 bits/pixel, RGB+alpha\nRecoverable errors found in input. Fixing...\nIDAT recoding is necessary, but is disabled by the user.\nError: Can\'t continue\n\n** Status report\n1 file(s) have been processed.\n1 error(s) have been encountered.\n' }
test
const imagemin = require('imagemin');
const imageminOptipng = require('imagemin-optipng');
imagemin(['images/*.png'], 'build', {
use: [imageminOptipng({
optimizationLevel: 0
})]
})
.then(() => {
console.log('Images optimized');
})
.catch(err => {
console.log(err)
});
Kevin Mårtensson commented
That's how optipng
should work (according to the source code).
tcme commented
perfect and sorry for opening so many issues.
Kevin Mårtensson commented
No problem :).
Alessandro Tagliapietra commented
Maybe you should remove the option with 0? Or is it supposed to return an error?