From d5e9baf4e939fe0fad893b9ec6fd051d02d86317 Mon Sep 17 00:00:00 2001 From: mappu Date: Fri, 18 Nov 2016 20:36:36 +1300 Subject: [PATCH] cmd/mkthumb: initial commit --- cmd/mkthumb/Makefile | 9 +++++++++ cmd/mkthumb/mkthumb.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 cmd/mkthumb/Makefile create mode 100644 cmd/mkthumb/mkthumb.go diff --git a/cmd/mkthumb/Makefile b/cmd/mkthumb/Makefile new file mode 100644 index 0000000..1f82ee8 --- /dev/null +++ b/cmd/mkthumb/Makefile @@ -0,0 +1,9 @@ +.PHONY: all + +all: mkthumb + +clean: + rm ./mkthumb + +mkthumb: mkthumb.go + go build -ldflags '-s -w' \ No newline at end of file diff --git a/cmd/mkthumb/mkthumb.go b/cmd/mkthumb/mkthumb.go new file mode 100644 index 0000000..73fe774 --- /dev/null +++ b/cmd/mkthumb/mkthumb.go @@ -0,0 +1,33 @@ +package main + +import ( + "flag" + "fmt" + "os" + + "code.ivysaur.me/thumbnail" +) + +func main() { + width := flag.Int("Width", 100, "Width") + height := flag.Int("Height", 100, "Height") + flag.Parse() + + if flag.NArg() != 1 { + fmt.Fprintf(os.Stderr, "Expected one filename") + os.Exit(1) + } + + fname := flag.Arg(0) + + th := thumbnail.NewThumbnailer(*width, *height, 1) + data, err := th.RenderFile_NoCache(fname) + if err != nil { + fmt.Fprintln(os.Stderr, err.Error()) + os.Exit(1) + } + + fmt.Print(string(data)) + os.Exit(0) + +}