From 561ea7ec7517114b21688a84beef0b377206f005 Mon Sep 17 00:00:00 2001 From: Deleplace Date: Fri, 24 Mar 2017 00:17:11 +0100 Subject: [PATCH] Extra flag -i to invert black and white (negative photo). --- qrcode/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qrcode/main.go b/qrcode/main.go index e91ef73..bddfb09 100644 --- a/qrcode/main.go +++ b/qrcode/main.go @@ -17,6 +17,7 @@ func main() { outFile := flag.String("o", "", "out PNG file prefix, empty for stdout") size := flag.Int("s", 256, "image size (pixel)") textArt := flag.Bool("t", false, "print as text-art on stdout") + negative := flag.Bool("i", false, "invert black and white") flag.Usage = func() { fmt.Fprintf(os.Stderr, `qrcode -- QR Code encoder in Go https://github.com/skip2/go-qrcode @@ -56,11 +57,15 @@ Usage: checkError(err) if *textArt { - art := qr2String(q, false) + art := qr2String(q, *negative) fmt.Println(art) return } + if *negative { + q.ForegroundColor, q.BackgroundColor = q.BackgroundColor, q.ForegroundColor + } + var png []byte png, err = q.PNG(*size) checkError(err)