mirror of
https://github.com/tenox7/wrp.git
synced 2024-06-08 18:29:34 +00:00
add support for monochrome 2 colors
This commit is contained in:
parent
ac594cdebd
commit
36427fac64
5
wrp.go
5
wrp.go
|
@ -27,6 +27,7 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/MaxHalford/halfgone"
|
||||||
"github.com/chromedp/cdproto/css"
|
"github.com/chromedp/cdproto/css"
|
||||||
"github.com/chromedp/cdproto/emulation"
|
"github.com/chromedp/cdproto/emulation"
|
||||||
"github.com/chromedp/cdproto/page"
|
"github.com/chromedp/cdproto/page"
|
||||||
|
@ -357,6 +358,10 @@ func (w wrpReq) capture() {
|
||||||
fmt.Fprintf(w.out, "<BR>Unable to decode page screenshot:<BR>%s<BR>\n", err)
|
fmt.Fprintf(w.out, "<BR>Unable to decode page screenshot:<BR>%s<BR>\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if w.colors == 2 {
|
||||||
|
gray := halfgone.ImageToGray(i)
|
||||||
|
i = halfgone.FloydSteinbergDitherer{}.Apply(gray)
|
||||||
|
}
|
||||||
var gifbuf bytes.Buffer
|
var gifbuf bytes.Buffer
|
||||||
err = gif.Encode(&gifbuf, i, &gif.Options{NumColors: int(w.colors), Quantizer: quantize.MedianCutQuantizer{}})
|
err = gif.Encode(&gifbuf, i, &gif.Options{NumColors: int(w.colors), Quantizer: quantize.MedianCutQuantizer{}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user