mirror of
https://github.com/gen2brain/cam2ip.git
synced 2025-12-16 12:28:35 +00:00
Add some options
This commit is contained in:
@@ -11,19 +11,20 @@ import (
|
||||
)
|
||||
|
||||
// NewEncoder returns a new Encoder.
|
||||
func NewEncoder(w io.Writer) *Encoder {
|
||||
return &Encoder{w}
|
||||
func NewEncoder(w io.Writer, quality int) *Encoder {
|
||||
return &Encoder{w, quality}
|
||||
}
|
||||
|
||||
// Encoder struct.
|
||||
type Encoder struct {
|
||||
w io.Writer
|
||||
w io.Writer
|
||||
quality int
|
||||
}
|
||||
|
||||
// Encode encodes image to JPEG.
|
||||
func (e Encoder) Encode(img image.Image) error {
|
||||
return jpeg.Encode(e.w, img, &jpeg.EncoderOptions{
|
||||
Quality: 75,
|
||||
Quality: e.quality,
|
||||
DCTMethod: jpeg.DCTIFast,
|
||||
ProgressiveMode: false,
|
||||
OptimizeCoding: false,
|
||||
|
||||
Reference in New Issue
Block a user