From af3aef5c394b685765820f8a3a4878b907c99f68 Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Thu, 6 Jun 2019 00:15:36 -0700 Subject: [PATCH] switched to websafe color pallete, disabled number of colors input box for now --- wrp.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wrp.go b/wrp.go index 442399d..538d251 100644 --- a/wrp.go +++ b/wrp.go @@ -12,7 +12,9 @@ import ( "context" "flag" "fmt" - _ "image" + "image" + "image/color/palette" + "image/draw" "image/gif" "image/png" "log" @@ -99,7 +101,7 @@ func pageServer(out http.ResponseWriter, req *http.Request) { fmt.Fprintf(out, "W \n", w) fmt.Fprintf(out, "H \n", h) fmt.Fprintf(out, "S \n", s) - fmt.Fprintf(out, "C \n", c) + //fmt.Fprintf(out, "C \n", c) fmt.Fprintf(out, "
\n") if len(u) > 1 { if strings.HasPrefix(u, "http") { @@ -195,8 +197,10 @@ func capture(gourl string, w int64, h int64, s float64, co int, p int64, i bool, fmt.Fprintf(out, "
Unable to decode page screenshot:
%s
\n", err) return } + pm := image.NewPaletted(img.Bounds(), palette.WebSafe) + draw.FloydSteinberg.Draw(pm, img.Bounds(), img, image.ZP) gifbuf.Reset() - err = gif.Encode(&gifbuf, img, &gif.Options{NumColors: co}) + err = gif.Encode(&gifbuf, img, nil) if err != nil { log.Printf("%s Failed to encode GIF: %s\n", c, err) fmt.Fprintf(out, "
Unable to encode GIF:
%s
\n", err)