add limit to crop limit

This commit is contained in:
Celogeek 2024-04-28 17:45:02 +02:00
parent 9133493e60
commit c500755a4e
Signed by: celogeek
SSH Key Fingerprint: SHA256:njNJLzoLQdbV9PC6ehcruRb0QnEgxABoCYZ+0+aUIYc
2 changed files with 6 additions and 1 deletions

View File

@ -389,6 +389,11 @@ func (c *Converter) Validate() error {
return errors.New("grayscale mode should be 0, 1 or 2") return errors.New("grayscale mode should be 0, 1 or 2")
} }
// crop
if c.Options.CropLimit < 0 || c.Options.CropLimit > 100 {
return errors.New("crop limit should be between 0 and 100")
}
return nil return nil
} }

View File

@ -268,7 +268,7 @@ func (o *Options) ShowConfig() string {
{"Grayscale", o.Grayscale, true}, {"Grayscale", o.Grayscale, true},
{"Grayscale mode", grayscaleMode, o.Grayscale}, {"Grayscale mode", grayscaleMode, o.Grayscale},
{"Crop", o.Crop, true}, {"Crop", o.Crop, true},
{"Crop ratio", fmt.Sprintf("%d Left - %d Up - %d Right - %d Bottom - %d%% Limit", o.CropRatioLeft, o.CropRatioUp, o.CropRatioRight, o.CropRatioBottom, o.CropLimit), o.Crop}, {"Crop ratio", fmt.Sprintf("%d Left - %d Up - %d Right - %d Bottom - Limit %d%%", o.CropRatioLeft, o.CropRatioUp, o.CropRatioRight, o.CropRatioBottom, o.CropLimit), o.Crop},
{"Brightness", o.Brightness, o.Brightness != 0}, {"Brightness", o.Brightness, o.Brightness != 0},
{"Contrast", o.Contrast, o.Contrast != 0}, {"Contrast", o.Contrast, o.Contrast != 0},
{"Auto contrast", o.AutoContrast, true}, {"Auto contrast", o.AutoContrast, true},