https://github.com/luoxuhai/generator-cover
中文图书封面生成器 Chinese book cover generator
https://github.com/luoxuhai/generator-cover
image javascript nodejs npm-module
Last synced: 6 months ago
JSON representation
中文图书封面生成器 Chinese book cover generator
- Host: GitHub
- URL: https://github.com/luoxuhai/generator-cover
- Owner: luoxuhai
- License: mit
- Created: 2019-09-04T13:55:03.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-10-25T13:26:26.000Z (over 5 years ago)
- Last Synced: 2025-12-25T16:26:13.546Z (6 months ago)
- Topics: image, javascript, nodejs, npm-module
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/generator-cover
- Size: 591 KB
- Stars: 28
- Watchers: 1
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.en.md
- License: LICENSE
Awesome Lists containing this project
README
- English
- [简体中文](https://github.com/ibyli/generator-cover/blob/master/README.md)
**Used to quickly generate Chinese book covers**
## Installation
**! Please install before use [ node-canvas](https://github.com/Automattic/node-canvas)**
```c
$ 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
```javascript
'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](https://github.com/ibyli/generator-cover/blob/master/LICENSE)
Copyright (c) 2019-present, [ibyli](https://github.com/ibyli/)