From d2af9182b1fb9c52b059f3c09aec5f01b169e17b Mon Sep 17 00:00:00 2001 From: Jaex Date: Fri, 12 Dec 2014 11:49:25 +0200 Subject: [PATCH] fixed #403: Optional resize if bigger setting --- ShareX.ImageEffectsLib/Manipulations/Resize.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ShareX.ImageEffectsLib/Manipulations/Resize.cs b/ShareX.ImageEffectsLib/Manipulations/Resize.cs index dd3552770..d8b0e2783 100644 --- a/ShareX.ImageEffectsLib/Manipulations/Resize.cs +++ b/ShareX.ImageEffectsLib/Manipulations/Resize.cs @@ -37,6 +37,9 @@ public class Resize : ImageEffect [DefaultValue(0), Description("Use height as 0 to automatically adjust height to maintain aspect ratio.")] public int Height { get; set; } + [DefaultValue(false), Description("Only resize image if it is bigger than specified size.")] + public bool ResizeIfBigger { get; set; } + public Resize() { this.ApplyDefaultPropertyValues(); @@ -49,6 +52,11 @@ public override Image Apply(Image img) int width = Width <= 0 ? (int)((float)Height / img.Height * img.Width) : Width; int height = Height <= 0 ? (int)((float)Width / img.Width * img.Height) : Height; + if (ResizeIfBigger && img.Width <= width && img.Height <= height) + { + return img; + } + return ImageHelpers.ResizeImage(img, width, height); } }