- English
- 简体中文
Used to quickly generate Chinese book covers
! Please install before use node-canvas
$ npm install generator-cover --save
or
$ yarn add generator-cover
or
$ cnpm install generator-cover --save
attribute | type | default | required | explain |
---|---|---|---|---|
bookName | String | yes | title | |
fontColor | Color | "#FFFFFF" | no | font color(Gradient color is not supported at this time) |
fontStyle | String | '74px "Source Han Serif"' | no | The property uses the same syntax as the CSS font property。 |
bgColor | Color | "#000000" | no | background color(Gradient color is not supported at this time) |
bgImage | local file/remote URL/base64 | no | Background image | |
savePath | Path | __dirname | no | File save path |
fileName | String | Date.now().jpg | no | File save name |
quality | Number | 1 | no | Output quality(0 - 1) |
font | Object | no | Custom font font file name cannot be Chinese | |
width | Number | 470(px) | no | Cover the width |
height | Number | 750(px) | no | Cover the height |
left | Number | 90(px) | no | Left margin of title |
'use strict';
const generatorCover = require('generator-cover');
generatorCover({
bookName: '醒世姻缘传',
fontStyle: '74px "Source Han Serif"',
bgColor: '#BCE3E7',
fontColor: '#4A70A9',
fileName: '醒世姻缘传.png',
savePath: __dirname,
quality: 1,
width: 470,
height: 750,
left: 90
// font: {
// fontPath: 'fontPath',
// family: 'fontFamily'
// },
}).then(res => {
console.log('cover path:', res);
});
Copyright (c) 2019-present, ibyli