mirror of https://github.com/tenox7/wrp.git
print time took to encode gif
This commit is contained in:
parent
55f4e45b4c
commit
fa3bd3f8fb
3
wrp.go
3
wrp.go
|
@ -284,6 +284,7 @@ func capture(w wrpReq) {
|
||||||
i = halfgone.FloydSteinbergDitherer{}.Apply(gray)
|
i = halfgone.FloydSteinbergDitherer{}.Apply(gray)
|
||||||
}
|
}
|
||||||
var gifbuf bytes.Buffer
|
var gifbuf bytes.Buffer
|
||||||
|
st := time.Now()
|
||||||
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 {
|
||||||
log.Printf("%s Failed to encode GIF: %s\n", w.req.RemoteAddr, err)
|
log.Printf("%s Failed to encode GIF: %s\n", w.req.RemoteAddr, err)
|
||||||
|
@ -294,7 +295,7 @@ func capture(w wrpReq) {
|
||||||
ssize = fmt.Sprintf("%.0f KB", float32(len(gifbuf.Bytes()))/1024.0)
|
ssize = fmt.Sprintf("%.0f KB", float32(len(gifbuf.Bytes()))/1024.0)
|
||||||
iw = i.Bounds().Max.X
|
iw = i.Bounds().Max.X
|
||||||
ih = i.Bounds().Max.Y
|
ih = i.Bounds().Max.Y
|
||||||
log.Printf("%s Encoded GIF image: %s, Size: %s, Colors: %d, %dx%d\n", w.req.RemoteAddr, imgpath, ssize, w.colors, iw, ih)
|
log.Printf("%s Encoded GIF image: %s, Size: %s, Colors: %d, %dx%d, Time: %vms\n", w.req.RemoteAddr, imgpath, ssize, w.colors, iw, ih, time.Since(st).Milliseconds())
|
||||||
case "png":
|
case "png":
|
||||||
pngbuf := bytes.NewBuffer(pngcap)
|
pngbuf := bytes.NewBuffer(pngcap)
|
||||||
img[imgpath] = *pngbuf
|
img[imgpath] = *pngbuf
|
||||||
|
|
Loading…
Reference in New Issue