Skip to content

Commit

Permalink
Merge pull request #9 from foxbot/feature/local-gen-command
Browse files Browse the repository at this point in the history
feature: add command to generate images
  • Loading branch information
SilverCory authored Oct 11, 2019
2 parents cd4caf5 + 40c8064 commit 45ae79d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ The assets folder is required and has to be in the current working directory (wh

- To install the library simply `go get github.com/Vexera/LogoGen`.
- For the webapp you can run `go get github.com/Vexera/LogoGen/cmd/LogoGenWebApp`, and the binary will end up as `$GOPATH/bin/LogoGenWebApp`.
- The webapp has a -listen parameter which can be used for chaning the listen address.
- The webapp has a -listen parameter which can be used for chaning the listen address.
- You may also generate images from the command line using `github.com/Vexera/LogoGen/cmd/LogoGen`
- Use with -top="top text", -bottom="bottom text", and -output="file.png"
42 changes: 42 additions & 0 deletions cmd/LogoGen/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"flag"
"fmt"
"image/png"
"os"

"github.com/Vexera/LogoGen"
)

var (
output string
topText string
bottomText string
)

func init() {
flag.StringVar(&output, "output", "vexera.png", "-output=path.png")
flag.StringVar(&topText, "top", "", `-top="dab"`)
flag.StringVar(&bottomText, "bottom", "", `-bottom="bot"`)
}

func main() {
flag.Parse()
image, err := LogoGen.CreateLogo(topText, bottomText)
if err != nil {
fmt.Printf("error generating logo: %+v\n", err)
os.Exit(1)
}
file, err := os.Create(output)
if err != nil {
fmt.Printf("error opening output file: %+v\n", err)
os.Exit(1)
}
defer file.Close()
err = png.Encode(file, image)
if err != nil {
fmt.Printf("error encoding image: %+v\n", err)
os.Exit(1)
}
}

0 comments on commit 45ae79d

Please sign in to comment.