Skip to content

Latest commit

 

History

History
72 lines (58 loc) · 3.27 KB

README.en.md

File metadata and controls

72 lines (58 loc) · 3.27 KB

Used to quickly generate Chinese book covers

License

Installation

! Please install before use node-canvas

  $ npm install generator-cover --save
   or
  $ yarn add generator-cover
   or
  $ cnpm install generator-cover --save

Docs

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

Examples

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

License

MIT

Copyright (c) 2019-present, ibyli