egg-szjcomo-image

1.0.0 • Public • Published

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;
})()
 

更多用法请参数canvas库

Package Sidebar

Install

npm i egg-szjcomo-image

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

6.21 kB

Total Files

6

Last publish

Collaborators

  • como20170606