mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-01-23 11:14:48 +02:00
Softer preferred formats check
This commit is contained in:
parent
97e15c717d
commit
067481dc6b
@ -2,6 +2,7 @@ package processing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@ -64,12 +65,22 @@ func findBestFormat(srcType imagetype.Type, animated, expectAlpha bool) imagetyp
|
||||
}
|
||||
|
||||
func ValidatePreferredFormats() error {
|
||||
filtered := config.PreferredFormats[:0]
|
||||
|
||||
for _, t := range config.PreferredFormats {
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user