Simplify applyProcessingOption

This commit is contained in:
DarthSim
2019-08-13 17:56:14 +06:00
parent 2a92243e47
commit 5c96ee1900

View File

@@ -650,86 +650,46 @@ func applyFilenameOption(po *processingOptions, args []string) error {
func applyProcessingOption(po *processingOptions, name string, args []string) error { func applyProcessingOption(po *processingOptions, name string, args []string) error {
switch name { switch name {
case "format", "f", "ext": case "format", "f", "ext":
if err := applyFormatOption(po, args); err != nil { return applyFormatOption(po, args)
return err
}
case "resize", "rs": case "resize", "rs":
if err := applyResizeOption(po, args); err != nil { return applyResizeOption(po, args)
return err
}
case "resizing_type", "rt": case "resizing_type", "rt":
if err := applyResizingTypeOption(po, args); err != nil { return applyResizingTypeOption(po, args)
return err
}
case "size", "s": case "size", "s":
if err := applySizeOption(po, args); err != nil { return applySizeOption(po, args)
return err
}
case "width", "w": case "width", "w":
if err := applyWidthOption(po, args); err != nil { return applyWidthOption(po, args)
return err
}
case "height", "h": case "height", "h":
if err := applyHeightOption(po, args); err != nil { return applyHeightOption(po, args)
return err
}
case "enlarge", "el": case "enlarge", "el":
if err := applyEnlargeOption(po, args); err != nil { return applyEnlargeOption(po, args)
return err
}
case "extend", "ex": case "extend", "ex":
if err := applyExtendOption(po, args); err != nil { return applyExtendOption(po, args)
return err
}
case "dpr": case "dpr":
if err := applyDprOption(po, args); err != nil { return applyDprOption(po, args)
return err
}
case "gravity", "g": case "gravity", "g":
if err := applyGravityOption(po, args); err != nil { return applyGravityOption(po, args)
return err
}
case "crop", "c": case "crop", "c":
if err := applyCropOption(po, args); err != nil { return applyCropOption(po, args)
return err
}
case "quality", "q": case "quality", "q":
if err := applyQualityOption(po, args); err != nil { return applyQualityOption(po, args)
return err
}
case "background", "bg": case "background", "bg":
if err := applyBackgroundOption(po, args); err != nil { return applyBackgroundOption(po, args)
return err
}
case "blur", "bl": case "blur", "bl":
if err := applyBlurOption(po, args); err != nil { return applyBlurOption(po, args)
return err
}
case "sharpen", "sh": case "sharpen", "sh":
if err := applySharpenOption(po, args); err != nil { return applySharpenOption(po, args)
return err
}
case "watermark", "wm": case "watermark", "wm":
if err := applyWatermarkOption(po, args); err != nil { return applyWatermarkOption(po, args)
return err
}
case "preset", "pr": case "preset", "pr":
if err := applyPresetOption(po, args); err != nil { return applyPresetOption(po, args)
return err
}
case "cachebuster", "cb": case "cachebuster", "cb":
if err := applyCacheBusterOption(po, args); err != nil { return applyCacheBusterOption(po, args)
return err
}
case "filename", "fn": case "filename", "fn":
if err := applyFilenameOption(po, args); err != nil { return applyFilenameOption(po, args)
return err
}
default:
return fmt.Errorf("Unknown processing option: %s", name)
} }
return nil return fmt.Errorf("Unknown processing option: %s", name)
} }
func applyProcessingOptions(po *processingOptions, options urlOptions) error { func applyProcessingOptions(po *processingOptions, options urlOptions) error {