我在代码中发现你可以指定
canvas
clipperOptions
在配置中。
试试这个:
var imageToSlices = require('image-to-slices');
var lineXArray = [100, 200];
var lineYArray = [100, 200];
var source = './public/images/Bitmap001.png'; // width: 300, height: 300
imageToSlices(source, lineXArray, lineYArray, {
saveToDir: '.',
clipperOptions: {
canvas: require('canvas')
}
}, function() {
console.log('the source image has been sliced into 9 sections!');
});