1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-12-07 23:32:55 +02:00

min-width and min-height processing options

This commit is contained in:
DarthSim
2021-03-29 20:21:00 +06:00
parent 27fa220fea
commit fca4f87445
4 changed files with 63 additions and 0 deletions

View File

@@ -132,6 +132,8 @@ type processingOptions struct {
ResizingType resizeType
Width int
Height int
MinWidth int
MinHeight int
Dpr float64
Gravity gravityOptions
Enlarge bool
@@ -461,6 +463,22 @@ func applyHeightOption(po *processingOptions, args []string) error {
return parseDimension(&po.Height, "height", args[0])
}
func applyMinWidthOption(po *processingOptions, args []string) error {
if len(args) > 1 {
return fmt.Errorf("Invalid min width arguments: %v", args)
}
return parseDimension(&po.MinWidth, "min width", args[0])
}
func applyMinHeightOption(po *processingOptions, args []string) error {
if len(args) > 1 {
return fmt.Errorf("Invalid min height arguments: %v", args)
}
return parseDimension(&po.MinHeight, " min height", args[0])
}
func applyEnlargeOption(po *processingOptions, args []string) error {
if len(args) > 1 {
return fmt.Errorf("Invalid enlarge arguments: %v", args)
@@ -970,6 +988,10 @@ func applyProcessingOption(po *processingOptions, name string, args []string) er
return applyWidthOption(po, args)
case "height", "h":
return applyHeightOption(po, args)
case "min-width", "mw":
return applyMinWidthOption(po, args)
case "min-height", "mh":
return applyMinHeightOption(po, args)
case "enlarge", "el":
return applyEnlargeOption(po, args)
case "extend", "ex":