diff --git a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj
index f8c863616..047451f26 100644
--- a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj
+++ b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj
@@ -72,6 +72,7 @@
+
@@ -90,6 +91,9 @@
ImageHelpers.cs
+
+ ResourceHelpers.cs
+
StartUp.cs
@@ -105,6 +109,15 @@
+
+ Config\Resources\cache.config
+
+
+ Config\Resources\processing.config
+
+
+ Config\Resources\security.config
+
Designer
diff --git a/src/ImageProcessor.Web/NET45/Config/ImageCacheSection.cs b/src/ImageProcessor.Web/NET45/Config/ImageCacheSection.cs
index b4b74f45d..6bda16a44 100644
--- a/src/ImageProcessor.Web/NET45/Config/ImageCacheSection.cs
+++ b/src/ImageProcessor.Web/NET45/Config/ImageCacheSection.cs
@@ -1,16 +1,22 @@
-// -----------------------------------------------------------------------
+// --------------------------------------------------------------------------------------------------------------------
//
-// Copyright (c) James South.
-// Licensed under the Apache License, Version 2.0.
+// Copyright (c) James South.
+// Licensed under the Apache License, Version 2.0.
//
-// -----------------------------------------------------------------------
+//
+// Represents an image cache section within a configuration file.
+//
+// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Web.Config
{
#region Using
using System.Configuration;
+ using System.IO;
+ using System.Xml;
using ImageProcessor.Extensions;
+ using ImageProcessor.Web.Helpers;
#endregion
@@ -24,7 +30,7 @@ namespace ImageProcessor.Web.Config
///
/// The name of the cache folder.
[ConfigurationProperty("virtualPath", DefaultValue = "~/app_data/cache", IsRequired = true)]
- [StringValidator(MinLength = 3, MaxLength = 200)]
+ [StringValidator(MinLength = 3, MaxLength = 256)]
public string VirtualPath
{
get
@@ -45,7 +51,7 @@ namespace ImageProcessor.Web.Config
///
/// The maximum number of days to store an image in the cache.
/// Defaults to 28 if not set.
- [ConfigurationProperty("maxDays", DefaultValue = "28", IsRequired = false)]
+ [ConfigurationProperty("maxDays", DefaultValue = "365", IsRequired = false)]
[IntegerValidator(ExcludeRange = false, MinValue = 0)]
public int MaxDays
{
@@ -73,7 +79,12 @@ namespace ImageProcessor.Web.Config
return imageCacheSection;
}
- return new ImageCacheSection();
+ string section = ResourceHelpers.ResourceAsString("ImageProcessor.Web.Config.Resources.cache.config");
+ XmlReader reader = new XmlTextReader(new StringReader(section));
+ imageCacheSection = new ImageCacheSection();
+ imageCacheSection.DeserializeSection(reader);
+
+ return imageCacheSection;
}
}
}
diff --git a/src/ImageProcessor.Web/NET45/Config/ImageProcessingSection.cs b/src/ImageProcessor.Web/NET45/Config/ImageProcessingSection.cs
index 1b0ed5952..7111521af 100644
--- a/src/ImageProcessor.Web/NET45/Config/ImageProcessingSection.cs
+++ b/src/ImageProcessor.Web/NET45/Config/ImageProcessingSection.cs
@@ -13,7 +13,10 @@ namespace ImageProcessor.Web.Config
{
#region Using
using System.Configuration;
+ using System.IO;
using System.Linq;
+ using System.Xml;
+ using ImageProcessor.Web.Helpers;
#endregion
///
@@ -69,7 +72,12 @@ namespace ImageProcessor.Web.Config
return imageProcessingSection;
}
- return new ImageProcessingSection();
+ string section = ResourceHelpers.ResourceAsString("ImageProcessor.Web.Config.Resources.processing.config");
+ XmlReader reader = new XmlTextReader(new StringReader(section));
+ imageProcessingSection = new ImageProcessingSection();
+ imageProcessingSection.DeserializeSection(reader);
+
+ return imageProcessingSection;
}
#endregion
diff --git a/src/ImageProcessor.Web/NET45/Config/ImageSecuritySection.cs b/src/ImageProcessor.Web/NET45/Config/ImageSecuritySection.cs
index dac3dd84e..824cf8277 100644
--- a/src/ImageProcessor.Web/NET45/Config/ImageSecuritySection.cs
+++ b/src/ImageProcessor.Web/NET45/Config/ImageSecuritySection.cs
@@ -13,6 +13,11 @@ namespace ImageProcessor.Web.Config
#region Using
using System;
using System.Configuration;
+ using System.IO;
+ using System.Xml;
+
+ using ImageProcessor.Web.Helpers;
+
#endregion
///
@@ -55,8 +60,8 @@ namespace ImageProcessor.Web.Config
/// Gets or sets the maximum allowed remote file size in bytes for the application.
///
/// The maximum number of days to store an image in the cache.
- /// Defaults to 524288 (512kb) if not set.
- [ConfigurationProperty("maxBytes", DefaultValue = "524288", IsRequired = true)]
+ /// Defaults to 4194304 (4Mb) if not set.
+ [ConfigurationProperty("maxBytes", DefaultValue = "4194304", IsRequired = true)]
public int MaxBytes
{
get
@@ -111,7 +116,12 @@ namespace ImageProcessor.Web.Config
return imageSecuritySection;
}
- return new ImageSecuritySection();
+ string section = ResourceHelpers.ResourceAsString("ImageProcessor.Web.Config.Resources.security.config");
+ XmlReader reader = new XmlTextReader(new StringReader(section));
+ imageSecuritySection = new ImageSecuritySection();
+ imageSecuritySection.DeserializeSection(reader);
+
+ return imageSecuritySection;
}
#endregion
diff --git a/src/ImageProcessor.Web/NET45/Config/Resources/cache.config b/src/ImageProcessor.Web/NET45/Config/Resources/cache.config
new file mode 100644
index 000000000..1caab6358
--- /dev/null
+++ b/src/ImageProcessor.Web/NET45/Config/Resources/cache.config
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/ImageProcessor.Web/NET45/Config/Resources/processing.config b/src/ImageProcessor.Web/NET45/Config/Resources/processing.config
new file mode 100644
index 000000000..0cb384b96
--- /dev/null
+++ b/src/ImageProcessor.Web/NET45/Config/Resources/processing.config
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ImageProcessor.Web/NET45/Config/Resources/security.config b/src/ImageProcessor.Web/NET45/Config/Resources/security.config
new file mode 100644
index 000000000..99cd3d3ff
--- /dev/null
+++ b/src/ImageProcessor.Web/NET45/Config/Resources/security.config
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/src/ImageProcessor.Web/NET45/Helpers/ResourceHelpers.cs b/src/ImageProcessor.Web/NET45/Helpers/ResourceHelpers.cs
new file mode 100644
index 000000000..fe8dc523b
--- /dev/null
+++ b/src/ImageProcessor.Web/NET45/Helpers/ResourceHelpers.cs
@@ -0,0 +1,56 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) James South.
+// Licensed under the Apache License, Version 2.0.
+//
+//
+// Provides helper methods for working with resources.
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace ImageProcessor.Web.Helpers
+{
+ using System.IO;
+ using System.Reflection;
+ using System.Text;
+
+ ///
+ /// Provides helper methods for working with resources.
+ ///
+ public class ResourceHelpers
+ {
+ ///
+ /// Converts an assembly resource into a string.
+ ///
+ ///
+ /// The resource.
+ ///
+ ///
+ /// The assembly.
+ ///
+ ///
+ /// The character encoding to return the resource in.
+ ///
+ ///
+ /// The .
+ ///
+ public static string ResourceAsString(string resource, Assembly assembly = null, Encoding encoding = null)
+ {
+ assembly = assembly ?? Assembly.GetExecutingAssembly();
+ encoding = encoding ?? Encoding.UTF8;
+
+ using (MemoryStream ms = new MemoryStream())
+ {
+ using (Stream manifestResourceStream = assembly.GetManifestResourceStream(resource))
+ {
+ if (manifestResourceStream != null)
+ {
+ manifestResourceStream.CopyTo(ms);
+ }
+ }
+
+ return encoding.GetString(ms.GetBuffer()).Replace('\0', ' ').Trim();
+ }
+ }
+ }
+}
diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj
index e40a4f641..10b2f0923 100644
--- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj
+++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj
@@ -57,6 +57,7 @@
+
@@ -72,6 +73,13 @@
+
+ Designer
+
+
+ Designer
+
+
diff --git a/src/ImageProcessor/Processors/Resize.cs b/src/ImageProcessor/Processors/Resize.cs
index d6d34390f..0c66e8de9 100644
--- a/src/ImageProcessor/Processors/Resize.cs
+++ b/src/ImageProcessor/Processors/Resize.cs
@@ -446,12 +446,19 @@ namespace ImageProcessor.Processors
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
- graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighQuality;
- graphics.Clear(backgroundColor);
- Rectangle destRect = new Rectangle(destinationX, destinationY, destinationWidth, destinationHeight);
- graphics.DrawImage(image, destRect, 0, 0, sourceWidth, sourceHeight, GraphicsUnit.Pixel);
+ // An unwanted border appears when using InterpolationMode.HighQualityBicubic to resize the image
+ // as the algorithm appears to be pulling averaging detail from surrounding pixels beyond the edge
+ // of the image. Using the ImageAttributes class to specify that the pixels beyond are simply mirror
+ // images of the pixels within solves this problem.
+ using (ImageAttributes wrapMode = new ImageAttributes())
+ {
+ wrapMode.SetWrapMode(WrapMode.TileFlipXY);
+ graphics.Clear(backgroundColor);
+ Rectangle destRect = new Rectangle(destinationX, destinationY, destinationWidth, destinationHeight);
+ graphics.DrawImage(image, destRect, 0, 0, sourceWidth, sourceHeight, GraphicsUnit.Pixel, wrapMode);
+ }
// Reassign the image.
image.Dispose();
diff --git a/src/Nuget/ImageProcessor.Web.Config.1.0.0.0.nupkg b/src/Nuget/ImageProcessor.Web.Config.1.0.0.0.nupkg
new file mode 100644
index 000000000..3acf89cfb
Binary files /dev/null and b/src/Nuget/ImageProcessor.Web.Config.1.0.0.0.nupkg differ