mirror of
https://github.com/tenox7/wrp.git
synced 2025-02-16 18:30:27 +00:00
switched to websafe color pallete, disabled number of colors input box for now
This commit is contained in:
parent
26ad732d99
commit
af3aef5c39
10
wrp.go
10
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 <INPUT TYPE=\"TEXT\" NAME=\"w\" VALUE=\"%d\" SIZE=\"4\"> \n", w)
|
||||
fmt.Fprintf(out, "H <INPUT TYPE=\"TEXT\" NAME=\"h\" VALUE=\"%d\" SIZE=\"4\"> \n", h)
|
||||
fmt.Fprintf(out, "S <INPUT TYPE=\"TEXT\" NAME=\"s\" VALUE=\"%1.2f\" SIZE=\"3\"> \n", s)
|
||||
fmt.Fprintf(out, "C <INPUT TYPE=\"TEXT\" NAME=\"c\" VALUE=\"%d\" SIZE=\"3\"> \n", c)
|
||||
//fmt.Fprintf(out, "C <INPUT TYPE=\"TEXT\" NAME=\"c\" VALUE=\"%d\" SIZE=\"3\"> \n", c)
|
||||
fmt.Fprintf(out, "</FORM><BR>\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, "<BR>Unable to decode page screenshot:<BR>%s<BR>\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, "<BR>Unable to encode GIF:<BR>%s<BR>\n", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user