resources/images: Require width and height for Crop, Fill, and Fit

Closes #9696
This commit is contained in:
Joe Mooring
2022-03-20 10:55:02 -07:00
committed by Bjørn Erik Pedersen
parent b80853de90
commit cad2d8cc70
2 changed files with 30 additions and 13 deletions

View File

@@ -253,8 +253,17 @@ func DecodeImageConfig(action, config string, defaults ImagingConfig, sourceForm
}
}
if c.Width == 0 && c.Height == 0 {
return c, errors.New("must provide Width or Height")
switch c.Action {
case "crop", "fill", "fit":
if c.Width == 0 || c.Height == 0 {
return c, errors.New("must provide Width and Height")
}
case "resize":
if c.Width == 0 && c.Height == 0 {
return c, errors.New("must provide Width or Height")
}
default:
return c, errors.Errorf("BUG: unknown action %q encountered while decoding image configuration", c.Action)
}
if c.FilterStr == "" {