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) + +}