mirror of
https://github.com/gen2brain/cam2ip.git
synced 2026-01-10 16:48:30 +00:00
Move encoder
This commit is contained in:
29
encoder/encode.go
Normal file
29
encoder/encode.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package encoder
|
||||
|
||||
import (
|
||||
"image"
|
||||
//"image/jpeg"
|
||||
"io"
|
||||
|
||||
jpeg "github.com/antonini/golibjpegturbo"
|
||||
)
|
||||
|
||||
// New returns a new Encoder.
|
||||
func New(w io.Writer) *Encoder {
|
||||
return &Encoder{w}
|
||||
}
|
||||
|
||||
// Encoder struct.
|
||||
type Encoder struct {
|
||||
w io.Writer
|
||||
}
|
||||
|
||||
// Encode encodes image to JPEG.
|
||||
func (e Encoder) Encode(img image.Image) error {
|
||||
err := jpeg.Encode(e.w, img, &jpeg.Options{Quality: 75})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user