From 64ccd5459d33b1462d8795d1e26663e27bf84260 Mon Sep 17 00:00:00 2001 From: wolfborg Date: Wed, 11 Jan 2017 21:30:24 -0500 Subject: [PATCH 1/2] Added ResizeMode enum --- ShareX.HelpersLib/Enums.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ShareX.HelpersLib/Enums.cs b/ShareX.HelpersLib/Enums.cs index 7447ff036..47600d855 100644 --- a/ShareX.HelpersLib/Enums.cs +++ b/ShareX.HelpersLib/Enums.cs @@ -167,4 +167,14 @@ public enum HotkeyStatus Failed, NotConfigured } + + public enum ResizeMode + { + [Description("Resizes all images to the specified size.")] + ResizeAll, + [Description("Only resize image if it is bigger than specified size.")] + ResizeIfBigger, + [Description("Only resize image if it is smaller than specified size.")] + ResizeIfSmaller + } } \ No newline at end of file From ec202fc8387c8a2d840da927a855fddbd431ce86 Mon Sep 17 00:00:00 2001 From: wolfborg Date: Wed, 11 Jan 2017 21:35:15 -0500 Subject: [PATCH 2/2] ResizeIfSmaller mode for more resize options --- ShareX.ImageEffectsLib/Manipulations/Resize.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ShareX.ImageEffectsLib/Manipulations/Resize.cs b/ShareX.ImageEffectsLib/Manipulations/Resize.cs index cc49aa5dd..809d3cade 100644 --- a/ShareX.ImageEffectsLib/Manipulations/Resize.cs +++ b/ShareX.ImageEffectsLib/Manipulations/Resize.cs @@ -37,8 +37,8 @@ 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; } + [DefaultValue(ResizeMode.ResizeAll)] + public ResizeMode Mode { get; set; } public Resize() { @@ -52,10 +52,8 @@ 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; - } + if (Mode == ResizeMode.ResizeIfBigger && img.Width <= width && img.Height <= height) return img; + if (Mode == ResizeMode.ResizeIfSmaller && img.Width >= width && img.Height >= height) return img; return ImageHelpers.ResizeImage(img, width, height); }