# README
Cogen is an automatic article cover generation tool, which can generate article covers according to requirements after configuring relevant options.
Installation
To install this package, you need to install Go and set your Go workspace first.
- You first need Go installed, then you can use the below Go command to install Cogen.
go get -u github.com/LgoLgo/cogen
- Import it in your code:
import "github.com/LgoLgo/cogen"
Example
package main
import "github.com/LgoLgo/cogen"
func main() {
cogen.CoverGen(
cogen.WithTitle("How to generate an article cover by golang"),
cogen.WithImagePath("example/gopher.png"),
cogen.WithFontFilePath("font/zads.ttf"),
cogen.WithFontRGB([]int{0, 0, 0}),
cogen.WithCoverRGB([]int{250, 235, 215}),
cogen.WithFontSize(100),
)
}
Output
Options
Option | Default | Description |
---|---|---|
Title | LgoLgo | Title sets article title. |
SavingFileName | LgoLgo | SavingFileName sets file name. |
FontFilePath | font/syqh.ttf | FontFilePath sets font file path. There are other fonts in the font folder. If you need to use them, just configure their paths. |
ImagePath | LgoLgo.png | ImagePath sets image path. The image will appear on the left side of the cover. |
CoverRGB | []int{47, 54, 66} | CoverRGB sets cover's RGB255. |
FontRGB | []int{238, 241, 247} | FontRGB sets font's RGB255. |
FontSize | 76 | FontSize sets font size. |
DPI | 72 | DPI sets font's DPI. |
LineSpacing | 1.1 | LineSpacing sets line spacing. |
Width | 1343 | Width sets cover width. |
ResizeWidth | 1000 | ResizeWidth sets image width. |
MaxWordWidth | 660.0 | MaxWordWidth sets max word's width. |
Height | 734 | Height sets height. |
ResizeHeight | 500 | ResizeHeight sets image height. |
X | 800.0 | X sets font's X coordinate. |
AX | 0.5 | AX sets font's AX. |
AnchoredX | 200 | AnchoredX sets image's X coordinate. |
AnchoredAX | 0.5 | AnchoredAX set image's AX. |
Y | 300.0 | Y sets font's Y coordinate. |
AY | 0.6 | AY sets font's AY. |
AnchoredY | 220 | AnchoredY sets image's Y coordinate. |
AnchoredAY | 0.5 | AnchoredAY set image's AY. |
License
This project is under the Apache License 2.0. See the LICENSE file for the full license text.
# Packages
No description provided by the author
# Functions
No description provided by the author
No description provided by the author
WithAnchoredAX sets image's AX.
WithAnchoredAY sets image's AY.
WithAnchoredX sets image's X coordinate.
WithAnchoredY sets image's Y coordinate.
WithAX sets font's AX.
WithAY sets font's AY.
WithCoverRGB sets cover's RGB255.
WithDPI sets font's DPI.
WithFontFilePath sets font file path.
WithFontRGB sets font's RGB255.
WithFontSize sets font's size.
WithHeight sets cover's height.
WithImagePath sets image path.
WithLineSpacing sets line spacing.
WithMaxWordWidth sets max word width.
WithResizeHeight sets image's height.
WithResizeWidth sets image's width.
WithSavingFileName sets title.
WithTitle sets title.
WithWidth sets cover's width.
WithX sets font's X coordinate.
WithY sets font's Y coordinate.
# Variables
OptionsDefault is the default options.