Electron

Electron 对图片的一些操作

2019-11-06  本文已影响0人  寺西创客

操作手册: 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);

  }

)

上一篇下一篇

猜你喜欢

热点阅读