From d352fa4cc8d0addc9c95e19d626dc13ca6bed633 Mon Sep 17 00:00:00 2001 From: James South Date: Wed, 15 Oct 2014 17:55:16 +0100 Subject: [PATCH] Fixing crop and saturation bugs Former-commit-id: 5de3038fbf6ff74a61b880c623ee479ee94d26cb Former-commit-id: 7800972e069b54bd95241e4ce22b99b1a8c6b073 --- .../Helpers/CommonParameterParserUtility.cs | 2 +- src/ImageProcessor.Web/Processors/Resize.cs | 6 +++--- src/ImageProcessor/Processors/Crop.cs | 8 ++++---- src/TestWebsites/MVC/Test_Website_MVC.csproj | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs b/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs index 273f478ef..bb20337eb 100644 --- a/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs +++ b/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs @@ -44,7 +44,7 @@ namespace ImageProcessor.Web.Helpers /// /// The regular expression to search strings for values between 1 and 100. /// - private static readonly Regex In100RangeRegex = new Regex(@"(-?(0*(?:[1-9][0-9]?|100)))", RegexOptions.Compiled); + private static readonly Regex In100RangeRegex = new Regex(@"(-?0*(?:100|[1-9][0-9]?))", RegexOptions.Compiled); /// /// The sharpen regex. diff --git a/src/ImageProcessor.Web/Processors/Resize.cs b/src/ImageProcessor.Web/Processors/Resize.cs index 207cd0b98..a634c2327 100644 --- a/src/ImageProcessor.Web/Processors/Resize.cs +++ b/src/ImageProcessor.Web/Processors/Resize.cs @@ -29,7 +29,7 @@ namespace ImageProcessor.Web.Processors /// /// The regular expression to search strings for. /// - private static readonly Regex QueryRegex = new Regex(@"(width|height)=|(width|height)ratio=|mode=(carve)?|anchor=|center=|upscale=", RegexOptions.Compiled); + private static readonly Regex QueryRegex = new Regex(@"(width|height)=|(width|height)ratio=|mode=(carve|percent)?|anchor=|center=|upscale=", RegexOptions.Compiled); /// /// The regular expression to search strings for the size attribute. @@ -111,8 +111,8 @@ namespace ImageProcessor.Web.Processors { if (match.Success) { - // We don't want any resize carve requests to interfere. - if (match.Value.ToUpperInvariant().Contains("CARVE")) + // We don't want any resize carve or percentile crops requests to interfere. + if (match.Value.ToUpperInvariant().Contains("CARVE") || match.Value.ToUpperInvariant().Contains("PERCENT")) { break; } diff --git a/src/ImageProcessor/Processors/Crop.cs b/src/ImageProcessor/Processors/Crop.cs index d0b8cb9ae..c65b82d34 100644 --- a/src/ImageProcessor/Processors/Crop.cs +++ b/src/ImageProcessor/Processors/Crop.cs @@ -126,11 +126,11 @@ namespace ImageProcessor.Processors GraphicsUnit.Pixel, wrapMode); } - - // Reassign the image. - image.Dispose(); - image = newImage; } + + // Reassign the image. + image.Dispose(); + image = newImage; } } catch (Exception ex) diff --git a/src/TestWebsites/MVC/Test_Website_MVC.csproj b/src/TestWebsites/MVC/Test_Website_MVC.csproj index 9cdaaaad9..4260443d6 100644 --- a/src/TestWebsites/MVC/Test_Website_MVC.csproj +++ b/src/TestWebsites/MVC/Test_Website_MVC.csproj @@ -228,7 +228,7 @@ - +