diff --git a/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs
index 115fa0451..a6e863860 100644
--- a/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs
+++ b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs
@@ -25,7 +25,7 @@ namespace ImageProcessor.Web.Helpers
///
/// The regular expression to search strings for colors.
///
- private static readonly Regex ColorRegex = new Regex(@"(bgcolor|color)(=|-)(\d+,\d+,\d+,\d+|([0-9a-fA-F]{3}){1,2})", RegexOptions.Compiled);
+ private static readonly Regex ColorRegex = new Regex(@"(bgcolor|color|tint)(=|-)(\d+,\d+,\d+,\d+|([0-9a-fA-F]{3}){1,2})", RegexOptions.Compiled);
///
/// The regular expression to search strings for angles.
@@ -37,11 +37,6 @@ namespace ImageProcessor.Web.Helpers
///
private static readonly Regex In100RangeRegex = new Regex(@"(-?(?:100)|-?([1-9]?[0-9]))", RegexOptions.Compiled);
- ///
- /// The regular expression to search strings for.
- ///
- private static readonly Regex GuassianRegex = new Regex(@"(blur|sharpen|sigma|threshold)(=|-)[^&]*", RegexOptions.Compiled);
-
///
/// The sharpen regex.
///
@@ -57,7 +52,6 @@ namespace ImageProcessor.Web.Helpers
///
private static readonly Regex ThresholdRegex = new Regex(@"threshold(=|-)\d+", RegexOptions.Compiled);
-
///
/// Returns the correct containing the angle for the given string.
///
@@ -202,7 +196,7 @@ namespace ImageProcessor.Web.Helpers
foreach (Match match in SigmaRegex.Matches(input))
{
// split on text-
- return Convert.ToDouble(match.Value.Split('-')[1]);
+ return Convert.ToDouble(match.Value.Split(new[] { '=', '-' })[1]);
}
return 1.4d;
@@ -223,7 +217,7 @@ namespace ImageProcessor.Web.Helpers
// ReSharper disable once LoopCanBeConvertedToQuery
foreach (Match match in ThresholdRegex.Matches(input))
{
- return Convert.ToInt32(match.Value.Split('-')[1]);
+ return Convert.ToInt32(match.Value.Split(new[] { '=', '-' })[1]);
}
return 0;
diff --git a/src/ImageProcessor.Web/NET45/Helpers/ImageHelpers.cs b/src/ImageProcessor.Web/NET45/Helpers/ImageHelpers.cs
index 88ed8e4b5..f48e8d9d1 100644
--- a/src/ImageProcessor.Web/NET45/Helpers/ImageHelpers.cs
+++ b/src/ImageProcessor.Web/NET45/Helpers/ImageHelpers.cs
@@ -28,7 +28,7 @@ namespace ImageProcessor.Web.Helpers
///
/// The image format regex.
///
- private static readonly Regex FormatRegex = new Regex(@"(\.?)" + RegexPattern, RegexOptions.IgnoreCase | RegexOptions.RightToLeft);
+ private static readonly Regex FormatRegex = new Regex(@"(\.?)(png8|" + RegexPattern + ")", RegexOptions.IgnoreCase | RegexOptions.RightToLeft);
///
/// The image format regex for matching the file format at the end of a string.
@@ -42,13 +42,7 @@ namespace ImageProcessor.Web.Helpers
/// True the value contains a valid image extension, otherwise false.
public static bool IsValidImageExtension(string fileName)
{
- Match match = EndFormatRegex.Match(fileName);
- if (match.Success && !match.Value.ToLowerInvariant().EndsWith("png8"))
- {
- return true;
- }
-
- return false;
+ return EndFormatRegex.IsMatch(fileName);
}
///
diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj
index 1f1601bf2..d1d3dfe66 100644
--- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj
+++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj
@@ -76,6 +76,7 @@
+
diff --git a/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs b/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs
index 80df3959c..c617f72a7 100644
--- a/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs
+++ b/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs
@@ -22,7 +22,7 @@ namespace ImageProcessor.Web.Processors
///
/// The regular expression to search strings for.
///
- private static readonly Regex QueryRegex = new Regex(@"bgcolor(=|-)[^&|,]*", RegexOptions.Compiled);
+ private static readonly Regex QueryRegex = new Regex(@"bgcolor(=|-)[^&]*", RegexOptions.Compiled);
///
/// Initializes a new instance of the class.
diff --git a/src/ImageProcessor.Web/NET45/Processors/Format.cs b/src/ImageProcessor.Web/NET45/Processors/Format.cs
index eaddab8e1..8e74f6cc3 100644
--- a/src/ImageProcessor.Web/NET45/Processors/Format.cs
+++ b/src/ImageProcessor.Web/NET45/Processors/Format.cs
@@ -133,13 +133,14 @@ namespace ImageProcessor.Web.Processors
private ISupportedImageFormat ParseFormat(string identifier)
{
identifier = identifier.ToLowerInvariant();
+ string finalIdentifier = identifier.Equals("png8") ? "png" : identifier;
ISupportedImageFormat format = ImageProcessorBootstrapper.Instance.SupportedImageFormats
- .FirstOrDefault(f => f.FileExtensions.Any(e => e.Equals(identifier, StringComparison.InvariantCultureIgnoreCase)));
+ .FirstOrDefault(f => f.FileExtensions.Any(e => e.Equals(finalIdentifier, StringComparison.InvariantCultureIgnoreCase)));
if (format != null)
{
- // I wish this wasn't hardcoded but there's no way I can
- // find to preserve the pallete.
+ // I wish this wasn't hard-coded but there's no way I can
+ // find to preserve the palette.
if (identifier.Equals("png8"))
{
format.IsIndexed = true;
diff --git a/src/ImageProcessor.Web/NET45/Processors/Tint.cs b/src/ImageProcessor.Web/NET45/Processors/Tint.cs
new file mode 100644
index 000000000..d6621b003
--- /dev/null
+++ b/src/ImageProcessor.Web/NET45/Processors/Tint.cs
@@ -0,0 +1,85 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) James South.
+// Licensed under the Apache License, Version 2.0.
+//
+//
+// Tints an image with the given color.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace ImageProcessor.Web.Processors
+{
+ using System.Text.RegularExpressions;
+ using ImageProcessor.Processors;
+ using ImageProcessor.Web.Helpers;
+
+ ///
+ /// Tints an image with the given color.
+ ///
+ public class Tint : IWebGraphicsProcessor
+ {
+ ///
+ /// The regular expression to search strings for.
+ ///
+ private static readonly Regex QueryRegex = new Regex(@"tint=[^&]*", RegexOptions.Compiled);
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public Tint()
+ {
+ this.Processor = new ImageProcessor.Processors.Tint();
+ }
+
+ ///
+ /// Gets the regular expression to search strings for.
+ ///
+ public Regex RegexPattern
+ {
+ get { return QueryRegex; }
+ }
+
+ ///
+ /// Gets the order in which this processor is to be used in a chain.
+ ///
+ public int SortOrder { get; private set; }
+
+ ///
+ /// Gets the associated graphics processor.
+ ///
+ public IGraphicsProcessor Processor { get; private set; }
+
+ ///
+ /// The position in the original string where the first character of the captured substring was found.
+ ///
+ /// The query string to search.
+ ///
+ /// The zero-based starting position in the original string where the captured substring was found.
+ ///
+ public int MatchRegexIndex(string queryString)
+ {
+ int index = 0;
+
+ // Set the sort order to max to allow filtering.
+ this.SortOrder = int.MaxValue;
+
+ foreach (Match match in this.RegexPattern.Matches(queryString))
+ {
+ if (match.Success)
+ {
+ if (index == 0)
+ {
+ // Set the index on the first instance only.
+ this.SortOrder = match.Index;
+ this.Processor.DynamicParameter = CommonParameterParserUtility.ParseColor(match.Value);
+ }
+
+ index += 1;
+ }
+ }
+
+ return this.SortOrder;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ImageProcessor/Imaging/Formats/PngFormat.cs b/src/ImageProcessor/Imaging/Formats/PngFormat.cs
index c0de55ba5..1c4e96aba 100644
--- a/src/ImageProcessor/Imaging/Formats/PngFormat.cs
+++ b/src/ImageProcessor/Imaging/Formats/PngFormat.cs
@@ -39,7 +39,7 @@ namespace ImageProcessor.Imaging.Formats
{
get
{
- return new[] { "png8", "png" };
+ return new[] { "png" };
}
}
diff --git a/src/ImageProcessor/Processors/Tint.cs b/src/ImageProcessor/Processors/Tint.cs
index 166789f63..44453c969 100644
--- a/src/ImageProcessor/Processors/Tint.cs
+++ b/src/ImageProcessor/Processors/Tint.cs
@@ -4,7 +4,7 @@
// Licensed under the Apache License, Version 2.0.
//
//
-// Tints an image with the given colour.
+// Tints an image with the given color.
//
// --------------------------------------------------------------------------------------------------------------------
@@ -14,78 +14,22 @@ namespace ImageProcessor.Processors
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
- using System.Text.RegularExpressions;
- using ImageProcessor.Core.Common.Extensions;
///
- /// Tints an image with the given colour.
+ /// Tints an image with the given color.
///
public class Tint : IGraphicsProcessor
{
- ///
- /// The regular expression to search strings for.
- ///
- private static readonly Regex QueryRegex = new Regex(@"tint=(\d+,\d+,\d+,\d+|([0-9a-fA-F]{3}){1,2})", RegexOptions.Compiled);
-
- #region IGraphicsProcessor Members
-
- ///
- /// Gets the regular expression to search strings for.
- ///
- public Regex RegexPattern
- {
- get { return QueryRegex; }
- }
-
///
/// Gets or sets DynamicParameter.
///
public dynamic DynamicParameter { get; set; }
- ///
- /// Gets the order in which this processor is to be used in a chain.
- ///
- public int SortOrder { get; private set; }
-
///
/// Gets or sets any additional settings required by the processor.
///
public Dictionary Settings { get; set; }
- ///
- /// The position in the original string where the first character of the captured substring was found.
- ///
- ///
- /// The query string to search.
- ///
- ///
- /// The zero-based starting position in the original string where the captured substring was found.
- ///
- public int MatchRegexIndex(string queryString)
- {
- int index = 0;
-
- // Set the sort order to max to allow filtering.
- this.SortOrder = int.MaxValue;
-
- foreach (Match match in this.RegexPattern.Matches(queryString))
- {
- if (match.Success)
- {
- if (index == 0)
- {
- // Set the index on the first instance only.
- this.SortOrder = match.Index;
- this.DynamicParameter = this.ParseColor(match.Value);
- }
-
- index += 1;
- }
- }
-
- return this.SortOrder;
- }
-
///
/// Processes the image.
///
@@ -103,7 +47,7 @@ namespace ImageProcessor.Processors
try
{
- Color tintColour = (Color)this.DynamicParameter;
+ Color tintColour = this.DynamicParameter;
float[][] colorMatrixElements =
{
new[] { tintColour.R / 255f, 0, 0, 0, 0 }, // Red
@@ -144,39 +88,5 @@ namespace ImageProcessor.Processors
return image;
}
- #endregion
-
- ///
- /// Returns the correct for the given string.
- ///
- ///
- /// The input string containing the value to parse.
- ///
- ///
- /// The correct
- ///
- private Color ParseColor(string input)
- {
- foreach (Match match in QueryRegex.Matches(input))
- {
- string value = match.Value.Split('=')[1];
-
- if (value.Contains(","))
- {
- int[] split = value.ToPositiveIntegerArray();
- byte red = split[0].ToByte();
- byte green = split[1].ToByte();
- byte blue = split[2].ToByte();
- byte alpha = split[3].ToByte();
-
- return Color.FromArgb(alpha, red, green, blue);
- }
-
- // Split on color-hex
- return ColorTranslator.FromHtml("#" + value);
- }
-
- return Color.Transparent;
- }
}
-}
+}
\ No newline at end of file
diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Web.config b/src/TestWebsites/NET45/Test_Website_NET45/Web.config
index db3f37806..d20021463 100644
--- a/src/TestWebsites/NET45/Test_Website_NET45/Web.config
+++ b/src/TestWebsites/NET45/Test_Website_NET45/Web.config
@@ -59,6 +59,5 @@
-