Code Monkey home page Code Monkey logo

cogen's Introduction

Cogen

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.

  1. You first need Go installed, then you can use the below Go command to install Cogen.
go get -u github.com/LgoLgo/cogen
  1. 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

result

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.

cogen's People

Contributors

dependabot[bot] avatar l2nce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.