Merge branch 'version/3' into version/3-refactoring

This commit is contained in:
DarthSim
2021-05-17 18:52:40 +06:00
7 changed files with 90 additions and 108 deletions

View File

@@ -84,6 +84,7 @@ type ProcessingOptions struct {
Background vips.Color
Blur float32
Sharpen float32
Pixelate int
StripMetadata bool
StripColorProfile bool
AutoRotate bool
@@ -603,6 +604,20 @@ func applySharpenOption(po *ProcessingOptions, args []string) error {
return nil
}
func applyPixelateOption(po *ProcessingOptions, args []string) error {
if len(args) > 1 {
return fmt.Errorf("Invalid pixelate arguments: %v", args)
}
if p, err := strconv.Atoi(args[0]); err == nil && p >= 0 {
po.Pixelate = p
} else {
return fmt.Errorf("Invalid pixelate: %s", args[0])
}
return nil
}
func applyPresetOption(po *ProcessingOptions, args []string) error {
for _, preset := range args {
if p, ok := presets[preset]; ok {
@@ -806,6 +821,8 @@ func applyURLOption(po *ProcessingOptions, name string, args []string) error {
return applyBlurOption(po, args)
case "sharpen", "sh":
return applySharpenOption(po, args)
case "pixelate", "pix":
return applyPixelateOption(po, args)
case "watermark", "wm":
return applyWatermarkOption(po, args)
case "strip_metadata", "sm":