1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-12-01 23:11:31 +02:00

extend option

This commit is contained in:
DarthSim
2019-02-21 21:55:20 +06:00
parent f43fd6eec0
commit 5040ba7d61
5 changed files with 76 additions and 12 deletions

View File

@@ -124,6 +124,7 @@ type processingOptions struct {
Dpr float64
Gravity gravityOptions
Enlarge bool
Expand bool
Format imageType
Quality int
Flatten bool
@@ -322,8 +323,18 @@ func applyEnlargeOption(po *processingOptions, args []string) error {
return nil
}
func applyExtendOption(po *processingOptions, args []string) error {
if len(args) > 1 {
return fmt.Errorf("Invalid expand arguments: %v", args)
}
po.Expand = args[0] != "0"
return nil
}
func applySizeOption(po *processingOptions, args []string) (err error) {
if len(args) > 3 {
if len(args) > 4 {
return fmt.Errorf("Invalid size arguments: %v", args)
}
@@ -339,12 +350,18 @@ func applySizeOption(po *processingOptions, args []string) (err error) {
}
}
if len(args) == 3 && len(args[2]) > 0 {
if len(args) >= 3 && len(args[2]) > 0 {
if err = applyEnlargeOption(po, args[2:3]); err != nil {
return
}
}
if len(args) == 4 && len(args[3]) > 0 {
if err = applyExtendOption(po, args[3:4]); err != nil {
return
}
}
return nil
}
@@ -363,7 +380,7 @@ func applyResizingTypeOption(po *processingOptions, args []string) error {
}
func applyResizeOption(po *processingOptions, args []string) error {
if len(args) > 4 {
if len(args) > 5 {
return fmt.Errorf("Invalid resize arguments: %v", args)
}
@@ -640,6 +657,10 @@ func applyProcessingOption(po *processingOptions, name string, args []string) er
if err := applyEnlargeOption(po, args); err != nil {
return err
}
case "extend", "ex":
if err := applyExtendOption(po, args); err != nil {
return err
}
case "dpr":
if err := applyDprOption(po, args); err != nil {
return err