mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-11 04:32:29 +02:00
Softer preferred formats check
This commit is contained in:
@@ -2,6 +2,7 @@ package processing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -64,12 +65,22 @@ func findBestFormat(srcType imagetype.Type, animated, expectAlpha bool) imagetyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ValidatePreferredFormats() error {
|
func ValidatePreferredFormats() error {
|
||||||
|
filtered := config.PreferredFormats[:0]
|
||||||
|
|
||||||
for _, t := range config.PreferredFormats {
|
for _, t := range config.PreferredFormats {
|
||||||
if !vips.SupportsSave(t) {
|
if !vips.SupportsSave(t) {
|
||||||
return fmt.Errorf("%s can't be a preferred format as it's saving is not supported", t)
|
log.Warnf("%s can't be a preferred format as it's saving is not supported", t)
|
||||||
|
} else {
|
||||||
|
filtered = append(filtered, t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(filtered) == 0 {
|
||||||
|
return errors.New("No supported preferred formats specified")
|
||||||
|
}
|
||||||
|
|
||||||
|
config.PreferredFormats = filtered
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user