mirror of
https://github.com/gen2brain/cam2ip.git
synced 2025-12-16 04:18:39 +00:00
Add jpegli
This commit is contained in:
35
image/encode_jpegli.go
Normal file
35
image/encode_jpegli.go
Normal file
@@ -0,0 +1,35 @@
|
||||
//go:build jpegli
|
||||
|
||||
// Package image.
|
||||
package image
|
||||
|
||||
import (
|
||||
"image"
|
||||
"io"
|
||||
|
||||
"github.com/gen2brain/jpegli"
|
||||
)
|
||||
|
||||
// NewEncoder returns a new Encoder.
|
||||
func NewEncoder(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 {
|
||||
return jpegli.Encode(e.w, img, &jpegli.EncodingOptions{
|
||||
Quality: 75,
|
||||
ProgressiveLevel: 0,
|
||||
ChromaSubsampling: image.YCbCrSubsampleRatio420,
|
||||
DCTMethod: jpegli.DCTIFast,
|
||||
OptimizeCoding: false,
|
||||
AdaptiveQuantization: false,
|
||||
StandardQuantTables: false,
|
||||
FancyDownsampling: false,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user