操作手册: https://cloud.tencent.com/developer/section/1116249
https://cloud.tencent.com/developer/article/1524055
https://blog.csdn.net/qq_34149805/article/details/83048055
const path = require('path')
const fs = require('fs');
const nativeImage = require('electron').nativeImage
// var fs = require('fs')
let image = nativeImage.createFromPath('/Users/lys/Desktop/imageSize/icon.jpg')
// image = image.resize({width:100,height:100})
image = image.crop({width:100,height:100,y:0,x:0})
let imageData = image.toPNG()
fs.writeFile(path.resolve('/Users/lys/Desktop/imageSize/logo.png'), imageData, function (err) {
if (err)
return console.log(err);
}
)
网友评论