egg-szjcomo-image
v1.0.0
Published
## Install
Downloads
2
Readme
egg-szjcomo-image
Install
$ npm i egg-szjcomo-image --save
Usage
// {app_root}/config/plugin.js
exports.szjimage = {
enable: true,
package: 'egg-szjcomo-image',
};
Configuration
// {app_root}/config/config.default.js
exports.szjimage = {
/**
* [ttf 配置字体文件]
* @type {[type]}
*/
ttf:null,
/**
* [ttfname 字体名称]
* @type {[type]}
*/
ttfname:null
};
// 有一个默认中文字体 szjcomo 黑体
see config/config.default.js for more detail.
Example
(async () => {
//创建一建画布
let canvas = app.szjimage.createCanvas(w,h);
let context = canvas.getContext('2d');
let image = app.szjimage.loadImage(imagepath);
context.drawImage(image,0,0,image.width,image.height);
let buffer = canvas.toBuffer('image/jpeg');
return buffer;
})()