diff --git a/src/ImageProcessor/Extensions/IntegerExtensions.cs b/src/ImageProcessor/Extensions/IntegerExtensions.cs
index a247d6511..d969e780e 100644
--- a/src/ImageProcessor/Extensions/IntegerExtensions.cs
+++ b/src/ImageProcessor/Extensions/IntegerExtensions.cs
@@ -10,6 +10,8 @@
namespace ImageProcessor.Extensions
{
+ using System.Globalization;
+
///
/// Encapsulates a series of time saving extension methods to the class.
///
@@ -32,5 +34,17 @@ namespace ImageProcessor.Extensions
{
return ((double)integer).ToByte();
}
+
+ ///
+ /// Converts the string representation of a number in a specified culture-specific format to its
+ /// 32-bit signed integer equivalent using invariant culture.
+ ///
+ /// The integer.
+ /// A string containing a number to convert.
+ /// A 32-bit signed integer equivalent to the number specified in s.
+ public static int ParseInvariant(this int integer, string s)
+ {
+ return int.Parse(s, CultureInfo.InvariantCulture);
+ }
}
}
diff --git a/src/ImageProcessor/Extensions/StringExtensions.cs b/src/ImageProcessor/Extensions/StringExtensions.cs
index 62bb01e70..318146a9b 100644
--- a/src/ImageProcessor/Extensions/StringExtensions.cs
+++ b/src/ImageProcessor/Extensions/StringExtensions.cs
@@ -134,7 +134,7 @@ namespace ImageProcessor.Extensions
// Loop and parse the int values.
for (int i = 0; i < count; i++)
{
- matches[i] = int.Parse(matchCollection[i].Value);
+ matches[i] = int.Parse(matchCollection[i].Value, CultureInfo.InvariantCulture);
}
return matches;
@@ -163,7 +163,7 @@ namespace ImageProcessor.Extensions
// Loop and parse the int values.
for (int i = 0; i < count; i++)
{
- matches[i] = float.Parse(matchCollection[i].Value);
+ matches[i] = float.Parse(matchCollection[i].Value, CultureInfo.InvariantCulture);
}
return matches;
diff --git a/src/ImageProcessor/Processors/Alpha.cs b/src/ImageProcessor/Processors/Alpha.cs
index 6cb1ca58c..70ff57a65 100644
--- a/src/ImageProcessor/Processors/Alpha.cs
+++ b/src/ImageProcessor/Processors/Alpha.cs
@@ -14,6 +14,7 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
+ using System.Globalization;
using System.Text.RegularExpressions;
#endregion
@@ -91,7 +92,7 @@ namespace ImageProcessor.Processors
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
- int percentage = int.Parse(match.Value.Split('=')[1]);
+ int percentage = int.Parse(match.Value.Split('=')[1], CultureInfo.InvariantCulture);
this.DynamicParameter = percentage;
}
diff --git a/src/ImageProcessor/Processors/Brightness.cs b/src/ImageProcessor/Processors/Brightness.cs
index 041d108b1..6671ec373 100644
--- a/src/ImageProcessor/Processors/Brightness.cs
+++ b/src/ImageProcessor/Processors/Brightness.cs
@@ -14,6 +14,7 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
+ using System.Globalization;
using System.Text.RegularExpressions;
#endregion
@@ -91,7 +92,7 @@ namespace ImageProcessor.Processors
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
- int percentage = int.Parse(match.Value.Split('=')[1]);
+ int percentage = int.Parse(match.Value.Split('=')[1], CultureInfo.InvariantCulture);
this.DynamicParameter = percentage;
}
diff --git a/src/ImageProcessor/Processors/Contrast.cs b/src/ImageProcessor/Processors/Contrast.cs
index fbf056e46..4d057d6d5 100644
--- a/src/ImageProcessor/Processors/Contrast.cs
+++ b/src/ImageProcessor/Processors/Contrast.cs
@@ -14,6 +14,7 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
+ using System.Globalization;
using System.Text.RegularExpressions;
#endregion
@@ -91,7 +92,7 @@ namespace ImageProcessor.Processors
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
- int percentage = int.Parse(match.Value.Split('=')[1]);
+ int percentage = int.Parse(match.Value.Split('=')[1], CultureInfo.InvariantCulture);
this.DynamicParameter = percentage;
}
diff --git a/src/ImageProcessor/Processors/GaussianBlur.cs b/src/ImageProcessor/Processors/GaussianBlur.cs
index 4a78185aa..d96ee7f54 100644
--- a/src/ImageProcessor/Processors/GaussianBlur.cs
+++ b/src/ImageProcessor/Processors/GaussianBlur.cs
@@ -13,6 +13,7 @@ namespace ImageProcessor.Processors
using System;
using System.Collections.Generic;
using System.Drawing;
+ using System.Globalization;
using System.Text.RegularExpressions;
using ImageProcessor.Imaging;
@@ -98,9 +99,9 @@ namespace ImageProcessor.Processors
double maxSigma;
int maxThreshold;
- int.TryParse(this.Settings["MaxSize"], out maxSize);
- double.TryParse(this.Settings["MaxSigma"], out maxSigma);
- int.TryParse(this.Settings["MaxThreshold"], out maxThreshold);
+ int.TryParse(this.Settings["MaxSize"], NumberStyles.Any, CultureInfo.InvariantCulture, out maxSize);
+ double.TryParse(this.Settings["MaxSigma"], NumberStyles.Any, CultureInfo.InvariantCulture, out maxSigma);
+ int.TryParse(this.Settings["MaxThreshold"], NumberStyles.Any, CultureInfo.InvariantCulture, out maxThreshold);
int size = this.ParseBlur(match.Value);
double sigma = this.ParseSigma(match.Value);
diff --git a/src/ImageProcessor/Processors/GaussianSharpen.cs b/src/ImageProcessor/Processors/GaussianSharpen.cs
index 1056940fb..8c4672bf6 100644
--- a/src/ImageProcessor/Processors/GaussianSharpen.cs
+++ b/src/ImageProcessor/Processors/GaussianSharpen.cs
@@ -13,6 +13,7 @@ namespace ImageProcessor.Processors
using System;
using System.Collections.Generic;
using System.Drawing;
+ using System.Globalization;
using System.Text.RegularExpressions;
using ImageProcessor.Imaging;
@@ -98,9 +99,9 @@ namespace ImageProcessor.Processors
double maxSigma;
int maxThreshold;
- int.TryParse(this.Settings["MaxSize"], out maxSize);
- double.TryParse(this.Settings["MaxSigma"], out maxSigma);
- int.TryParse(this.Settings["MaxThreshold"], out maxThreshold);
+ int.TryParse(this.Settings["MaxSize"], NumberStyles.Any, CultureInfo.InvariantCulture, out maxSize);
+ double.TryParse(this.Settings["MaxSigma"], NumberStyles.Any, CultureInfo.InvariantCulture, out maxSigma);
+ int.TryParse(this.Settings["MaxThreshold"], NumberStyles.Any, CultureInfo.InvariantCulture, out maxThreshold);
int size = this.ParseSharpen(match.Value);
double sigma = this.ParseSigma(match.Value);
diff --git a/src/ImageProcessor/Processors/Quality.cs b/src/ImageProcessor/Processors/Quality.cs
index b41031031..97b4b7651 100644
--- a/src/ImageProcessor/Processors/Quality.cs
+++ b/src/ImageProcessor/Processors/Quality.cs
@@ -13,6 +13,7 @@ namespace ImageProcessor.Processors
#region Using
using System.Collections.Generic;
using System.Drawing;
+ using System.Globalization;
using System.Text.RegularExpressions;
#endregion
@@ -89,7 +90,7 @@ namespace ImageProcessor.Processors
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
- int percentage = int.Parse(match.Value.Split('=')[1]);
+ int percentage = int.Parse(match.Value.Split('=')[1], CultureInfo.InvariantCulture);
this.DynamicParameter = percentage;
}
diff --git a/src/ImageProcessor/Processors/Resize.cs b/src/ImageProcessor/Processors/Resize.cs
index 0c66e8de9..f13ad84d8 100644
--- a/src/ImageProcessor/Processors/Resize.cs
+++ b/src/ImageProcessor/Processors/Resize.cs
@@ -16,6 +16,7 @@ namespace ImageProcessor.Processors
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
+ using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
@@ -179,8 +180,8 @@ namespace ImageProcessor.Processors
int defaultMaxHeight;
string restrictions;
this.Settings.TryGetValue("RestrictTo", out restrictions);
- int.TryParse(this.Settings["MaxWidth"], out defaultMaxWidth);
- int.TryParse(this.Settings["MaxHeight"], out defaultMaxHeight);
+ int.TryParse(this.Settings["MaxWidth"], NumberStyles.Any, CultureInfo.InvariantCulture, out defaultMaxWidth);
+ int.TryParse(this.Settings["MaxHeight"], NumberStyles.Any, CultureInfo.InvariantCulture, out defaultMaxHeight);
List restrictedSizes = this.ParseRestrictions(restrictions);
return this.ResizeImage(factory, width, height, defaultMaxWidth, defaultMaxHeight, restrictedSizes, backgroundColor, mode, anchor, upscale, centerCoordinates);
diff --git a/src/ImageProcessor/Processors/Rotate.cs b/src/ImageProcessor/Processors/Rotate.cs
index 57e06fa2b..da3e85e63 100644
--- a/src/ImageProcessor/Processors/Rotate.cs
+++ b/src/ImageProcessor/Processors/Rotate.cs
@@ -15,6 +15,7 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
+ using System.Globalization;
using System.Text.RegularExpressions;
using ImageProcessor.Imaging;
#endregion
@@ -114,7 +115,7 @@ namespace ImageProcessor.Processors
else
{
int degrees;
- int.TryParse(match.Value.Split('=')[1], out degrees);
+ int.TryParse(match.Value.Split('=')[1], NumberStyles.Any, CultureInfo.InvariantCulture, out degrees);
rotateLayer = new RotateLayer(degrees);
}
@@ -281,7 +282,7 @@ namespace ImageProcessor.Processors
{
// Split on angle-
int angle;
- int.TryParse(match.Value.Split('-')[1], out angle);
+ int.TryParse(match.Value.Split('-')[1], NumberStyles.Any, CultureInfo.InvariantCulture, out angle);
return angle;
}
diff --git a/src/ImageProcessor/Processors/RoundedCorners.cs b/src/ImageProcessor/Processors/RoundedCorners.cs
index c8067c4fa..042a6b7f0 100644
--- a/src/ImageProcessor/Processors/RoundedCorners.cs
+++ b/src/ImageProcessor/Processors/RoundedCorners.cs
@@ -14,6 +14,7 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
+ using System.Globalization;
using System.Text.RegularExpressions;
using ImageProcessor.Imaging;
#endregion
@@ -133,7 +134,7 @@ namespace ImageProcessor.Processors
else
{
int radius;
- int.TryParse(match.Value.Split('=')[1], out radius);
+ int.TryParse(match.Value.Split('=')[1], NumberStyles.Any, CultureInfo.InvariantCulture, out radius);
roundedCornerLayer = new RoundedCornerLayer(radius, this.ParseCorner(TopLeftRegex, toParse), this.ParseCorner(TopRightRegex, toParse), this.ParseCorner(BottomLeftRegex, toParse), this.ParseCorner(BottomRightRegex, toParse));
}
@@ -295,7 +296,7 @@ namespace ImageProcessor.Processors
{
// Split on radius-
int radius;
- int.TryParse(match.Value.Split('-')[1], out radius);
+ int.TryParse(match.Value.Split('-')[1], NumberStyles.Any, CultureInfo.InvariantCulture, out radius);
return radius;
}
diff --git a/src/ImageProcessor/Processors/Saturation.cs b/src/ImageProcessor/Processors/Saturation.cs
index 8d89fb880..268de2f4a 100644
--- a/src/ImageProcessor/Processors/Saturation.cs
+++ b/src/ImageProcessor/Processors/Saturation.cs
@@ -14,6 +14,7 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
+ using System.Globalization;
using System.Text.RegularExpressions;
#endregion
@@ -95,7 +96,7 @@ namespace ImageProcessor.Processors
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
- int percentage = int.Parse(match.Value.Split('=')[1]);
+ int percentage = int.Parse(match.Value.Split('=')[1], CultureInfo.InvariantCulture);
this.DynamicParameter = percentage;
}
diff --git a/src/ImageProcessor/Processors/Watermark.cs b/src/ImageProcessor/Processors/Watermark.cs
index 16a0368d9..586f04404 100644
--- a/src/ImageProcessor/Processors/Watermark.cs
+++ b/src/ImageProcessor/Processors/Watermark.cs
@@ -16,6 +16,7 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Text;
+ using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
@@ -370,7 +371,7 @@ namespace ImageProcessor.Processors
foreach (Match match in FontSizeRegex.Matches(input))
{
// split on size-value
- return int.Parse(match.Value.Split('-')[1]);
+ return int.Parse(match.Value.Split('-')[1], CultureInfo.InvariantCulture);
}
// Matches the default number in TextLayer.
@@ -449,7 +450,7 @@ namespace ImageProcessor.Processors
foreach (Match match in OpacityRegex.Matches(input))
{
// split on opacity-
- return int.Parse(match.Value.Split('-')[1]);
+ return int.Parse(match.Value.Split('-')[1], CultureInfo.InvariantCulture);
}
// full opacity - matches the Textlayer default.