浏览代码

Softer preferred formats check

DarthSim 2 年之前
父节点
当前提交
067481dc6b
共有 1 个文件被更改,包括 12 次插入1 次删除
  1. 12 1
      processing/processing.go

+ 12 - 1
processing/processing.go

@@ -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
 }