OptiPNG is a PNG optimizer that recompresses image files to a smaller size, without losing any information
You probably want imagemin-optipng
instead.
npm install --save optipng-bin
import {execFile} from 'node:child_process';
import optipng from 'optipng-bin';
execFile(optipng, ['-out', 'output.png', 'input.png'], error => {
console.log('Image minified!');
});
npm install --global optipng-bin
optipng --help