mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-04 18:33:36 +02:00
NewProcessingOptions without hacks
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@@ -109,14 +108,8 @@ type ProcessingOptions struct {
|
|||||||
defaultQuality int
|
defaultQuality int
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
|
||||||
_newProcessingOptions ProcessingOptions
|
|
||||||
newProcessingOptionsOnce sync.Once
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewProcessingOptions() *ProcessingOptions {
|
func NewProcessingOptions() *ProcessingOptions {
|
||||||
newProcessingOptionsOnce.Do(func() {
|
po := ProcessingOptions{
|
||||||
_newProcessingOptions = ProcessingOptions{
|
|
||||||
ResizingType: ResizeFit,
|
ResizingType: ResizeFit,
|
||||||
Width: 0,
|
Width: 0,
|
||||||
Height: 0,
|
Height: 0,
|
||||||
@@ -143,16 +136,14 @@ func NewProcessingOptions() *ProcessingOptions {
|
|||||||
EnforceThumbnail: config.EnforceThumbnail,
|
EnforceThumbnail: config.EnforceThumbnail,
|
||||||
ReturnAttachment: config.ReturnAttachment,
|
ReturnAttachment: config.ReturnAttachment,
|
||||||
|
|
||||||
|
SkipProcessingFormats: append([]imagetype.Type(nil), config.SkipProcessingFormats...),
|
||||||
|
UsedPresets: make([]string, 0, len(config.Presets)),
|
||||||
|
|
||||||
// Basically, we need this to update ETag when `IMGPROXY_QUALITY` is changed
|
// Basically, we need this to update ETag when `IMGPROXY_QUALITY` is changed
|
||||||
defaultQuality: config.Quality,
|
defaultQuality: config.Quality,
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
po := _newProcessingOptions
|
po.FormatQuality = make(map[imagetype.Type]int, len(config.FormatQuality))
|
||||||
po.SkipProcessingFormats = append([]imagetype.Type(nil), config.SkipProcessingFormats...)
|
|
||||||
po.UsedPresets = make([]string, 0, len(config.Presets))
|
|
||||||
|
|
||||||
po.FormatQuality = make(map[imagetype.Type]int)
|
|
||||||
for k, v := range config.FormatQuality {
|
for k, v := range config.FormatQuality {
|
||||||
po.FormatQuality[k] = v
|
po.FormatQuality[k] = v
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user