cmd/mkthumb: initial commit

This commit is contained in:
mappu 2016-11-18 20:36:36 +13:00
parent 0f4d2af8f0
commit d5e9baf4e9
2 changed files with 42 additions and 0 deletions

9
cmd/mkthumb/Makefile Normal file
View File

@ -0,0 +1,9 @@
.PHONY: all
all: mkthumb
clean:
rm ./mkthumb
mkthumb: mkthumb.go
go build -ldflags '-s -w'

33
cmd/mkthumb/mkthumb.go Normal file
View File

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