mirror of
https://github.com/tenox7/wrp.git
synced 2025-04-09 14:39:35 +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"
|
||||
"time"
|
||||
|
||||
"github.com/MaxHalford/halfgone"
|
||||
"github.com/chromedp/cdproto/css"
|
||||
"github.com/chromedp/cdproto/emulation"
|
||||
"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)
|
||||
return
|
||||
}
|
||||
if w.colors == 2 {
|
||||
gray := halfgone.ImageToGray(i)
|
||||
i = halfgone.FloydSteinbergDitherer{}.Apply(gray)
|
||||
}
|
||||
var gifbuf bytes.Buffer
|
||||
err = gif.Encode(&gifbuf, i, &gif.Options{NumColors: int(w.colors), Quantizer: quantize.MedianCutQuantizer{}})
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user