Explorar o código

improve svg format detection (#135)

Marius Cristea %!s(int64=6) %!d(string=hai) anos
pai
achega
4f2f20c089
Modificáronse 1 ficheiros con 8 adicións e 10 borrados
  1. 8 10
      svg.go

+ 8 - 10
svg.go

@@ -9,14 +9,12 @@ import (
 func init() {
 	// Register fake svg decoder. Since we need this only for type detecting, we can
 	// return fake image sizes
-	image.RegisterFormat(
-		"svg",
-		"<?xml ",
-		func(io.Reader) (image.Image, error) {
-			return image.NewRGBA(image.Rect(0, 0, 1, 1)), nil
-		},
-		func(io.Reader) (image.Config, error) {
-			return image.Config{ColorModel: color.RGBAModel, Width: 1, Height: 1}, nil
-		},
-	)
+	decode := func(io.Reader) (image.Image, error) {
+		return image.NewRGBA(image.Rect(0, 0, 1, 1)), nil
+	}
+	decodeConfig := func(io.Reader) (image.Config, error) {
+		return image.Config{ColorModel: color.RGBAModel, Width: 1, Height: 1}, nil
+	}
+	image.RegisterFormat("svg", "<?xml ", decode, decodeConfig)
+	image.RegisterFormat("svg", "<svg", decode, decodeConfig)
 }