From 0a1c0bafb07a498cc27c9e68486ff2b60dde762d Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 10 Jun 2014 00:42:30 +0200 Subject: [PATCH 001/155] Initial commit THIS WON'T BUILD JUST NOW. Former-commit-id: 89c0a9c493cd0adb90638b5ebc79ef5b82f8a902 --- .../NET45/Caching/DiskCache.cs | 8 +- .../NET45/Config/ImageCacheSection.cs | 4 +- .../NET45/Config/ImageProcessingSection.cs | 2 +- ...nfig.cs => ImageProcessorConfiguration.cs} | 12 +- .../NET45/Config/ImageSecuritySection.cs | 2 +- .../NET45/Helpers/ParameterParserUtilities.cs | 90 +++++ .../NET45/Helpers/RemoteFile.cs | 12 +- .../HttpModules/ImageProcessingModule.cs | 13 +- .../NET45/ImageFactoryExtensions.cs | 71 +--- .../NET45/ImageProcessor.Web_NET45.csproj | 6 +- .../NET45/Processors/BackgroundColor.cs | 88 +++++ .../NET45/Processors/IWebGraphicsProcessor.cs | 51 +++ .../NET45/Processors/Rotate.cs | 96 +++++ .../NET45/Processors/RoundedCorners.cs | 24 ++ .../ImageProcessorBootstrapper.cs | 81 +++++ .../Common/Exceptions/ImageFormatException.cs | 39 ++ .../Exceptions/ImageProcessingException.cs | 39 ++ .../Common}/Extensions/DoubleExtensions.cs | 2 +- .../Common}/Extensions/ImageExtensions.cs | 3 +- .../Extensions/ImageFormatExtensions.cs | 4 +- .../{ => Core/Common}/Extensions/ImageInfo.cs | 3 +- .../Common}/Extensions/IntegerExtensions.cs | 2 +- .../Common}/Extensions/StringExtensions.cs | 4 +- src/ImageProcessor/ImageFactory.cs | 332 +++++------------- src/ImageProcessor/ImageProcessor.csproj | 24 +- src/ImageProcessor/Imaging/Convolution.cs | 3 +- .../Imaging/Filters/ComicMatrixFilter.cs | 2 +- .../Imaging/Formats/BitmapFormat.cs | 65 ++++ .../Imaging/Formats/FormatBase.cs | 123 +++++++ .../Imaging/Formats/FormatUtilities.cs | 88 +++++ .../Imaging/Formats/GifFormat.cs | 149 ++++++++ .../Imaging/Formats/ISupportedImageFormat.cs | 113 ++++++ .../Imaging/Formats/JpegFormat.cs | 155 ++++++++ .../Imaging/Formats/PngFormat.cs | 103 ++++++ .../Imaging/Formats/TiffFormat.cs | 96 +++++ .../Processors/BackgroundColor.cs | 74 ++++ src/ImageProcessor/Processors/Crop.cs | 2 +- src/ImageProcessor/Processors/Format.cs | 3 +- .../Processors/IGraphicsProcessor.cs | 27 +- src/ImageProcessor/Processors/Quality.cs | 2 +- src/ImageProcessor/Processors/Resize.cs | 3 +- src/ImageProcessor/Processors/Rotate.cs | 150 +------- src/ImageProcessor/Processors/Tint.cs | 3 +- src/ImageProcessor/Processors/Watermark.cs | 2 +- src/ImageProcessor/Settings.StyleCop | 2 + src/ImageProcessorConsole/Program.cs | 4 +- .../images/output/120430.gif.REMOVED.git-id | 2 +- .../images/output/nLpfllv.gif.REMOVED.git-id | 2 +- 48 files changed, 1659 insertions(+), 526 deletions(-) rename src/ImageProcessor.Web/NET45/Config/{ImageProcessorConfig.cs => ImageProcessorConfiguration.cs} (97%) create mode 100644 src/ImageProcessor.Web/NET45/Helpers/ParameterParserUtilities.cs create mode 100644 src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs create mode 100644 src/ImageProcessor.Web/NET45/Processors/IWebGraphicsProcessor.cs create mode 100644 src/ImageProcessor.Web/NET45/Processors/Rotate.cs create mode 100644 src/ImageProcessor.Web/NET45/Processors/RoundedCorners.cs create mode 100644 src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs create mode 100644 src/ImageProcessor/Core/Common/Exceptions/ImageFormatException.cs create mode 100644 src/ImageProcessor/Core/Common/Exceptions/ImageProcessingException.cs rename src/ImageProcessor/{ => Core/Common}/Extensions/DoubleExtensions.cs (96%) rename src/ImageProcessor/{ => Core/Common}/Extensions/ImageExtensions.cs (98%) rename src/ImageProcessor/{ => Core/Common}/Extensions/ImageFormatExtensions.cs (98%) rename src/ImageProcessor/{ => Core/Common}/Extensions/ImageInfo.cs (97%) rename src/ImageProcessor/{ => Core/Common}/Extensions/IntegerExtensions.cs (97%) rename src/ImageProcessor/{ => Core/Common}/Extensions/StringExtensions.cs (99%) create mode 100644 src/ImageProcessor/Imaging/Formats/BitmapFormat.cs create mode 100644 src/ImageProcessor/Imaging/Formats/FormatBase.cs create mode 100644 src/ImageProcessor/Imaging/Formats/FormatUtilities.cs create mode 100644 src/ImageProcessor/Imaging/Formats/GifFormat.cs create mode 100644 src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs create mode 100644 src/ImageProcessor/Imaging/Formats/JpegFormat.cs create mode 100644 src/ImageProcessor/Imaging/Formats/PngFormat.cs create mode 100644 src/ImageProcessor/Imaging/Formats/TiffFormat.cs create mode 100644 src/ImageProcessor/Processors/BackgroundColor.cs diff --git a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs index 8052e0540..5b0562dc6 100644 --- a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs +++ b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs @@ -21,8 +21,8 @@ namespace ImageProcessor.Web.Caching using System.Web; using System.Web.Hosting; - using ImageProcessor.Extensions; - using ImageProcessor.Web.Config; + using ImageProcessor.Core.Common.Extensions; + using ImageProcessor.Web.Configuration; using ImageProcessor.Web.Helpers; #endregion @@ -35,7 +35,7 @@ namespace ImageProcessor.Web.Caching /// /// The maximum number of days to cache files on the system for. /// - internal static readonly int MaxFileCachedDuration = ImageProcessorConfig.Instance.MaxCacheDays; + internal static readonly int MaxFileCachedDuration = ImageProcessorConfiguration.Instance.MaxCacheDays; /// /// The maximum number of files allowed in the directory. @@ -53,7 +53,7 @@ namespace ImageProcessor.Web.Caching /// The absolute path to virtual cache path on the server. /// private static readonly string AbsoluteCachePath = - HostingEnvironment.MapPath(ImageProcessorConfig.Instance.VirtualCachePath); + HostingEnvironment.MapPath(ImageProcessorConfiguration.Instance.VirtualCachePath); /// /// The request for the image. diff --git a/src/ImageProcessor.Web/NET45/Config/ImageCacheSection.cs b/src/ImageProcessor.Web/NET45/Config/ImageCacheSection.cs index 6bda16a44..27e5320c3 100644 --- a/src/ImageProcessor.Web/NET45/Config/ImageCacheSection.cs +++ b/src/ImageProcessor.Web/NET45/Config/ImageCacheSection.cs @@ -8,14 +8,14 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Web.Config +namespace ImageProcessor.Web.Configuration { #region Using using System.Configuration; using System.IO; using System.Xml; - using ImageProcessor.Extensions; + using ImageProcessor.Core.Common.Extensions; using ImageProcessor.Web.Helpers; #endregion diff --git a/src/ImageProcessor.Web/NET45/Config/ImageProcessingSection.cs b/src/ImageProcessor.Web/NET45/Config/ImageProcessingSection.cs index d1018ba89..3942280f6 100644 --- a/src/ImageProcessor.Web/NET45/Config/ImageProcessingSection.cs +++ b/src/ImageProcessor.Web/NET45/Config/ImageProcessingSection.cs @@ -9,7 +9,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Web.Config +namespace ImageProcessor.Web.Configuration { #region Using using System.Configuration; diff --git a/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs b/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfiguration.cs similarity index 97% rename from src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs rename to src/ImageProcessor.Web/NET45/Config/ImageProcessorConfiguration.cs index c85c25039..2bcf73d78 100644 --- a/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs +++ b/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfiguration.cs @@ -8,7 +8,7 @@ // // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Web.Config +namespace ImageProcessor.Web.Configuration { #region Using using System; @@ -24,15 +24,15 @@ namespace ImageProcessor.Web.Config /// Encapsulates methods to allow the retrieval of ImageProcessor settings. /// /// - public sealed class ImageProcessorConfig + public sealed class ImageProcessorConfiguration { #region Fields /// /// A new instance Initializes a new instance of the class. /// with lazy initialization. /// - private static readonly Lazy Lazy = - new Lazy(() => new ImageProcessorConfig()); + private static readonly Lazy Lazy = + new Lazy(() => new ImageProcessorConfiguration()); /// /// A collection of the elements @@ -67,7 +67,7 @@ namespace ImageProcessor.Web.Config /// /// Prevents a default instance of the class from being created. /// - private ImageProcessorConfig() + private ImageProcessorConfiguration() { this.LoadGraphicsProcessors(); } @@ -77,7 +77,7 @@ namespace ImageProcessor.Web.Config /// /// Gets the current instance of the class. /// - public static ImageProcessorConfig Instance + public static ImageProcessorConfiguration Instance { get { diff --git a/src/ImageProcessor.Web/NET45/Config/ImageSecuritySection.cs b/src/ImageProcessor.Web/NET45/Config/ImageSecuritySection.cs index 824cf8277..29079fdc2 100644 --- a/src/ImageProcessor.Web/NET45/Config/ImageSecuritySection.cs +++ b/src/ImageProcessor.Web/NET45/Config/ImageSecuritySection.cs @@ -8,7 +8,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Web.Config +namespace ImageProcessor.Web.Configuration { #region Using using System; diff --git a/src/ImageProcessor.Web/NET45/Helpers/ParameterParserUtilities.cs b/src/ImageProcessor.Web/NET45/Helpers/ParameterParserUtilities.cs new file mode 100644 index 000000000..eb6af4357 --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Helpers/ParameterParserUtilities.cs @@ -0,0 +1,90 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Encapsulates methods to correctly parse querystring parameters. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Helpers +{ + using System.Drawing; + using System.Globalization; + using System.Text.RegularExpressions; + using ImageProcessor.Core.Common.Extensions; + + /// + /// Encapsulates methods to correctly parse querystring parameters. + /// + public static class ParameterParserUtilities + { + /// + /// 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); + + /// + /// The regular expression to search strings for angles. + /// + private static readonly Regex AngleRegex = new Regex(@"(rotate|angle)(=|-)(?:3[0-5][0-9]|[12][0-9]{2}|[1-9][0-9]?)", RegexOptions.Compiled); + + /// + /// Returns the correct containing the angle for the given string. + /// + /// + /// The input string containing the value to parse. + /// + /// + /// The correct containing the angle for the given string. + /// + public static int ParseAngle(string input) + { + foreach (Match match in AngleRegex.Matches(input)) + { + // Split on angle + int angle; + string value = match.Value.Split(new[] { '=', '-' })[1]; + int.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out angle); + return angle; + } + + // No rotate - matches the RotateLayer default. + return 0; + } + + /// + /// Returns the correct for the given string. + /// + /// + /// The input string containing the value to parse. + /// + /// + /// The correct + /// + public static Color ParseColor(string input) + { + foreach (Match match in ColorRegex.Matches(input)) + { + string value = match.Value.Split(new[] { '=', '-' })[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; + } + } +} diff --git a/src/ImageProcessor.Web/NET45/Helpers/RemoteFile.cs b/src/ImageProcessor.Web/NET45/Helpers/RemoteFile.cs index 05c2f9753..1fa38568c 100644 --- a/src/ImageProcessor.Web/NET45/Helpers/RemoteFile.cs +++ b/src/ImageProcessor.Web/NET45/Helpers/RemoteFile.cs @@ -19,7 +19,7 @@ namespace ImageProcessor.Web.Helpers using System.Security; using System.Text; using System.Threading.Tasks; - using ImageProcessor.Web.Config; + using ImageProcessor.Web.Configuration; #endregion /// @@ -48,27 +48,27 @@ namespace ImageProcessor.Web.Helpers /// /// The white-list of url[s] from which to download remote files. /// - public static readonly ImageSecuritySection.SafeUrl[] RemoteFileWhiteListExtensions = ImageProcessorConfig.Instance.RemoteFileWhiteListExtensions; + public static readonly ImageSecuritySection.SafeUrl[] RemoteFileWhiteListExtensions = ImageProcessorConfiguration.Instance.RemoteFileWhiteListExtensions; /// /// The white-list of url[s] from which to download remote files. /// - private static readonly Uri[] RemoteFileWhiteList = ImageProcessorConfig.Instance.RemoteFileWhiteList; + private static readonly Uri[] RemoteFileWhiteList = ImageProcessorConfiguration.Instance.RemoteFileWhiteList; /// /// The length of time, in milliseconds, that a remote file download attempt can last before timing out. /// - private static readonly int TimeoutMilliseconds = ImageProcessorConfig.Instance.Timeout; + private static readonly int TimeoutMilliseconds = ImageProcessorConfiguration.Instance.Timeout; /// /// The maximum size, in bytes, that a remote file download attempt can download. /// - private static readonly int MaxBytes = ImageProcessorConfig.Instance.MaxBytes; + private static readonly int MaxBytes = ImageProcessorConfiguration.Instance.MaxBytes; /// /// Whether to allow remote downloads. /// - private static readonly bool AllowRemoteDownloads = ImageProcessorConfig.Instance.AllowRemoteDownloads; + private static readonly bool AllowRemoteDownloads = ImageProcessorConfiguration.Instance.AllowRemoteDownloads; /// /// Whether this RemoteFile instance is ignoring remote download rules set in the current application diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index efcbdc2ed..6d10a49ee 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -28,9 +28,10 @@ namespace ImageProcessor.Web.HttpModules using System.Web; using System.Web.Hosting; using System.Web.Security; - using ImageProcessor.Extensions; + + using ImageProcessor.Core.Common.Extensions; using ImageProcessor.Web.Caching; - using ImageProcessor.Web.Config; + using ImageProcessor.Web.Configuration; using ImageProcessor.Web.Helpers; #endregion @@ -117,12 +118,12 @@ namespace ImageProcessor.Web.HttpModules { if (remotePrefix == null) { - remotePrefix = ImageProcessorConfig.Instance.RemotePrefix; + remotePrefix = ImageProcessorConfiguration.Instance.RemotePrefix; } if (preserveExifMetaData == null) { - preserveExifMetaData = ImageProcessorConfig.Instance.PreserveExifMetaData; + preserveExifMetaData = ImageProcessorConfiguration.Instance.PreserveExifMetaData; } #if NET45 @@ -453,7 +454,7 @@ namespace ImageProcessor.Web.HttpModules imageFactory.Load(fullPath).AutoProcess().Save(cachedPath); // Store the response type in the context for later retrieval. - context.Items[CachedResponseTypeKey] = imageFactory.MimeType; + context.Items[CachedResponseTypeKey] = imageFactory.CurrentImageFormat.MimeType; // Ensure that the LastWriteTime property of the source and cached file match. Tuple creationAndLastWriteDateTimes = await cache.SetCachedLastWriteTimeAsync(); @@ -555,7 +556,7 @@ namespace ImageProcessor.Web.HttpModules string preset = match.Value.Split('=')[1]; // We use the processor config system to store the preset values. - string replacements = ImageProcessorConfig.Instance.GetPresetSettings(preset); + string replacements = ImageProcessorConfiguration.Instance.GetPresetSettings(preset); queryString = Regex.Replace(queryString, preset, replacements ?? string.Empty); } } diff --git a/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs b/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs index 0c8788cd9..c677149fb 100644 --- a/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs +++ b/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs @@ -11,17 +11,10 @@ namespace ImageProcessor.Web { #region Using - - using System; using System.Collections.Generic; - using System.Drawing; - using System.Drawing.Imaging; - using System.IO; using System.Linq; - using ImageProcessor.Extensions; - using ImageProcessor.Imaging; using ImageProcessor.Processors; - using ImageProcessor.Web.Config; + using ImageProcessor.Web.Configuration; #endregion /// @@ -53,7 +46,7 @@ namespace ImageProcessor.Web { // Get a list of all graphics processors that have parsed and matched the query string. List graphicsProcessors = - ImageProcessorConfig.Instance.GraphicsProcessors + ImageProcessorConfiguration.Instance.GraphicsProcessors .Where(x => x.MatchRegexIndex(factory.QueryString) != int.MaxValue) .OrderBy(y => y.SortOrder) .ToList(); @@ -61,70 +54,12 @@ namespace ImageProcessor.Web // Loop through and process the image. foreach (IGraphicsProcessor graphicsProcessor in graphicsProcessors) { - ApplyProcessor(graphicsProcessor.ProcessImage, factory); + factory.CurrentImageFormat.ApplyProcessor(graphicsProcessor.ProcessImage, factory); } } } return factory; } - - /// - /// Processes the image. - /// - /// - /// The processor. - /// - /// - /// The factory. - /// - private static void ApplyProcessor(Func processor, ImageFactory factory) - { - ImageInfo imageInfo = factory.Image.GetImageInfo(factory.ImageFormat); - - if (imageInfo.IsAnimated) - { - OctreeQuantizer quantizer = new OctreeQuantizer(255, 8); - - // We don't dispose of the memory stream as that is disposed when a new image is created and doing so - // beforehand will cause an exception. - MemoryStream stream = new MemoryStream(); - using (GifEncoder encoder = new GifEncoder(stream, null, null, imageInfo.LoopCount)) - { - foreach (GifFrame frame in imageInfo.GifFrames) - { - factory.Update(frame.Image); - frame.Image = quantizer.Quantize(processor.Invoke(factory)); - encoder.AddFrame(frame); - } - } - - stream.Position = 0; - factory.Update(Image.FromStream(stream)); - } - else - { - factory.Update(processor.Invoke(factory)); - } - - // Set the property item information from any Exif metadata. - // We do this here so that they can be changed between processor methods. - if (factory.PreserveExifData) - { - foreach (KeyValuePair propertItem in factory.ExifPropertyItems) - { - try - { - factory.Image.SetPropertyItem(propertItem.Value); - } - // ReSharper disable once EmptyGeneralCatchClause - catch - { - // Do nothing. The image format does not handle EXIF data. - // TODO: empty catch is fierce code smell. - } - } - } - } } } diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj index 23cc45e96..bdf8ba8dc 100644 --- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj +++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj @@ -51,14 +51,18 @@ - + + + + + diff --git a/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs b/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs new file mode 100644 index 000000000..7fc0a49a5 --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs @@ -0,0 +1,88 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Changes the background color of an image. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Processors +{ + using System.Text.RegularExpressions; + using ImageProcessor.Processors; + using ImageProcessor.Web.Helpers; + + /// + /// Changes the background color of an image. + /// + public class BackgroundColor : IWebGraphicsProcessor + { + /// + /// The regular expression to search strings for. + /// + private static readonly Regex QueryRegex = new Regex(@"bgcolor(=|-)[^&|,]*", RegexOptions.Compiled); + + /// + /// Initializes a new instance of the class. + /// + public BackgroundColor() + { + this.Processor = new ImageProcessor.Processors.BackgroundColor(); + } + + /// + /// 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 = ParameterParserUtilities.ParseColor(match.Value); + } + + index += 1; + } + } + + return this.SortOrder; + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET45/Processors/IWebGraphicsProcessor.cs b/src/ImageProcessor.Web/NET45/Processors/IWebGraphicsProcessor.cs new file mode 100644 index 000000000..b15d86d30 --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Processors/IWebGraphicsProcessor.cs @@ -0,0 +1,51 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Defines properties and methods for ImageProcessor.Web Plugins. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Processors +{ + using System.Text.RegularExpressions; + using ImageProcessor.Processors; + + /// + /// Defines properties and methods for ImageProcessor.Web Plugins. + /// + public interface IWebGraphicsProcessor + { + #region Properties + /// + /// Gets the regular expression to search strings for. + /// + Regex RegexPattern { get; } + + /// + /// Gets the order in which this processor is to be used in a chain. + /// + int SortOrder { get; } + + /// + /// Gets the associated graphics processor. + /// + IGraphicsProcessor Processor { get; } + #endregion + + #region Methods + /// + /// 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. + /// + int MatchRegexIndex(string queryString); + #endregion + } +} diff --git a/src/ImageProcessor.Web/NET45/Processors/Rotate.cs b/src/ImageProcessor.Web/NET45/Processors/Rotate.cs new file mode 100644 index 000000000..58375b179 --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Processors/Rotate.cs @@ -0,0 +1,96 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Encapsulates methods to rotate an image. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Processors +{ + using System.Text.RegularExpressions; + using ImageProcessor.Processors; + using ImageProcessor.Web.Helpers; + + /// + /// Encapsulates methods to rotate an image. + /// + public class Rotate : IWebGraphicsProcessor + { + /// + /// The regular expression to search strings for. + /// + private static readonly Regex QueryRegex = new Regex(@"(rotate|angle)(=|-)[^&|,]*", RegexOptions.Compiled); + + /// + /// Initializes a new instance of the class. + /// + public Rotate() + { + this.Processor = new ImageProcessor.Processors.Rotate(); + } + + #region IGraphicsProcessor Members + /// + /// 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 = ParameterParserUtilities.ParseAngle(match.Value); + } + + index += 1; + } + } + + return this.SortOrder; + } + #endregion + } +} diff --git a/src/ImageProcessor.Web/NET45/Processors/RoundedCorners.cs b/src/ImageProcessor.Web/NET45/Processors/RoundedCorners.cs new file mode 100644 index 000000000..d09d19bba --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Processors/RoundedCorners.cs @@ -0,0 +1,24 @@ + +namespace ImageProcessor.Web.Processors +{ + using System; + using System.Text.RegularExpressions; + using ImageProcessor.Processors; + + /// + /// Encapsulates methods to add rounded corners to an image. + /// + public class RoundedCorners : IWebGraphicsProcessor + { + public Regex RegexPattern { get; private set; } + + public int SortOrder { get; private set; } + + public IGraphicsProcessor Processor { get; private set; } + + public int MatchRegexIndex(string queryString) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs new file mode 100644 index 000000000..594ce5185 --- /dev/null +++ b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs @@ -0,0 +1,81 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// The image processor bootstrapper. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Configuration +{ + using System; + using System.Collections.Generic; + using System.Linq; + using ImageProcessor.Core.Common.Exceptions; + using ImageProcessor.Imaging.Formats; + + /// + /// The image processor bootstrapper. + /// + public class ImageProcessorBootstrapper + { + /// + /// A new instance Initializes a new instance of the class. + /// with lazy initialization. + /// + private static readonly Lazy Lazy = + new Lazy(() => new ImageProcessorBootstrapper()); + + /// + /// Prevents a default instance of the class from being created. + /// + private ImageProcessorBootstrapper() + { + this.LoadSupportedImageFormats(); + } + + /// + /// Gets the current instance of the class. + /// + public static ImageProcessorBootstrapper Instance + { + get + { + return Lazy.Value; + } + } + + /// + /// Gets the supported image formats. + /// + public IEnumerable SupportedImageFormats { get; private set; } + + /// + /// Creates a list, using reflection, of supported image formats that ImageProcessor can run. + /// + private void LoadSupportedImageFormats() + { + if (this.SupportedImageFormats == null) + { + try + { + Type type = typeof(ISupportedImageFormat); + List availableTypes = AppDomain.CurrentDomain + .GetAssemblies() + .SelectMany(s => s.GetTypes()) + .Where(t => t != null && type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract) + .ToList(); + + this.SupportedImageFormats = availableTypes + .Select(x => (Activator.CreateInstance(x) as ISupportedImageFormat)).ToList(); + } + catch (Exception ex) + { + throw new ImageFormatException(ex.Message, ex.InnerException); + } + } + } + } +} diff --git a/src/ImageProcessor/Core/Common/Exceptions/ImageFormatException.cs b/src/ImageProcessor/Core/Common/Exceptions/ImageFormatException.cs new file mode 100644 index 000000000..0469e33d4 --- /dev/null +++ b/src/ImageProcessor/Core/Common/Exceptions/ImageFormatException.cs @@ -0,0 +1,39 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// The exception that is thrown when loading the supported image format types has failed. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Core.Common.Exceptions +{ + using System; + + /// + /// The exception that is thrown when loading the supported image format types has failed. + /// + public sealed class ImageFormatException : Exception + { + /// + /// Initializes a new instance of the class. + /// + /// The message that describes the error. + public ImageFormatException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified. + public ImageFormatException(string message, Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/src/ImageProcessor/Core/Common/Exceptions/ImageProcessingException.cs b/src/ImageProcessor/Core/Common/Exceptions/ImageProcessingException.cs new file mode 100644 index 000000000..db1adf2a6 --- /dev/null +++ b/src/ImageProcessor/Core/Common/Exceptions/ImageProcessingException.cs @@ -0,0 +1,39 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// The exception that is thrown when processing an image has failed. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Core.Common.Exceptions +{ + using System; + + /// + /// The exception that is thrown when processing an image has failed. + /// + public sealed class ImageProcessingException : Exception + { + /// + /// Initializes a new instance of the class. + /// + /// The message that describes the error. + public ImageProcessingException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified. + public ImageProcessingException(string message, Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/src/ImageProcessor/Extensions/DoubleExtensions.cs b/src/ImageProcessor/Core/Common/Extensions/DoubleExtensions.cs similarity index 96% rename from src/ImageProcessor/Extensions/DoubleExtensions.cs rename to src/ImageProcessor/Core/Common/Extensions/DoubleExtensions.cs index a21817df1..a8980c5c6 100644 --- a/src/ImageProcessor/Extensions/DoubleExtensions.cs +++ b/src/ImageProcessor/Core/Common/Extensions/DoubleExtensions.cs @@ -8,7 +8,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Extensions +namespace ImageProcessor.Core.Common.Extensions { /// /// Encapsulates a series of time saving extension methods to the class. diff --git a/src/ImageProcessor/Extensions/ImageExtensions.cs b/src/ImageProcessor/Core/Common/Extensions/ImageExtensions.cs similarity index 98% rename from src/ImageProcessor/Extensions/ImageExtensions.cs rename to src/ImageProcessor/Core/Common/Extensions/ImageExtensions.cs index a4134016e..cff34a9f8 100644 --- a/src/ImageProcessor/Extensions/ImageExtensions.cs +++ b/src/ImageProcessor/Core/Common/Extensions/ImageExtensions.cs @@ -8,12 +8,13 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Extensions +namespace ImageProcessor.Core.Common.Extensions { using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; + using ImageProcessor.Imaging; /// diff --git a/src/ImageProcessor/Extensions/ImageFormatExtensions.cs b/src/ImageProcessor/Core/Common/Extensions/ImageFormatExtensions.cs similarity index 98% rename from src/ImageProcessor/Extensions/ImageFormatExtensions.cs rename to src/ImageProcessor/Core/Common/Extensions/ImageFormatExtensions.cs index 036a4153e..dcdaa4550 100644 --- a/src/ImageProcessor/Extensions/ImageFormatExtensions.cs +++ b/src/ImageProcessor/Core/Common/Extensions/ImageFormatExtensions.cs @@ -9,11 +9,13 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Extensions +namespace ImageProcessor.Core.Common.Extensions { #region + using System.Drawing.Imaging; using System.Linq; + #endregion /// diff --git a/src/ImageProcessor/Extensions/ImageInfo.cs b/src/ImageProcessor/Core/Common/Extensions/ImageInfo.cs similarity index 97% rename from src/ImageProcessor/Extensions/ImageInfo.cs rename to src/ImageProcessor/Core/Common/Extensions/ImageInfo.cs index 720eb5a20..41ef6f5b0 100644 --- a/src/ImageProcessor/Extensions/ImageInfo.cs +++ b/src/ImageProcessor/Core/Common/Extensions/ImageInfo.cs @@ -9,9 +9,10 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Extensions +namespace ImageProcessor.Core.Common.Extensions { using System.Collections.Generic; + using ImageProcessor.Imaging; /// diff --git a/src/ImageProcessor/Extensions/IntegerExtensions.cs b/src/ImageProcessor/Core/Common/Extensions/IntegerExtensions.cs similarity index 97% rename from src/ImageProcessor/Extensions/IntegerExtensions.cs rename to src/ImageProcessor/Core/Common/Extensions/IntegerExtensions.cs index d969e780e..c4aa90bd8 100644 --- a/src/ImageProcessor/Extensions/IntegerExtensions.cs +++ b/src/ImageProcessor/Core/Common/Extensions/IntegerExtensions.cs @@ -8,7 +8,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Extensions +namespace ImageProcessor.Core.Common.Extensions { using System.Globalization; diff --git a/src/ImageProcessor/Extensions/StringExtensions.cs b/src/ImageProcessor/Core/Common/Extensions/StringExtensions.cs similarity index 99% rename from src/ImageProcessor/Extensions/StringExtensions.cs rename to src/ImageProcessor/Core/Common/Extensions/StringExtensions.cs index 318146a9b..a60590f66 100644 --- a/src/ImageProcessor/Extensions/StringExtensions.cs +++ b/src/ImageProcessor/Core/Common/Extensions/StringExtensions.cs @@ -8,15 +8,17 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Extensions +namespace ImageProcessor.Core.Common.Extensions { #region Using + using System; using System.Globalization; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; + #endregion /// diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index b88c3d3bf..8d9b34f75 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -14,15 +14,15 @@ namespace ImageProcessor using System; using System.Collections.Concurrent; using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; - using System.Threading; - using ImageProcessor.Extensions; + + using ImageProcessor.Core.Common.Exceptions; using ImageProcessor.Imaging; using ImageProcessor.Imaging.Filters; + using ImageProcessor.Imaging.Formats; using ImageProcessor.Processors; #endregion @@ -33,24 +33,14 @@ namespace ImageProcessor { #region Fields /// - /// The default quality for jpeg files. - /// - private const int DefaultJpegQuality = 90; - - /// - /// The backup image format. - /// - private ImageFormat backupImageFormat; - - /// - /// The memory stream for storing any input stream to prevent disposal. + /// The default quality for image files. /// - private MemoryStream inputStream; + private const int DefaultQuality = 90; /// - /// Whether the image is indexed. + /// The backup supported image format. /// - private bool isIndexed; + private ISupportedImageFormat backupFormat; /// /// A value indicating whether this instance of the given entity has been disposed. @@ -122,20 +112,9 @@ namespace ImageProcessor public bool ShouldProcess { get; private set; } /// - /// Gets the file format of the image. + /// Gets the supported image format. /// - public ImageFormat ImageFormat { get; private set; } - - /// - /// Gets the mime type. - /// - public string MimeType - { - get - { - return this.ImageFormat.GetMimeType(); - } - } + public ISupportedImageFormat CurrentImageFormat { get; private set; } /// /// Gets or sets a value indicating whether to preserve exif metadata. @@ -153,9 +132,9 @@ namespace ImageProcessor internal string OriginalExtension { get; set; } /// - /// Gets or sets the quality of output for jpeg images as a percentile. + /// Gets or sets the memory stream for storing any input stream to prevent disposal. /// - internal int JpegQuality { get; set; } + internal MemoryStream InputStream { get; set; } #endregion #region Methods @@ -170,17 +149,25 @@ namespace ImageProcessor /// public ImageFactory Load(MemoryStream memoryStream) { + ISupportedImageFormat format = FormatUtilities.GetFormat(memoryStream); + + if (format == null) + { + throw new ImageFormatException("Input stream is not a supported format."); + } + + this.backupFormat = format; + this.CurrentImageFormat = format; + // Set our image as the memory stream value. - this.Image = Image.FromStream(memoryStream, true); + this.Image = format.Load(memoryStream); // Store the stream so we can dispose of it later. - this.inputStream = memoryStream; + this.InputStream = memoryStream; // Set the other properties. - this.JpegQuality = DefaultJpegQuality; - this.ImageFormat = this.Image.RawFormat; - this.backupImageFormat = this.ImageFormat; - this.isIndexed = ImageUtils.IsIndexed(this.Image); + format.Quality = DefaultQuality; + format.IsIndexed = ImageUtils.IsIndexed(this.Image); if (this.PreserveExifData) { @@ -222,6 +209,16 @@ namespace ImageProcessor // Open a file stream to prevent the need for lock. using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { + ISupportedImageFormat format = FormatUtilities.GetFormat(fileStream); + + if (format == null) + { + throw new ImageFormatException("Input stream is not a supported format."); + } + + this.backupFormat = format; + this.CurrentImageFormat = format; + MemoryStream memoryStream = new MemoryStream(); // Copy the stream. @@ -231,18 +228,16 @@ namespace ImageProcessor fileStream.Position = memoryStream.Position = 0; // Set our image as the memory stream value. - this.Image = Image.FromStream(memoryStream, true); + this.Image = format.Load(memoryStream); // Store the stream so we can dispose of it later. - this.inputStream = memoryStream; + this.InputStream = memoryStream; // Set the other properties. - this.JpegQuality = DefaultJpegQuality; - ImageFormat imageFormat = this.Image.RawFormat; - this.backupImageFormat = imageFormat; + format.Quality = DefaultQuality; + format.IsIndexed = ImageUtils.IsIndexed(this.Image); + this.OriginalExtension = Path.GetExtension(this.ImagePath); - this.ImageFormat = imageFormat; - this.isIndexed = ImageUtils.IsIndexed(this.Image); if (this.PreserveExifData) { @@ -271,6 +266,16 @@ namespace ImageProcessor if (this.ShouldProcess) { this.Image = image; + + // Get the correct image format for the image. + using (MemoryStream stream = new MemoryStream()) + { + image.Save(stream, image.RawFormat); + stream.Position = 0; + int quality = this.CurrentImageFormat.Quality; + this.CurrentImageFormat = FormatUtilities.GetFormat(stream); + this.CurrentImageFormat.Quality = quality; + } } return this; @@ -287,16 +292,15 @@ namespace ImageProcessor if (this.ShouldProcess) { // Set our new image as the memory stream value. - Image newImage = Image.FromStream(this.inputStream, true); + Image newImage = Image.FromStream(this.InputStream, true); // Dispose and reassign the image. this.Image.Dispose(); this.Image = newImage; // Set the other properties. - this.JpegQuality = DefaultJpegQuality; - this.ImageFormat = this.backupImageFormat; - this.isIndexed = ImageUtils.IsIndexed(this.Image); + this.CurrentImageFormat = this.backupFormat; + this.CurrentImageFormat.Quality = DefaultQuality; } return this; @@ -312,6 +316,7 @@ namespace ImageProcessor /// public ImageFactory AddQueryString(string query) { + // TODO: Remove this. if (this.ShouldProcess) { this.QueryString = query; @@ -341,7 +346,7 @@ namespace ImageProcessor } Alpha alpha = new Alpha { DynamicParameter = percentage }; - this.ApplyProcessor(alpha.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(alpha.ProcessImage, this); } return this; @@ -368,7 +373,7 @@ namespace ImageProcessor } Brightness brightness = new Brightness { DynamicParameter = percentage }; - this.ApplyProcessor(brightness.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(brightness.ProcessImage, this); } return this; @@ -416,7 +421,7 @@ namespace ImageProcessor } Contrast contrast = new Contrast { DynamicParameter = percentage }; - this.ApplyProcessor(contrast.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(contrast.ProcessImage, this); } return this; @@ -456,7 +461,7 @@ namespace ImageProcessor if (this.ShouldProcess) { Crop crop = new Crop { DynamicParameter = cropLayer }; - this.ApplyProcessor(crop.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(crop.ProcessImage, this); } return this; @@ -477,7 +482,7 @@ namespace ImageProcessor if (this.ShouldProcess) { Filter filter = new Filter { DynamicParameter = filterName }; - this.ApplyProcessor(filter.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(filter.ProcessImage, this); } return this; @@ -498,7 +503,7 @@ namespace ImageProcessor if (this.ShouldProcess) { Filter filter = new Filter { DynamicParameter = matrixFilter }; - this.ApplyProcessor(filter.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(filter.ProcessImage, this); } return this; @@ -522,7 +527,7 @@ namespace ImageProcessor : RotateFlipType.RotateNoneFlipY; Flip flip = new Flip { DynamicParameter = rotateFlipType }; - this.ApplyProcessor(flip.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(flip.ProcessImage, this); } return this; @@ -531,18 +536,15 @@ namespace ImageProcessor /// /// Sets the output format of the current image to the matching . /// - /// The . to set the image to. - /// Whether the pixel format of the image should be indexed. Used for generating Png8 images. + /// The . to set the image to. /// /// The current instance of the class. /// - [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")] - public ImageFactory Format(ImageFormat imageFormat, bool indexedFormat = false) + public ImageFactory Format(ISupportedImageFormat format) { if (this.ShouldProcess) { - this.isIndexed = indexedFormat; - this.ImageFormat = imageFormat; + this.CurrentImageFormat = format; } return this; @@ -589,7 +591,7 @@ namespace ImageProcessor if (this.ShouldProcess) { GaussianBlur gaussianBlur = new GaussianBlur { DynamicParameter = gaussianLayer }; - this.ApplyProcessor(gaussianBlur.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(gaussianBlur.ProcessImage, this); } return this; @@ -636,7 +638,7 @@ namespace ImageProcessor if (this.ShouldProcess) { GaussianSharpen gaussianSharpen = new GaussianSharpen { DynamicParameter = gaussianLayer }; - this.ApplyProcessor(gaussianSharpen.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(gaussianSharpen.ProcessImage, this); } return this; @@ -656,7 +658,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - this.JpegQuality = percentage; + this.CurrentImageFormat.Quality = percentage; } return this; @@ -701,7 +703,7 @@ namespace ImageProcessor var resizeSettings = new Dictionary { { "MaxWidth", resizeLayer.Size.Width.ToString("G") }, { "MaxHeight", resizeLayer.Size.Height.ToString("G") } }; Resize resize = new Resize { DynamicParameter = resizeLayer, Settings = resizeSettings }; - this.ApplyProcessor(resize.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(resize.ProcessImage, this); } return this; @@ -710,24 +712,24 @@ namespace ImageProcessor /// /// Rotates the current image by the given angle. /// - /// - /// The containing the properties to rotate the image. + /// + /// The angle at which to rotate the image in degrees. /// /// /// The current instance of the class. /// - public ImageFactory Rotate(RotateLayer rotateLayer) + public ImageFactory Rotate(int degrees) { if (this.ShouldProcess) { // Sanitize the input. - if (rotateLayer.Angle > 360 || rotateLayer.Angle < 0) + if (degrees > 360 || degrees < 0) { - rotateLayer.Angle = 0; + degrees = 0; } - Rotate rotate = new Rotate { DynamicParameter = rotateLayer }; - this.ApplyProcessor(rotate.ProcessImage); + Rotate rotate = new Rotate { DynamicParameter = degrees }; + this.CurrentImageFormat.ApplyProcessor(rotate.ProcessImage, this); } return this; @@ -752,7 +754,7 @@ namespace ImageProcessor } RoundedCorners roundedCorners = new RoundedCorners { DynamicParameter = roundedCornerLayer }; - this.ApplyProcessor(roundedCorners.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(roundedCorners.ProcessImage, this); } return this; @@ -779,7 +781,7 @@ namespace ImageProcessor } Saturation saturate = new Saturation { DynamicParameter = percentage }; - this.ApplyProcessor(saturate.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(saturate.ProcessImage, this); } return this; @@ -799,7 +801,7 @@ namespace ImageProcessor if (this.ShouldProcess) { Tint tint = new Tint { DynamicParameter = color }; - this.ApplyProcessor(tint.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(tint.ProcessImage, this); } return this; @@ -816,7 +818,7 @@ namespace ImageProcessor if (this.ShouldProcess) { Vignette vignette = new Vignette(); - this.ApplyProcessor(vignette.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(vignette.ProcessImage, this); } return this; @@ -837,7 +839,7 @@ namespace ImageProcessor if (this.ShouldProcess) { Watermark watermark = new Watermark { DynamicParameter = textLayer }; - this.ApplyProcessor(watermark.ProcessImage); + this.CurrentImageFormat.ApplyProcessor(watermark.ProcessImage, this); } return this; @@ -845,7 +847,9 @@ namespace ImageProcessor #endregion /// - /// Saves the current image to the specified file path. + /// Saves the current image to the specified file path. If the extension does not + /// match the correct extension for the current format it will be replaced by the + /// correct default value. /// /// The path to save the image to. /// @@ -858,71 +862,24 @@ namespace ImageProcessor // We need to check here if the path has an extension and remove it if so. // This is so we can add the correct image format. int length = filePath.LastIndexOf(".", StringComparison.Ordinal); - string extension = this.ImageFormat.GetFileExtension(this.OriginalExtension); + string extension = Path.GetExtension(filePath).TrimStart('.'); + string fallback = this.CurrentImageFormat.DefaultExtension; - if (!string.IsNullOrWhiteSpace(extension)) + if (extension != fallback && !this.CurrentImageFormat.FileExtensions.Contains(extension)) { - filePath = length == -1 ? filePath + extension : filePath.Substring(0, length) + extension; + filePath = length == -1 + ? string.Format("{0}.{1}", filePath, fallback) + : filePath.Substring(0, length + 1) + fallback; } - // Fix the colour palette of indexed images. - this.FixIndexedPallete(); - // ReSharper disable once AssignNullToNotNullAttribute DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(filePath)); - - if (this.ImageFormat.Equals(ImageFormat.Jpeg)) + if (!directoryInfo.Exists) { - // Jpegs can be saved with different settings to include a quality setting for the JPEG compression. - // This improves output compression and quality. - using (EncoderParameters encoderParameters = ImageUtils.GetEncodingParameters(this.JpegQuality)) - { - ImageCodecInfo imageCodecInfo = - ImageCodecInfo.GetImageEncoders() - .FirstOrDefault(ici => ici.MimeType.Equals(this.MimeType, StringComparison.OrdinalIgnoreCase)); - - if (imageCodecInfo != null) - { - for (int i = 0; i < 3; i++) - { - try - { - if (!directoryInfo.Exists) - { - directoryInfo.Create(); - } - - this.Image.Save(filePath, imageCodecInfo, encoderParameters); - break; - } - catch (Exception) - { - Thread.Sleep(200); - } - } - } - } + directoryInfo.Create(); } - else - { - for (int i = 0; i < 3; i++) - { - try - { - if (!directoryInfo.Exists) - { - directoryInfo.Create(); - } - this.Image.Save(filePath, this.ImageFormat); - break; - } - catch (Exception) - { - Thread.Sleep(200); - } - } - } + this.Image = this.CurrentImageFormat.Save(filePath, this.Image); } return this; @@ -941,29 +898,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - // Fix the colour palette of gif and png8 images. - this.FixIndexedPallete(); - - if (this.ImageFormat.Equals(ImageFormat.Jpeg)) - { - // Jpegs can be saved with different settings to include a quality setting for the JPEG compression. - // This improves output compression and quality. - using (EncoderParameters encoderParameters = ImageUtils.GetEncodingParameters(this.JpegQuality)) - { - ImageCodecInfo imageCodecInfo = - ImageCodecInfo.GetImageEncoders().FirstOrDefault( - ici => ici.MimeType.Equals(this.MimeType, StringComparison.OrdinalIgnoreCase)); - - if (imageCodecInfo != null) - { - this.Image.Save(memoryStream, imageCodecInfo, encoderParameters); - } - } - } - else - { - this.Image.Save(memoryStream, this.ImageFormat); - } + this.Image = this.CurrentImageFormat.Save(memoryStream, this.Image); } return this; @@ -1002,10 +937,10 @@ namespace ImageProcessor if (this.Image != null) { // Dispose of the memory stream from Load and the image. - if (this.inputStream != null) + if (this.InputStream != null) { - this.inputStream.Dispose(); - this.inputStream = null; + this.InputStream.Dispose(); + this.InputStream = null; } this.Image.Dispose(); @@ -1019,81 +954,6 @@ namespace ImageProcessor this.isDisposed = true; } #endregion - - /// - /// Uses the - /// to fix the color palette of gif images. - /// - private void FixIndexedPallete() - { - ImageFormat format = this.ImageFormat; - - // Fix the colour palette of indexed images. - if (this.isIndexed || format.Equals(ImageFormat.Gif)) - { - ImageInfo imageInfo = this.Image.GetImageInfo(format, false); - - if (!imageInfo.IsAnimated) - { - this.Image = new OctreeQuantizer(255, 8).Quantize(this.Image); - } - } - } - - /// - /// Applies the given processor the current image. - /// - /// - /// The processor delegate. - /// - private void ApplyProcessor(Func processor) - { - ImageInfo imageInfo = this.Image.GetImageInfo(this.ImageFormat); - - if (imageInfo.IsAnimated) - { - OctreeQuantizer quantizer = new OctreeQuantizer(255, 8); - - // We don't dispose of the memory stream as that is disposed when a new image is created and doing so - // beforehand will cause an exception. - MemoryStream stream = new MemoryStream(); - using (GifEncoder encoder = new GifEncoder(stream, null, null, imageInfo.LoopCount)) - { - foreach (GifFrame frame in imageInfo.GifFrames) - { - this.Image = frame.Image; - frame.Image = quantizer.Quantize(processor.Invoke(this)); - encoder.AddFrame(frame); - } - } - - stream.Position = 0; - this.Image = Image.FromStream(stream); - } - else - { - this.Image = processor.Invoke(this); - } - - // Set the property item information from any Exif metadata. - // We do this here so that they can be changed between processor methods. - if (this.PreserveExifData) - { - foreach (KeyValuePair propertItem in this.ExifPropertyItems) - { - try - { - this.Image.SetPropertyItem(propertItem.Value); - } - // ReSharper disable once EmptyGeneralCatchClause - catch - { - // Do nothing. The image format does not handle EXIF data. - // TODO: empty catch is fierce code smell. - } - } - } - } #endregion } } diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 54aa058bb..68f6e06bd 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -60,12 +60,15 @@ - - - - - - + + + + + + + + + @@ -75,6 +78,14 @@ + + + + + + + + @@ -100,6 +111,7 @@ + diff --git a/src/ImageProcessor/Imaging/Convolution.cs b/src/ImageProcessor/Imaging/Convolution.cs index be3f585e9..1d8088970 100644 --- a/src/ImageProcessor/Imaging/Convolution.cs +++ b/src/ImageProcessor/Imaging/Convolution.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Imaging using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; - using ImageProcessor.Extensions; + + using ImageProcessor.Core.Common.Extensions; /// /// Provides methods for applying blurring and sharpening effects to an image.. diff --git a/src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs index 2f46693cb..7c7feab83 100644 --- a/src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs @@ -18,7 +18,7 @@ namespace ImageProcessor.Imaging.Filters using System.Drawing.Imaging; using System.Runtime.InteropServices; - using ImageProcessor.Extensions; + using ImageProcessor.Core.Common.Extensions; #endregion diff --git a/src/ImageProcessor/Imaging/Formats/BitmapFormat.cs b/src/ImageProcessor/Imaging/Formats/BitmapFormat.cs new file mode 100644 index 000000000..b971f276e --- /dev/null +++ b/src/ImageProcessor/Imaging/Formats/BitmapFormat.cs @@ -0,0 +1,65 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Provides the necessary information to support bitmap images. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Imaging.Formats +{ + using System.Drawing.Imaging; + using System.Text; + + /// + /// Provides the necessary information to support bitmap images. + /// + public class BitmapFormat : FormatBase + { + /// + /// Gets the file header. + /// + public override byte[] FileHeader + { + get + { + return Encoding.ASCII.GetBytes("BM"); + } + } + + /// + /// Gets the list of file extensions. + /// + public override string[] FileExtensions + { + get + { + return new[] { "bmp" }; + } + } + + /// + /// Gets the standard identifier used on the Internet to indicate the type of data that a file contains. + /// + public override string MimeType + { + get + { + return "image/bmp"; + } + } + + /// + /// Gets the . + /// + public override ImageFormat ImageFormat + { + get + { + return ImageFormat.Bmp; + } + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor/Imaging/Formats/FormatBase.cs b/src/ImageProcessor/Imaging/Formats/FormatBase.cs new file mode 100644 index 000000000..79c90a12b --- /dev/null +++ b/src/ImageProcessor/Imaging/Formats/FormatBase.cs @@ -0,0 +1,123 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// The supported format base implement this class when building a supported format. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Imaging.Formats +{ + using System; + using System.Drawing; + using System.Drawing.Imaging; + using System.IO; + + /// + /// The supported format base. Implement this class when building a supported format. + /// + public abstract class FormatBase : ISupportedImageFormat + { + /// + /// Gets the file header. + /// + public abstract byte[] FileHeader { get; } + + /// + /// Gets the list of file extensions. + /// + public abstract string[] FileExtensions { get; } + + /// + /// Gets the standard identifier used on the Internet to indicate the type of data that a file contains. + /// + public abstract string MimeType { get; } + + /// + /// Gets the default file extension. + /// + public string DefaultExtension + { + get + { + return this.MimeType.Replace("image/", string.Empty); + } + } + + /// + /// Gets the file format of the image. + /// + public abstract ImageFormat ImageFormat { get; } + + /// + /// Gets or sets a value indicating whether the image format is indexed. + /// + public bool IsIndexed { get; set; } + + /// + /// Gets or sets a value indicating whether the image format is animated. + /// + public bool IsAnimated { get; set; } + + /// + /// Gets or sets the quality of output for images. + /// + public int Quality { get; set; } + + /// + /// Applies the given processor the current image. + /// + /// The processor delegate. + /// The . + public virtual void ApplyProcessor(Func processor, ImageFactory factory) + { + processor.Invoke(factory); + } + + /// + /// Decodes the image to process. + /// + /// + /// The containing the image information. + /// + /// + /// The the . + /// + public virtual Image Load(Stream stream) + { + return Image.FromStream(stream, true); + } + + /// + /// Saves the current image to the specified output stream. + /// + /// The to save the image information to. + /// The to save. + /// + /// The . + /// + public virtual Image Save(MemoryStream memoryStream, Image image) + { + image.Save(memoryStream, this.ImageFormat); + memoryStream.Position = 0; + return image; + } + + /// + /// Saves the current image to the specified file path. + /// + /// The path to save the image to. + /// The + /// to save. + /// + /// The . + /// + public virtual Image Save(string path, Image image) + { + image.Save(path, this.ImageFormat); + return image; + } + } +} diff --git a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs new file mode 100644 index 000000000..d3b6f9c56 --- /dev/null +++ b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs @@ -0,0 +1,88 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Utility methods for working with supported image formats. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Imaging.Formats +{ + using System.Collections.Generic; + using System.Drawing; + using System.Drawing.Imaging; + using System.IO; + using System.Linq; + using ImageProcessor.Configuration; + + /// + /// Utility methods for working with supported image formats. + /// + public static class FormatUtilities + { + /// + /// Gets the correct from the given stream. + /// + /// + /// + /// The to read from. + /// + /// + /// The . + /// + public static ISupportedImageFormat GetFormat(Stream stream) + { + IEnumerable supportedImageFormats = + ImageProcessorBootstrapper.Instance.SupportedImageFormats; + + byte[] buffer = new byte[4]; + stream.Read(buffer, 0, buffer.Length); + + // ReSharper disable once LoopCanBeConvertedToQuery + foreach (ISupportedImageFormat supportedImageFormat in supportedImageFormats) + { + byte[] header = supportedImageFormat.FileHeader; + if (header.SequenceEqual(buffer.Take(header.Length))) + { + stream.Position = 0; + return supportedImageFormat; + } + } + + stream.Position = 0; + return null; + } + + /// + /// Returns a value indicating whether the given image is indexed. + /// + /// + /// The to test. + /// + /// + /// The true if the image is indexed; otherwise, false. + /// + public static bool IsIndexed(Image image) + { + // Test value of flags using bitwise AND. + // ReSharper disable once BitwiseOperatorOnEnumWithoutFlags + return (image.PixelFormat & PixelFormat.Indexed) != 0; + } + + /// + /// Returns a value indicating whether the given image is indexed. + /// + /// + /// The to test. + /// + /// + /// The true if the image is animated; otherwise, false. + /// + public static bool IsAnimated(Image image) + { + return ImageAnimator.CanAnimate(image); + } + } +} diff --git a/src/ImageProcessor/Imaging/Formats/GifFormat.cs b/src/ImageProcessor/Imaging/Formats/GifFormat.cs new file mode 100644 index 000000000..b2b3cb413 --- /dev/null +++ b/src/ImageProcessor/Imaging/Formats/GifFormat.cs @@ -0,0 +1,149 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Provides the necessary information to support gif images. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Imaging.Formats +{ + using System; + using System.Drawing; + using System.Drawing.Imaging; + using System.IO; + using System.Text; + using ImageProcessor.Core.Common.Extensions; + + /// + /// Provides the necessary information to support gif images. + /// + public class GifFormat : FormatBase + { + /// + /// Gets the file header. + /// + public override byte[] FileHeader + { + get + { + return Encoding.ASCII.GetBytes("GIF"); + } + } + + /// + /// Gets the list of file extensions. + /// + public override string[] FileExtensions + { + get + { + return new[] { "gif" }; + } + } + + /// + /// Gets the standard identifier used on the Internet to indicate the type of data that a file contains. + /// + public override string MimeType + { + get + { + return "image/gif"; + } + } + + /// + /// Gets the . + /// + public override ImageFormat ImageFormat + { + get + { + return ImageFormat.Gif; + } + } + + /// + /// Applies the given processor the current image. + /// + /// The processor delegate. + /// The . + public override void ApplyProcessor(Func processor, ImageFactory factory) + { + ImageInfo imageInfo = factory.Image.GetImageInfo(this.ImageFormat); + + if (imageInfo.IsAnimated) + { + OctreeQuantizer quantizer = new OctreeQuantizer(255, 8); + + // We don't dispose of the memory stream as that is disposed when a new image is created and doing so + // beforehand will cause an exception. + MemoryStream stream = new MemoryStream(); + using (GifEncoder encoder = new GifEncoder(stream, null, null, imageInfo.LoopCount)) + { + foreach (GifFrame frame in imageInfo.GifFrames) + { + factory.Update(frame.Image); + frame.Image = quantizer.Quantize(processor.Invoke(factory)); + encoder.AddFrame(frame); + } + } + + stream.Position = 0; + factory.Update(Image.FromStream(stream)); + } + else + { + base.ApplyProcessor(processor, factory); + } + } + + /// + /// Saves the current image to the specified output stream. + /// + /// + /// The to save the image information to. + /// + /// The to save. + /// + /// The . + /// + public override Image Save(MemoryStream memoryStream, Image image) + { + // TODO: Move this in here. It doesn't need to be anywhere else. + ImageInfo imageInfo = image.GetImageInfo(this.ImageFormat, false); + + if (!imageInfo.IsAnimated) + { + image = new OctreeQuantizer(255, 8).Quantize(image); + } + + return base.Save(memoryStream, image); + } + + /// + /// Saves the current image to the specified file path. + /// + /// The path to save the image to. + /// The + /// to save. + /// + /// The . + /// + public override Image Save(string path, Image image) + { + // TODO: Move this in here. It doesn't need to be anywhere else. + ImageInfo imageInfo = image.GetImageInfo(this.ImageFormat, false); + + if (!imageInfo.IsAnimated) + { + image = new OctreeQuantizer(255, 8).Quantize(image); + } + + return base.Save(path, image); + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs b/src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs new file mode 100644 index 000000000..8ad4e0763 --- /dev/null +++ b/src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs @@ -0,0 +1,113 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// The SupportedImageFormat interface providing information about image formats to ImageProcessor. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Imaging.Formats +{ + using System; + using System.Drawing; + using System.Drawing.Imaging; + using System.IO; + + /// + /// The SupportedImageFormat interface providing information about image formats to ImageProcessor. + /// + public interface ISupportedImageFormat + { + /// + /// Gets the file header. + /// + byte[] FileHeader { get; } + + /// + /// Gets the list of file extensions. + /// + string[] FileExtensions { get; } + + /// + /// Gets the standard identifier used on the Internet to indicate the type of data that a file contains. + /// + string MimeType { get; } + + /// + /// Gets the default file extension. + /// + string DefaultExtension { get; } + + /// + /// Gets the file format of the image. + /// + ImageFormat ImageFormat { get; } + + /// + /// Gets or sets a value indicating whether the image format is indexed. + /// + bool IsIndexed { get; set; } + + /// + /// Gets or sets a value indicating whether the image format is animated. + /// + bool IsAnimated { get; set; } + + /// + /// Gets or sets the quality of output for images. + /// + int Quality { get; set; } + + #region Methods + /// + /// Applies the given processor the current image. + /// + /// + /// The processor delegate. + /// + /// + /// The . + /// + void ApplyProcessor(Func processor, ImageFactory factory); + + /// + /// Loads the image to process. + /// + /// + /// The containing the image information. + /// + /// + /// The . + /// + Image Load(Stream stream); + + /// + /// Saves the current image to the specified output stream. + /// + /// + /// The to save the image information to. + /// + /// + /// The to save. + /// + /// + /// The . + /// + Image Save(MemoryStream memoryStream, Image image); + + /// + /// Saves the current image to the specified file path. + /// + /// The path to save the image to. + /// + /// The to save. + /// + /// + /// The . + /// + Image Save(string path, Image image); + #endregion + } +} diff --git a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs new file mode 100644 index 000000000..761088ddc --- /dev/null +++ b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs @@ -0,0 +1,155 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Provides the necessary information to support jpeg images. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Imaging.Formats +{ + using System; + using System.Collections.Generic; + using System.Drawing; + using System.Drawing.Imaging; + using System.IO; + using System.Linq; + + /// + /// Provides the necessary information to support jpeg images. + /// + public sealed class JpegFormat : FormatBase + { + /// + /// Gets the file header. + /// + public override byte[] FileHeader + { + get + { + return new byte[] { 255, 216, 255, 224 }; + } + } + + /// + /// Gets the list of file extensions. + /// + public override string[] FileExtensions + { + get + { + return new[] { "jpeg", "jpg" }; + } + } + + /// + /// Gets the standard identifier used on the Internet to indicate the type of data that a file contains. + /// + public override string MimeType + { + get + { + return "image/jpeg"; + } + } + + /// + /// Gets the . + /// + public override ImageFormat ImageFormat + { + get + { + return ImageFormat.Jpeg; + } + } + + /// + /// Applies the given processor the current image. + /// + /// The processor delegate. + /// The . + public override void ApplyProcessor(Func processor, ImageFactory factory) + { + base.ApplyProcessor(processor, factory); + + // Set the property item information from any Exif metadata. + // We do this here so that they can be changed between processor methods. + if (factory.PreserveExifData) + { + foreach (KeyValuePair propertItem in factory.ExifPropertyItems) + { + try + { + factory.Image.SetPropertyItem(propertItem.Value); + } + // ReSharper disable once EmptyGeneralCatchClause + catch + { + // Do nothing. The image format does not handle EXIF data. + // TODO: empty catch is fierce code smell. + } + } + } + } + + /// + /// Saves the current image to the specified output stream. + /// + /// + /// The to save the image information to. + /// + /// The to save. + /// + /// The . + /// + public override Image Save(MemoryStream memoryStream, Image image) + { + // Jpegs can be saved with different settings to include a quality setting for the JPEG compression. + // This improves output compression and quality. + using (EncoderParameters encoderParameters = ImageUtils.GetEncodingParameters(this.Quality)) + { + ImageCodecInfo imageCodecInfo = + ImageCodecInfo.GetImageEncoders() + .FirstOrDefault(ici => ici.MimeType.Equals(this.MimeType, StringComparison.OrdinalIgnoreCase)); + + if (imageCodecInfo != null) + { + image.Save(memoryStream, imageCodecInfo, encoderParameters); + } + } + + return image; + } + + /// + /// Saves the current image to the specified file path. + /// + /// The path to save the image to. + /// The + /// to save. + /// + /// The . + /// + public override Image Save(string path, Image image) + { + // Jpegs can be saved with different settings to include a quality setting for the JPEG compression. + // This improves output compression and quality. + using (EncoderParameters encoderParameters = ImageUtils.GetEncodingParameters(this.Quality)) + { + ImageCodecInfo imageCodecInfo = + ImageCodecInfo.GetImageEncoders() + .FirstOrDefault(ici => ici.MimeType.Equals(this.MimeType, StringComparison.OrdinalIgnoreCase)); + + if (imageCodecInfo != null) + { + image.Save(path, imageCodecInfo, encoderParameters); + } + } + + return image; + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor/Imaging/Formats/PngFormat.cs b/src/ImageProcessor/Imaging/Formats/PngFormat.cs new file mode 100644 index 000000000..da6b4dc5f --- /dev/null +++ b/src/ImageProcessor/Imaging/Formats/PngFormat.cs @@ -0,0 +1,103 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Provides the necessary information to support png images. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Imaging.Formats +{ + using System.Drawing; + using System.Drawing.Imaging; + using System.IO; + + /// + /// Provides the necessary information to support png images. + /// + public class PngFormat : FormatBase + { + /// + /// Gets the file header. + /// + public override byte[] FileHeader + { + get + { + return new byte[] { 137, 80, 78, 71 }; + } + } + + /// + /// Gets the list of file extensions. + /// + public override string[] FileExtensions + { + get + { + return new[] { "png" }; + } + } + + /// + /// Gets the standard identifier used on the Internet to indicate the type of data that a file contains. + /// + public override string MimeType + { + get + { + return "image/png"; + } + } + + /// + /// Gets the . + /// + public override ImageFormat ImageFormat + { + get + { + return ImageFormat.Png; + } + } + + /// + /// Saves the current image to the specified output stream. + /// + /// The to save the image information to. + /// The to save. + /// + /// The . + /// + public override Image Save(MemoryStream memoryStream, Image image) + { + if (FormatUtilities.IsIndexed(image)) + { + image = new OctreeQuantizer(255, 8).Quantize(image); + } + + return base.Save(memoryStream, image); + } + + /// + /// Saves the current image to the specified file path. + /// + /// The path to save the image to. + /// The + /// to save. + /// + /// The . + /// + public override Image Save(string path, Image image) + { + if (FormatUtilities.IsIndexed(image)) + { + image = new OctreeQuantizer(255, 8).Quantize(image); + } + + return base.Save(path, image); + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor/Imaging/Formats/TiffFormat.cs b/src/ImageProcessor/Imaging/Formats/TiffFormat.cs new file mode 100644 index 000000000..226c0efab --- /dev/null +++ b/src/ImageProcessor/Imaging/Formats/TiffFormat.cs @@ -0,0 +1,96 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Provides the necessary information to support tiff images. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Imaging.Formats +{ + using System; + using System.Collections.Generic; + using System.Drawing; + using System.Drawing.Imaging; + + /// + /// Provides the necessary information to support tiff images. + /// + public class TiffFormat : FormatBase + { + /// + /// Gets the file header. + /// + public override byte[] FileHeader + { + get + { + return new byte[] { 77, 77, 42 }; + } + } + + /// + /// Gets the list of file extensions. + /// + public override string[] FileExtensions + { + get + { + return new[] { "tif", "tiff" }; + } + } + + /// + /// Gets the standard identifier used on the Internet to indicate the type of data that a file contains. + /// + public override string MimeType + { + get + { + return "image/tiff"; + } + } + + /// + /// Gets the . + /// + public override ImageFormat ImageFormat + { + get + { + return ImageFormat.Tiff; + } + } + + /// + /// Applies the given processor the current image. + /// + /// The processor delegate. + /// The . + public override void ApplyProcessor(Func processor, ImageFactory factory) + { + base.ApplyProcessor(processor, factory); + + // Set the property item information from any Exif metadata. + // We do this here so that they can be changed between processor methods. + if (factory.PreserveExifData) + { + foreach (KeyValuePair propertItem in factory.ExifPropertyItems) + { + try + { + factory.Image.SetPropertyItem(propertItem.Value); + } + // ReSharper disable once EmptyGeneralCatchClause + catch + { + // Do nothing. The image format does not handle EXIF data. + // TODO: empty catch is fierce code smell. + } + } + } + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor/Processors/BackgroundColor.cs b/src/ImageProcessor/Processors/BackgroundColor.cs new file mode 100644 index 000000000..357b08014 --- /dev/null +++ b/src/ImageProcessor/Processors/BackgroundColor.cs @@ -0,0 +1,74 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Changes the background color of an image. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Processors +{ + using System.Collections.Generic; + using System.Drawing; + + /// + /// Changes the background color of an image. + /// + public class BackgroundColor : IGraphicsProcessor + { + /// + /// Gets or sets the DynamicParameter. + /// + public dynamic DynamicParameter { get; set; } + + /// + /// Gets or sets any additional settings required by the processor. + /// + public Dictionary Settings { get; set; } + + /// + /// Processes the image. + /// + /// The the current instance of the + /// class containing + /// the image to process. + /// + /// The processed image from the current instance of the class. + /// + public Image ProcessImage(ImageFactory factory) + { + Bitmap newImage = null; + Image image = factory.Image; + + try + { + Color backgroundColor = this.DynamicParameter; + newImage = new Bitmap(image.Width, image.Height); + + // Make a graphics object from the empty bitmap. + using (Graphics graphics = Graphics.FromImage(newImage)) + { + // Fill the background. + graphics.Clear(backgroundColor); + + // Draw passed in image onto graphics object. + graphics.DrawImage(image, 0, 0); + } + + image.Dispose(); + image = newImage; + } + catch + { + if (newImage != null) + { + newImage.Dispose(); + } + } + + return image; + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor/Processors/Crop.cs b/src/ImageProcessor/Processors/Crop.cs index fa4f20ccf..0124b0f61 100644 --- a/src/ImageProcessor/Processors/Crop.cs +++ b/src/ImageProcessor/Processors/Crop.cs @@ -18,7 +18,7 @@ namespace ImageProcessor.Processors using System.Text; using System.Text.RegularExpressions; - using ImageProcessor.Extensions; + using ImageProcessor.Core.Common.Extensions; using ImageProcessor.Imaging; #endregion diff --git a/src/ImageProcessor/Processors/Format.cs b/src/ImageProcessor/Processors/Format.cs index 97173b836..4879c9d11 100644 --- a/src/ImageProcessor/Processors/Format.cs +++ b/src/ImageProcessor/Processors/Format.cs @@ -146,7 +146,8 @@ namespace ImageProcessor.Processors // Set the internal property. factory.OriginalExtension = string.Format(".{0}", format); - factory.Format(imageFormat, isIndexed); + // TODO: Fix this. + //factory.Format(imageFormat); return factory.Image; } diff --git a/src/ImageProcessor/Processors/IGraphicsProcessor.cs b/src/ImageProcessor/Processors/IGraphicsProcessor.cs index 148c7a7e4..a3c06c050 100644 --- a/src/ImageProcessor/Processors/IGraphicsProcessor.cs +++ b/src/ImageProcessor/Processors/IGraphicsProcessor.cs @@ -23,38 +23,17 @@ namespace ImageProcessor.Processors { #region Properties /// - /// Gets the regular expression to search strings for. + /// Gets or sets the DynamicParameter. /// - Regex RegexPattern { get; } - - /// - /// Gets DynamicParameter. - /// - dynamic DynamicParameter { get; } - - /// - /// Gets the order in which this processor is to be used in a chain. - /// - int SortOrder { get; } + dynamic DynamicParameter { get; set; } /// /// Gets or sets any additional settings required by the processor. /// - Dictionary Settings { get; set; } + Dictionary Settings { get; set; } #endregion #region Methods - /// - /// 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. - /// - int MatchRegexIndex(string queryString); - /// /// Processes the image. /// diff --git a/src/ImageProcessor/Processors/Quality.cs b/src/ImageProcessor/Processors/Quality.cs index 97b4b7651..21995cd3c 100644 --- a/src/ImageProcessor/Processors/Quality.cs +++ b/src/ImageProcessor/Processors/Quality.cs @@ -115,7 +115,7 @@ namespace ImageProcessor.Processors public Image ProcessImage(ImageFactory factory) { // Set the internal property. - factory.JpegQuality = this.DynamicParameter; + factory.CurrentImageFormat.Quality = this.DynamicParameter; return factory.Image; } diff --git a/src/ImageProcessor/Processors/Resize.cs b/src/ImageProcessor/Processors/Resize.cs index 3a95203f7..072848ee6 100644 --- a/src/ImageProcessor/Processors/Resize.cs +++ b/src/ImageProcessor/Processors/Resize.cs @@ -20,7 +20,8 @@ namespace ImageProcessor.Processors using System.Linq; using System.Text; using System.Text.RegularExpressions; - using ImageProcessor.Extensions; + + using ImageProcessor.Core.Common.Extensions; using ImageProcessor.Imaging; #endregion diff --git a/src/ImageProcessor/Processors/Rotate.cs b/src/ImageProcessor/Processors/Rotate.cs index da3e85e63..1ce5fd416 100644 --- a/src/ImageProcessor/Processors/Rotate.cs +++ b/src/ImageProcessor/Processors/Rotate.cs @@ -15,9 +15,6 @@ 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 /// @@ -25,33 +22,7 @@ namespace ImageProcessor.Processors /// public class Rotate : IGraphicsProcessor { - /// - /// The regular expression to search strings for. - /// - private static readonly Regex QueryRegex = new Regex(@"rotate=((?:3[0-5][0-9]|[12][0-9]{2}|[1-9][0-9]?)|angle-(?:3[0-5][0-9]|[12][0-9]{2}|[1-9][0-9]?)[\|,]bgcolor-([0-9a-fA-F]{3}){1,2})", RegexOptions.Compiled); - - /// - /// The regular expression to search strings for the angle attribute. - /// - private static readonly Regex AngleRegex = new Regex(@"angle-(?:3[0-5][0-9]|[12][0-9]{2}|[1-9][0-9]?)", RegexOptions.Compiled); - - /// - /// The regular expression to search strings for the color attribute. - /// - private static readonly Regex ColorRegex = new Regex(@"bgcolor-([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; - } - } - + #region IGraphicsProcessor members /// /// Gets or sets DynamicParameter. /// @@ -61,15 +32,6 @@ namespace ImageProcessor.Processors 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. /// @@ -79,57 +41,6 @@ namespace ImageProcessor.Processors 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; - - RotateLayer rotateLayer; - - string toParse = match.Value; - - if (toParse.Contains("bgcolor")) - { - rotateLayer = new RotateLayer(this.ParseAngle(toParse), this.ParseColor(toParse)); - } - else - { - int degrees; - int.TryParse(match.Value.Split('=')[1], NumberStyles.Any, CultureInfo.InvariantCulture, out degrees); - - rotateLayer = new RotateLayer(degrees); - } - - this.DynamicParameter = rotateLayer; - } - - index += 1; - } - } - - return this.SortOrder; - } - /// /// Processes the image. /// @@ -147,16 +58,14 @@ namespace ImageProcessor.Processors try { - RotateLayer rotateLayer = this.DynamicParameter; - int angle = rotateLayer.Angle; - Color backgroundColor = rotateLayer.BackgroundColor; + int angle = this.DynamicParameter; // Center of the image float rotateAtX = Math.Abs(image.Width / 2); float rotateAtY = Math.Abs(image.Height / 2); // Create a rotated image. - newImage = this.RotateImage(image, rotateAtX, rotateAtY, angle, backgroundColor); + newImage = this.RotateImage(image, rotateAtX, rotateAtY, angle); image.Dispose(); image = newImage; @@ -181,12 +90,11 @@ namespace ImageProcessor.Processors /// The horizontal pixel coordinate at which to rotate the image. /// The vertical pixel coordinate at which to rotate the image. /// The angle in degrees at which to rotate the image. - /// The background color to fill an image with. /// The image rotated to the given angle at the given position. /// /// Based on /// - private Bitmap RotateImage(Image image, float rotateAtX, float rotateAtY, float angle, Color backgroundColor) + private Bitmap RotateImage(Image image, float rotateAtX, float rotateAtY, float angle) { int width, height, x, y; @@ -242,14 +150,9 @@ namespace ImageProcessor.Processors { // Reduce the jagged edge. graphics.SmoothingMode = SmoothingMode.HighQuality; - - // Contrary to everything I have read bicubic is producing the best results. graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; - graphics.CompositingQuality = CompositingQuality.HighSpeed; - - // Fill the background. - graphics.Clear(backgroundColor); + graphics.CompositingQuality = CompositingQuality.HighQuality; // Put the rotation point in the "center" of the image graphics.TranslateTransform(rotateAtX + x, rotateAtY + y); @@ -266,49 +169,6 @@ namespace ImageProcessor.Processors return newImage; } - - /// - /// Returns the correct containing the angle for the given string. - /// - /// - /// The input string containing the value to parse. - /// - /// - /// The correct containing the angle for the given string. - /// - private int ParseAngle(string input) - { - foreach (Match match in AngleRegex.Matches(input)) - { - // Split on angle- - int angle; - int.TryParse(match.Value.Split('-')[1], NumberStyles.Any, CultureInfo.InvariantCulture, out angle); - return angle; - } - - // No rotate - matches the RotateLayer default. - return 0; - } - - /// - /// 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 ColorRegex.Matches(input)) - { - // split on color-hex - return ColorTranslator.FromHtml("#" + match.Value.Split('-')[1]); - } - - return Color.Transparent; - } #endregion } } diff --git a/src/ImageProcessor/Processors/Tint.cs b/src/ImageProcessor/Processors/Tint.cs index 37341552e..166789f63 100644 --- a/src/ImageProcessor/Processors/Tint.cs +++ b/src/ImageProcessor/Processors/Tint.cs @@ -10,13 +10,12 @@ namespace ImageProcessor.Processors { - using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Text.RegularExpressions; - using ImageProcessor.Extensions; + using ImageProcessor.Core.Common.Extensions; /// /// Tints an image with the given colour. diff --git a/src/ImageProcessor/Processors/Watermark.cs b/src/ImageProcessor/Processors/Watermark.cs index 586f04404..e911a443f 100644 --- a/src/ImageProcessor/Processors/Watermark.cs +++ b/src/ImageProcessor/Processors/Watermark.cs @@ -20,7 +20,7 @@ namespace ImageProcessor.Processors using System.Linq; using System.Text.RegularExpressions; - using ImageProcessor.Extensions; + using ImageProcessor.Core.Common.Extensions; using ImageProcessor.Imaging; #endregion diff --git a/src/ImageProcessor/Settings.StyleCop b/src/ImageProcessor/Settings.StyleCop index ceca99cde..6f5d9d4ab 100644 --- a/src/ImageProcessor/Settings.StyleCop +++ b/src/ImageProcessor/Settings.StyleCop @@ -2,6 +2,7 @@ behaviour + bootstrapper chrominance colour enum @@ -9,6 +10,7 @@ halftoning lomograph octree + png quantizer diff --git a/src/ImageProcessorConsole/Program.cs b/src/ImageProcessorConsole/Program.cs index 070afe2d8..fd5492fa8 100644 --- a/src/ImageProcessorConsole/Program.cs +++ b/src/ImageProcessorConsole/Program.cs @@ -38,9 +38,7 @@ namespace ImageProcessorConsole // Load, resize, set the format and quality and save an image. imageFactory.Load(inStream) .Constrain(size) - .Tint(Color.FromArgb(255, 106, 166, 204)) - .Format(format) - .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name))); + .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name.TrimEnd(".gif".ToCharArray()) + ".jpg"))); } } } diff --git a/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id index 0d2234d4e..71ce555c1 100644 --- a/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id +++ b/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id @@ -1 +1 @@ -17e154964bfb4da80c1e0aec623cd2486d493b47 \ No newline at end of file +30ec5c05548fd350f9b7c699715848b9fbfb8ca9 \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id index e57ebffe4..4487aede0 100644 --- a/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id +++ b/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id @@ -1 +1 @@ -069f8472ed7b83ea57f4cf511f83396e1a0b8877 \ No newline at end of file +23a1c81a2d1422076373796e0c47f5d968c56d0b \ No newline at end of file From b83179d67aff2761607dcef48ef2da269f2d1ced Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 10 Jun 2014 16:38:38 +0200 Subject: [PATCH 002/155] Moar conversions! Former-commit-id: f812ee5350b737eb4df0bccae42025c44d133065 --- .../ImageCacheSection.cs | 0 .../ImageProcessingSection.cs | 0 .../ImageProcessorConfiguration.cs | 29 +-- .../ImageSecuritySection.cs | 0 .../Resources/cache.config | 0 .../Resources/processing - Copy.config} | 0 .../Configuration/Resources/processing.config | 40 +++++ .../Resources/security.config | 0 ...ies.cs => CommonParameterParserUtility.cs} | 29 ++- .../HttpModules/ImageProcessingModule.cs | 2 +- .../NET45/ImageFactoryExtensions.cs | 8 +- .../NET45/ImageProcessor.Web_NET45.csproj | 27 ++- .../NET45/Processors/Alpha.cs | 80 +++++++++ .../NET45/Processors/BackgroundColor.cs | 2 +- .../NET45/Processors/Brightness.cs | 89 ++++++++++ .../NET45/Processors/Contrast.cs | 89 ++++++++++ .../NET45/Processors/Crop.cs | 166 ++++++++++++++++++ .../NET45/Processors/Quality.cs | 90 ++++++++++ .../NET45/Processors/Rotate.cs | 2 +- .../NET45/Processors/Saturation.cs | 92 ++++++++++ src/ImageProcessor/ImageFactory.cs | 37 +--- .../Imaging/Filters/GothamMatrixFilter.cs | 8 +- .../Imaging/Filters/LomographMatrixFilter.cs | 5 +- .../Imaging/Filters/PolaroidMatrixFilter.cs | 2 +- .../Imaging/Formats/FormatBase.cs | 2 +- .../Imaging/Formats/GifFormat.cs | 4 +- src/ImageProcessor/Processors/Alpha.cs | 68 ------- src/ImageProcessor/Processors/Brightness.cs | 98 ++--------- src/ImageProcessor/Processors/Contrast.cs | 80 +-------- src/ImageProcessor/Processors/Crop.cs | 144 +-------------- src/ImageProcessor/Processors/Quality.cs | 67 ------- src/ImageProcessor/Processors/Saturation.cs | 75 +------- .../NET45/Test_Website_NET45/Web.config | 6 +- .../config/imageprocessor/processing.config | 44 +++-- 34 files changed, 783 insertions(+), 602 deletions(-) rename src/ImageProcessor.Web/NET45/{Config => Configuration}/ImageCacheSection.cs (100%) rename src/ImageProcessor.Web/NET45/{Config => Configuration}/ImageProcessingSection.cs (100%) rename src/ImageProcessor.Web/NET45/{Config => Configuration}/ImageProcessorConfiguration.cs (91%) rename src/ImageProcessor.Web/NET45/{Config => Configuration}/ImageSecuritySection.cs (100%) rename src/ImageProcessor.Web/NET45/{Config => Configuration}/Resources/cache.config (100%) rename src/ImageProcessor.Web/NET45/{Config/Resources/processing.config => Configuration/Resources/processing - Copy.config} (100%) create mode 100644 src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config rename src/ImageProcessor.Web/NET45/{Config => Configuration}/Resources/security.config (100%) rename src/ImageProcessor.Web/NET45/Helpers/{ParameterParserUtilities.cs => CommonParameterParserUtility.cs} (76%) create mode 100644 src/ImageProcessor.Web/NET45/Processors/Alpha.cs create mode 100644 src/ImageProcessor.Web/NET45/Processors/Brightness.cs create mode 100644 src/ImageProcessor.Web/NET45/Processors/Contrast.cs create mode 100644 src/ImageProcessor.Web/NET45/Processors/Crop.cs create mode 100644 src/ImageProcessor.Web/NET45/Processors/Quality.cs create mode 100644 src/ImageProcessor.Web/NET45/Processors/Saturation.cs diff --git a/src/ImageProcessor.Web/NET45/Config/ImageCacheSection.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Config/ImageCacheSection.cs rename to src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs diff --git a/src/ImageProcessor.Web/NET45/Config/ImageProcessingSection.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Config/ImageProcessingSection.cs rename to src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs diff --git a/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfiguration.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs similarity index 91% rename from src/ImageProcessor.Web/NET45/Config/ImageProcessorConfiguration.cs rename to src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs index 2bcf73d78..e871a5c35 100644 --- a/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfiguration.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs @@ -1,5 +1,5 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // Copyright (c) James South. // Licensed under the Apache License, Version 2.0. // @@ -18,6 +18,8 @@ namespace ImageProcessor.Web.Configuration using System.Reflection; using System.Web.Compilation; using ImageProcessor.Processors; + using ImageProcessor.Web.Processors; + #endregion /// @@ -64,8 +66,9 @@ namespace ImageProcessor.Web.Configuration #endregion #region Constructors + /// - /// Prevents a default instance of the class from being created. + /// Prevents a default instance of the class from being created. /// private ImageProcessorConfiguration() { @@ -75,7 +78,7 @@ namespace ImageProcessor.Web.Configuration #region Properties /// - /// Gets the current instance of the class. + /// Gets the current instance of the class. /// public static ImageProcessorConfiguration Instance { @@ -88,7 +91,7 @@ namespace ImageProcessor.Web.Configuration /// /// Gets the list of available GraphicsProcessors. /// - public IList GraphicsProcessors { get; private set; } + public IList GraphicsProcessors { get; private set; } /// /// Gets a value indicating whether to preserve exif meta data. @@ -292,7 +295,7 @@ namespace ImageProcessor.Web.Configuration { if (GetImageProcessingSection().Plugins.AutoLoadPlugins) { - Type type = typeof(IGraphicsProcessor); + Type type = typeof(IWebGraphicsProcessor); try { // Build a list of native IGraphicsProcessor instances. @@ -303,12 +306,12 @@ namespace ImageProcessor.Web.Configuration .ToList(); // Create them and add. - this.GraphicsProcessors = availableTypes.Select(x => (Activator.CreateInstance(x) as IGraphicsProcessor)).ToList(); + this.GraphicsProcessors = availableTypes.Select(x => (Activator.CreateInstance(x) as IWebGraphicsProcessor)).ToList(); // Add the available settings. - foreach (IGraphicsProcessor processor in this.GraphicsProcessors) + foreach (IWebGraphicsProcessor webProcessor in this.GraphicsProcessors) { - processor.Settings = this.GetPluginSettings(processor.GetType().Name); + webProcessor.Processor.Settings = this.GetPluginSettings(webProcessor.GetType().Name); } } catch (ReflectionTypeLoadException) @@ -332,23 +335,23 @@ namespace ImageProcessor.Web.Configuration private void LoadGraphicsProcessorsFromConfiguration() { ImageProcessingSection.PluginElementCollection pluginConfigs = imageProcessingSection.Plugins; - this.GraphicsProcessors = new List(); + this.GraphicsProcessors = new List(); foreach (ImageProcessingSection.PluginElement pluginConfig in pluginConfigs) { Type type = Type.GetType(pluginConfig.Type); if (type == null) { - throw new TypeLoadException("Couldn't load IGraphicsProcessor: " + pluginConfig.Type); + throw new TypeLoadException("Couldn't load IWebGraphicsProcessor: " + pluginConfig.Type); } - this.GraphicsProcessors.Add(Activator.CreateInstance(type) as IGraphicsProcessor); + this.GraphicsProcessors.Add(Activator.CreateInstance(type) as IWebGraphicsProcessor); } // Add the available settings. - foreach (IGraphicsProcessor processor in this.GraphicsProcessors) + foreach (IWebGraphicsProcessor webProcessor in this.GraphicsProcessors) { - processor.Settings = this.GetPluginSettings(processor.GetType().Name); + webProcessor.Processor.Settings = this.GetPluginSettings(webProcessor.GetType().Name); } } #endregion diff --git a/src/ImageProcessor.Web/NET45/Config/ImageSecuritySection.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageSecuritySection.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Config/ImageSecuritySection.cs rename to src/ImageProcessor.Web/NET45/Configuration/ImageSecuritySection.cs diff --git a/src/ImageProcessor.Web/NET45/Config/Resources/cache.config b/src/ImageProcessor.Web/NET45/Configuration/Resources/cache.config similarity index 100% rename from src/ImageProcessor.Web/NET45/Config/Resources/cache.config rename to src/ImageProcessor.Web/NET45/Configuration/Resources/cache.config diff --git a/src/ImageProcessor.Web/NET45/Config/Resources/processing.config b/src/ImageProcessor.Web/NET45/Configuration/Resources/processing - Copy.config similarity index 100% rename from src/ImageProcessor.Web/NET45/Config/Resources/processing.config rename to src/ImageProcessor.Web/NET45/Configuration/Resources/processing - Copy.config diff --git a/src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config b/src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config new file mode 100644 index 000000000..c29cd5db1 --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET45/Config/Resources/security.config b/src/ImageProcessor.Web/NET45/Configuration/Resources/security.config similarity index 100% rename from src/ImageProcessor.Web/NET45/Config/Resources/security.config rename to src/ImageProcessor.Web/NET45/Configuration/Resources/security.config diff --git a/src/ImageProcessor.Web/NET45/Helpers/ParameterParserUtilities.cs b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs similarity index 76% rename from src/ImageProcessor.Web/NET45/Helpers/ParameterParserUtilities.cs rename to src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs index eb6af4357..d4039acdd 100644 --- a/src/ImageProcessor.Web/NET45/Helpers/ParameterParserUtilities.cs +++ b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs @@ -1,5 +1,5 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // Copyright (c) James South. // Licensed under the Apache License, Version 2.0. // @@ -18,7 +18,7 @@ namespace ImageProcessor.Web.Helpers /// /// Encapsulates methods to correctly parse querystring parameters. /// - public static class ParameterParserUtilities + public static class CommonParameterParserUtility { /// /// The regular expression to search strings for colors. @@ -30,6 +30,11 @@ namespace ImageProcessor.Web.Helpers /// private static readonly Regex AngleRegex = new Regex(@"(rotate|angle)(=|-)(?:3[0-5][0-9]|[12][0-9]{2}|[1-9][0-9]?)", RegexOptions.Compiled); + /// + /// The regular expression to search strings for values between 1 and 100. + /// + private static readonly Regex In100RangeRegex = new Regex(@"(-?(?:100)|-?([1-9]?[0-9]))", RegexOptions.Compiled); + /// /// Returns the correct containing the angle for the given string. /// @@ -86,5 +91,25 @@ namespace ImageProcessor.Web.Helpers return Color.Transparent; } + + /// + /// Returns the correct for the given string. + /// + /// + /// The input string containing the value to parse. + /// + /// + /// The correct between -100 and 100. + /// + public static int ParseIn100Range(string input) + { + int value = 0; + foreach (Match match in In100RangeRegex.Matches(input)) + { + value = int.Parse(match.Value, CultureInfo.InvariantCulture); + } + + return value; + } } } diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index 6d10a49ee..213d35b2a 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -414,7 +414,7 @@ namespace ImageProcessor.Web.HttpModules .Save(cachedPath); // Store the response type in the context for later retrieval. - context.Items[CachedResponseTypeKey] = imageFactory.MimeType; + context.Items[CachedResponseTypeKey] = imageFactory.CurrentImageFormat.MimeType; // Ensure that the LastWriteTime property of the source and cached file match. Tuple creationAndLastWriteDateTimes = await cache.SetCachedLastWriteTimeAsync(); diff --git a/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs b/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs index c677149fb..704373a55 100644 --- a/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs +++ b/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs @@ -13,8 +13,8 @@ namespace ImageProcessor.Web #region Using using System.Collections.Generic; using System.Linq; - using ImageProcessor.Processors; using ImageProcessor.Web.Configuration; + using ImageProcessor.Web.Processors; #endregion /// @@ -45,16 +45,16 @@ namespace ImageProcessor.Web lock (SyncRoot) { // Get a list of all graphics processors that have parsed and matched the query string. - List graphicsProcessors = + List graphicsProcessors = ImageProcessorConfiguration.Instance.GraphicsProcessors .Where(x => x.MatchRegexIndex(factory.QueryString) != int.MaxValue) .OrderBy(y => y.SortOrder) .ToList(); // Loop through and process the image. - foreach (IGraphicsProcessor graphicsProcessor in graphicsProcessors) + foreach (IWebGraphicsProcessor graphicsProcessor in graphicsProcessors) { - factory.CurrentImageFormat.ApplyProcessor(graphicsProcessor.ProcessImage, factory); + factory.CurrentImageFormat.ApplyProcessor(graphicsProcessor.Processor.ProcessImage, factory); } } } diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj index bdf8ba8dc..40d4d8fdd 100644 --- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj +++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj @@ -49,20 +49,26 @@ - - - - - + + + + + + + + + + + @@ -72,13 +78,18 @@ - + Designer - + + Designer + + + + + Designer - diff --git a/src/ImageProcessor.Web/NET45/Processors/Alpha.cs b/src/ImageProcessor.Web/NET45/Processors/Alpha.cs new file mode 100644 index 000000000..75993a702 --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Processors/Alpha.cs @@ -0,0 +1,80 @@ +namespace ImageProcessor.Web.Processors +{ + using System; + using System.Text.RegularExpressions; + using ImageProcessor.Processors; + using ImageProcessor.Web.Helpers; + + /// + /// Encapsulates methods to change the alpha component of the image to effect its transparency. + /// + public class Alpha : IWebGraphicsProcessor + { + /// + /// The regular expression to search strings for. + /// + private static readonly Regex QueryRegex = new Regex(@"alpha=[^&|,]*", RegexOptions.Compiled); + + /// + /// Initializes a new instance of the class. + /// + public Alpha() + { + this.Processor = new ImageProcessor.Processors.Alpha(); + } + + /// + /// 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; + int percentage = Math.Abs(CommonParameterParserUtility.ParseIn100Range(match.Value)); + this.Processor.DynamicParameter = percentage; + } + + index += 1; + } + } + + return this.SortOrder; + } + } +} diff --git a/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs b/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs index 7fc0a49a5..80df3959c 100644 --- a/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs +++ b/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs @@ -75,7 +75,7 @@ namespace ImageProcessor.Web.Processors { // Set the index on the first instance only. this.SortOrder = match.Index; - this.Processor.DynamicParameter = ParameterParserUtilities.ParseColor(match.Value); + this.Processor.DynamicParameter = CommonParameterParserUtility.ParseColor(match.Value); } index += 1; diff --git a/src/ImageProcessor.Web/NET45/Processors/Brightness.cs b/src/ImageProcessor.Web/NET45/Processors/Brightness.cs new file mode 100644 index 000000000..602d34b1c --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Processors/Brightness.cs @@ -0,0 +1,89 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Encapsulates methods to change the brightness component of the image. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Processors +{ + using System.Text.RegularExpressions; + using ImageProcessor.Processors; + using ImageProcessor.Web.Helpers; + + /// + /// Encapsulates methods to change the brightness component of the image. + /// + public class Brightness : IWebGraphicsProcessor + { + /// + /// The regular expression to search strings for. + /// + private static readonly Regex QueryRegex = new Regex(@"brightness=[^&|,]*", RegexOptions.Compiled); + + /// + /// Initializes a new instance of the class. + /// + public Brightness() + { + this.Processor = new ImageProcessor.Processors.Brightness(); + } + + /// + /// 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; + int percentage = CommonParameterParserUtility.ParseIn100Range(match.Value); + this.Processor.DynamicParameter = percentage; + } + + index += 1; + } + } + + return this.SortOrder; + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET45/Processors/Contrast.cs b/src/ImageProcessor.Web/NET45/Processors/Contrast.cs new file mode 100644 index 000000000..09ec2808c --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Processors/Contrast.cs @@ -0,0 +1,89 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Encapsulates methods to change the contrast component of the image. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Processors +{ + using System.Text.RegularExpressions; + using ImageProcessor.Processors; + using ImageProcessor.Web.Helpers; + + /// + /// Encapsulates methods to change the contrast component of the image. + /// + public class Contrast : IWebGraphicsProcessor + { + /// + /// The regular expression to search strings for. + /// + private static readonly Regex QueryRegex = new Regex(@"contrast=[^&|,]*", RegexOptions.Compiled); + + /// + /// Initializes a new instance of the class. + /// + public Contrast() + { + this.Processor = new ImageProcessor.Processors.Contrast(); + } + + /// + /// 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; + int percentage = CommonParameterParserUtility.ParseIn100Range(match.Value); + this.Processor.DynamicParameter = percentage; + } + + index += 1; + } + } + + return this.SortOrder; + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET45/Processors/Crop.cs b/src/ImageProcessor.Web/NET45/Processors/Crop.cs new file mode 100644 index 000000000..4ca186d5c --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Processors/Crop.cs @@ -0,0 +1,166 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Crops an image to the given directions. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Processors +{ + using System.Text; + using System.Text.RegularExpressions; + using ImageProcessor.Core.Common.Extensions; + using ImageProcessor.Imaging; + using ImageProcessor.Processors; + + /// + /// Crops an image to the given directions. + /// + public class Crop : IWebGraphicsProcessor + { + /// + /// The regular expression to search strings for. + /// + /// + private static readonly Regex QueryRegex = new Regex(@"(crop=|cropmode=)[^&]*", RegexOptions.Compiled); + + /// + /// The coordinate regex. + /// + private static readonly Regex CoordinateRegex = new Regex(@"crop=\d+(.\d+)?[,-]\d+(.\d+)?[,-]\d+(.\d+)?[,-]\d+(.\d+)?", RegexOptions.Compiled); + + /// + /// The mode regex. + /// + private static readonly Regex ModeRegex = new Regex(@"cropmode=(pixels|percent)", RegexOptions.Compiled); + + /// + /// Initializes a new instance of the class. + /// + public Crop() + { + this.Processor = new ImageProcessor.Processors.Crop(); + } + + /// + /// 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; + + // First merge the matches so we can parse . + StringBuilder stringBuilder = new StringBuilder(); + + 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; + } + + stringBuilder.Append(match.Value); + + index += 1; + } + } + + if (this.SortOrder < int.MaxValue) + { + // Match syntax + string toParse = stringBuilder.ToString(); + + float[] coordinates = this.ParseCoordinates(toParse); + CropMode cropMode = this.ParseMode(toParse); + + CropLayer cropLayer = new CropLayer(coordinates[0], coordinates[1], coordinates[2], coordinates[3], cropMode); + this.Processor.DynamicParameter = cropLayer; + } + + return this.SortOrder; + } + + /// + /// Returns the correct for the given string. + /// + /// + /// The input string containing the value to parse. + /// + /// + /// The correct . + /// + private CropMode ParseMode(string input) + { + foreach (Match match in ModeRegex.Matches(input)) + { + // Split on = + string mode = match.Value.Split('=')[1]; + + switch (mode) + { + case "percent": + return CropMode.Percentage; + case "pixels": + return CropMode.Pixels; + } + } + + return CropMode.Pixels; + } + + /// + /// Returns the correct for the given string. + /// + /// + /// The input string containing the value to parse. + /// + /// + /// The correct . + /// + private float[] ParseCoordinates(string input) + { + float[] floats = { }; + + foreach (Match match in CoordinateRegex.Matches(input)) + { + floats = match.Value.ToPositiveFloatArray(); + } + + return floats; + } + } +} diff --git a/src/ImageProcessor.Web/NET45/Processors/Quality.cs b/src/ImageProcessor.Web/NET45/Processors/Quality.cs new file mode 100644 index 000000000..fa11777db --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Processors/Quality.cs @@ -0,0 +1,90 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Encapsulates methods to change the quality component of the image. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Processors +{ + using System; + using System.Text.RegularExpressions; + using ImageProcessor.Processors; + using ImageProcessor.Web.Helpers; + + /// + /// Encapsulates methods to change the quality component of the image. + /// + public class Quality : IWebGraphicsProcessor + { + /// + /// The regular expression to search strings for. + /// + private static readonly Regex QueryRegex = new Regex(@"quality=[^&|,]*", RegexOptions.Compiled); + + /// + /// Initializes a new instance of the class. + /// + public Quality() + { + this.Processor = new ImageProcessor.Processors.Quality(); + } + + /// + /// 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; + int percentage = Math.Abs(CommonParameterParserUtility.ParseIn100Range(match.Value)); + this.Processor.DynamicParameter = percentage; + } + + index += 1; + } + } + + return this.SortOrder; + } + } +} diff --git a/src/ImageProcessor.Web/NET45/Processors/Rotate.cs b/src/ImageProcessor.Web/NET45/Processors/Rotate.cs index 58375b179..74a707d36 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Rotate.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Rotate.cs @@ -82,7 +82,7 @@ namespace ImageProcessor.Web.Processors { // Set the index on the first instance only. this.SortOrder = match.Index; - this.Processor.DynamicParameter = ParameterParserUtilities.ParseAngle(match.Value); + this.Processor.DynamicParameter = CommonParameterParserUtility.ParseAngle(match.Value); } index += 1; diff --git a/src/ImageProcessor.Web/NET45/Processors/Saturation.cs b/src/ImageProcessor.Web/NET45/Processors/Saturation.cs new file mode 100644 index 000000000..469a19ba6 --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Processors/Saturation.cs @@ -0,0 +1,92 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Encapsulates methods to change the saturation component of the image. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Processors +{ + using System.Text.RegularExpressions; + using ImageProcessor.Processors; + using ImageProcessor.Web.Helpers; + + /// + /// Encapsulates methods to change the saturation component of the image. + /// + /// + /// + /// + public class Saturation : IWebGraphicsProcessor + { + /// + /// The regular expression to search strings for. + /// + private static readonly Regex QueryRegex = new Regex(@"saturation=[^&|,]*", RegexOptions.Compiled); + + /// + /// Initializes a new instance of the class. + /// + public Saturation() + { + this.Processor = new ImageProcessor.Processors.Saturation(); + } + + /// + /// 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; + int percentage = CommonParameterParserUtility.ParseIn100Range(match.Value); + this.Processor.DynamicParameter = percentage; + } + + index += 1; + } + } + + return this.SortOrder; + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 8d9b34f75..c0ac9062b 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -91,11 +91,6 @@ namespace ImageProcessor #endregion #region Properties - /// - /// Gets the local image for manipulation. - /// - public Image Image { get; private set; } - /// /// Gets the path to the local image for manipulation. /// @@ -126,6 +121,11 @@ namespace ImageProcessor /// public ConcurrentDictionary ExifPropertyItems { get; set; } + /// + /// Gets or sets the local image for manipulation. + /// + internal Image Image { get; set; } + /// /// Gets or sets the original extension. /// @@ -254,33 +254,6 @@ namespace ImageProcessor return this; } - /// - /// Updates the specified image. Used by the various IProcessors. - /// - /// The image. - /// - /// The current instance of the class. - /// - public ImageFactory Update(Image image) - { - if (this.ShouldProcess) - { - this.Image = image; - - // Get the correct image format for the image. - using (MemoryStream stream = new MemoryStream()) - { - image.Save(stream, image.RawFormat); - stream.Position = 0; - int quality = this.CurrentImageFormat.Quality; - this.CurrentImageFormat = FormatUtilities.GetFormat(stream); - this.CurrentImageFormat.Quality = quality; - } - } - - return this; - } - /// /// Resets the current image to its original loaded state. /// diff --git a/src/ImageProcessor/Imaging/Filters/GothamMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/GothamMatrixFilter.cs index ddbb92128..abeaedf5c 100644 --- a/src/ImageProcessor/Imaging/Filters/GothamMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/GothamMatrixFilter.cs @@ -79,13 +79,13 @@ namespace ImageProcessor.Imaging.Filters } // Add brightness and contrast to finish the effect. - factory.Update(newImage); + factory.Image = newImage; Brightness brightness = new Brightness { DynamicParameter = 5 }; - newImage = (Bitmap)brightness.ProcessImage(factory); + newImage = brightness.ProcessImage(factory); - factory.Update(newImage); + factory.Image = newImage; Contrast contrast = new Contrast { DynamicParameter = 85 }; - newImage = (Bitmap)contrast.ProcessImage(factory); + newImage = contrast.ProcessImage(factory); // Reassign the image. image.Dispose(); diff --git a/src/ImageProcessor/Imaging/Filters/LomographMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/LomographMatrixFilter.cs index c44bce5c8..253bb419a 100644 --- a/src/ImageProcessor/Imaging/Filters/LomographMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/LomographMatrixFilter.cs @@ -50,15 +50,14 @@ namespace ImageProcessor.Imaging.Filters attributes.SetColorMatrix(this.Matrix); Rectangle rectangle = new Rectangle(0, 0, image.Width, image.Height); - graphics.DrawImage(image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); } } // Add a vignette to finish the effect. - factory.Update(newImage); + factory.Image = newImage; Vignette vignette = new Vignette(); - newImage = (Bitmap)vignette.ProcessImage(factory); + newImage = vignette.ProcessImage(factory); // Reassign the image. image.Dispose(); diff --git a/src/ImageProcessor/Imaging/Filters/PolaroidMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/PolaroidMatrixFilter.cs index 947c79f25..af4c5fd4f 100644 --- a/src/ImageProcessor/Imaging/Filters/PolaroidMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/PolaroidMatrixFilter.cs @@ -85,7 +85,7 @@ namespace ImageProcessor.Imaging.Filters } // Add a vignette to finish the effect. - factory.Update(newImage); + factory.Image = newImage; Vignette vignette = new Vignette(); newImage = vignette.ProcessImage(factory); diff --git a/src/ImageProcessor/Imaging/Formats/FormatBase.cs b/src/ImageProcessor/Imaging/Formats/FormatBase.cs index 79c90a12b..de590aea2 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatBase.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatBase.cs @@ -73,7 +73,7 @@ namespace ImageProcessor.Imaging.Formats /// The . public virtual void ApplyProcessor(Func processor, ImageFactory factory) { - processor.Invoke(factory); + factory.Image = processor.Invoke(factory); } /// diff --git a/src/ImageProcessor/Imaging/Formats/GifFormat.cs b/src/ImageProcessor/Imaging/Formats/GifFormat.cs index b2b3cb413..87c9a0d30 100644 --- a/src/ImageProcessor/Imaging/Formats/GifFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/GifFormat.cs @@ -86,14 +86,14 @@ namespace ImageProcessor.Imaging.Formats { foreach (GifFrame frame in imageInfo.GifFrames) { - factory.Update(frame.Image); + factory.Image = frame.Image; frame.Image = quantizer.Quantize(processor.Invoke(factory)); encoder.AddFrame(frame); } } stream.Position = 0; - factory.Update(Image.FromStream(stream)); + factory.Image = Image.FromStream(stream); } else { diff --git a/src/ImageProcessor/Processors/Alpha.cs b/src/ImageProcessor/Processors/Alpha.cs index 70ff57a65..6301c0e97 100644 --- a/src/ImageProcessor/Processors/Alpha.cs +++ b/src/ImageProcessor/Processors/Alpha.cs @@ -10,37 +10,15 @@ namespace ImageProcessor.Processors { - #region Using using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; - using System.Globalization; - using System.Text.RegularExpressions; - #endregion /// /// Encapsulates methods to change the alpha component of the image to effect its transparency. /// public class Alpha : IGraphicsProcessor { - /// - /// The regular expression to search strings for. - /// - /// - private static readonly Regex QueryRegex = new Regex(@"alpha=(?:100|[1-9]?[0-9])", RegexOptions.Compiled); - - #region IGraphicsProcessor Members - /// - /// Gets the regular expression to search strings for. - /// - public Regex RegexPattern - { - get - { - return QueryRegex; - } - } - /// /// Gets or sets DynamicParameter. /// @@ -50,15 +28,6 @@ namespace ImageProcessor.Processors 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. /// @@ -68,42 +37,6 @@ namespace ImageProcessor.Processors 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; - int percentage = int.Parse(match.Value.Split('=')[1], CultureInfo.InvariantCulture); - - this.DynamicParameter = percentage; - } - - index += 1; - } - } - - return this.SortOrder; - } - /// /// Processes the image. /// @@ -152,6 +85,5 @@ namespace ImageProcessor.Processors return image; } - #endregion } } diff --git a/src/ImageProcessor/Processors/Brightness.cs b/src/ImageProcessor/Processors/Brightness.cs index 6671ec373..56a17cc2b 100644 --- a/src/ImageProcessor/Processors/Brightness.cs +++ b/src/ImageProcessor/Processors/Brightness.cs @@ -10,37 +10,15 @@ namespace ImageProcessor.Processors { - #region Using using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; - using System.Globalization; - using System.Text.RegularExpressions; - #endregion /// /// Encapsulates methods to change the brightness component of the image. /// public class Brightness : IGraphicsProcessor { - /// - /// The regular expression to search strings for. - /// - /// - private static readonly Regex QueryRegex = new Regex(@"brightness=(-?(?:100)|-?([1-9]?[0-9]))", RegexOptions.Compiled); - - #region IGraphicsProcessor Members - /// - /// Gets the regular expression to search strings for. - /// - public Regex RegexPattern - { - get - { - return QueryRegex; - } - } - /// /// Gets or sets DynamicParameter. /// @@ -50,15 +28,6 @@ namespace ImageProcessor.Processors 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. /// @@ -68,42 +37,6 @@ namespace ImageProcessor.Processors 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; - int percentage = int.Parse(match.Value.Split('=')[1], CultureInfo.InvariantCulture); - - this.DynamicParameter = percentage; - } - - index += 1; - } - } - - return this.SortOrder; - } - /// /// Processes the image. /// @@ -125,16 +58,14 @@ namespace ImageProcessor.Processors newImage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppPArgb); - ColorMatrix colorMatrix = new ColorMatrix( - new float[][] - { - new float[] { 1, 0, 0, 0, 0 }, - new float[] { 0, 1, 0, 0, 0 }, - new float[] { 0, 0, 1, 0, 0 }, - new float[] { 0, 0, 0, 1, 0 }, - new float[] { brightnessFactor, brightnessFactor, brightnessFactor, 0, 1 } - }); - + ColorMatrix colorMatrix = + new ColorMatrix( + new[] + { + new float[] { 1, 0, 0, 0, 0 }, new float[] { 0, 1, 0, 0, 0 }, + new float[] { 0, 0, 1, 0, 0 }, new float[] { 0, 0, 0, 1, 0 }, + new[] { brightnessFactor, brightnessFactor, brightnessFactor, 0, 1 } + }); using (Graphics graphics = Graphics.FromImage(newImage)) { @@ -142,7 +73,15 @@ namespace ImageProcessor.Processors { imageAttributes.SetColorMatrix(colorMatrix); - graphics.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes); + graphics.DrawImage( + image, + new Rectangle(0, 0, image.Width, image.Height), + 0, + 0, + image.Width, + image.Height, + GraphicsUnit.Pixel, + imageAttributes); image.Dispose(); image = newImage; @@ -159,6 +98,5 @@ namespace ImageProcessor.Processors return image; } - #endregion } -} +} \ No newline at end of file diff --git a/src/ImageProcessor/Processors/Contrast.cs b/src/ImageProcessor/Processors/Contrast.cs index 4d057d6d5..ee4557517 100644 --- a/src/ImageProcessor/Processors/Contrast.cs +++ b/src/ImageProcessor/Processors/Contrast.cs @@ -10,37 +10,15 @@ namespace ImageProcessor.Processors { - #region Using using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; - using System.Globalization; - using System.Text.RegularExpressions; - #endregion /// /// Encapsulates methods to change the contrast component of the image. /// public class Contrast : IGraphicsProcessor { - /// - /// The regular expression to search strings for. - /// - /// - private static readonly Regex QueryRegex = new Regex(@"contrast=(-?(?:100)|-?([1-9]?[0-9]))", RegexOptions.Compiled); - - #region IGraphicsProcessor Members - /// - /// Gets the regular expression to search strings for. - /// - public Regex RegexPattern - { - get - { - return QueryRegex; - } - } - /// /// Gets or sets DynamicParameter. /// @@ -50,15 +28,6 @@ namespace ImageProcessor.Processors 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. /// @@ -68,42 +37,6 @@ namespace ImageProcessor.Processors 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; - int percentage = int.Parse(match.Value.Split('=')[1], CultureInfo.InvariantCulture); - - this.DynamicParameter = percentage; - } - - index += 1; - } - } - - return this.SortOrder; - } - /// /// Processes the image. /// @@ -130,13 +63,13 @@ namespace ImageProcessor.Processors newImage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppPArgb); ColorMatrix colorMatrix = new ColorMatrix( - new float[][] + new[] { - new float[] { contrastFactor, 0, 0, 0, 0 }, - new float[] { 0, contrastFactor, 0, 0, 0 }, - new float[] { 0, 0, contrastFactor, 0, 0 }, + new[] { contrastFactor, 0, 0, 0, 0 }, + new[] { 0, contrastFactor, 0, 0, 0 }, + new[] { 0, 0, contrastFactor, 0, 0 }, new float[] { 0, 0, 0, 1, 0 }, - new float[] { factorTransform, factorTransform, factorTransform, 0, 1 } + new[] { factorTransform, factorTransform, factorTransform, 0, 1 } }); using (Graphics graphics = Graphics.FromImage(newImage)) @@ -162,6 +95,5 @@ namespace ImageProcessor.Processors return image; } - #endregion } -} +} \ No newline at end of file diff --git a/src/ImageProcessor/Processors/Crop.cs b/src/ImageProcessor/Processors/Crop.cs index 0124b0f61..abf9483ef 100644 --- a/src/ImageProcessor/Processors/Crop.cs +++ b/src/ImageProcessor/Processors/Crop.cs @@ -15,12 +15,7 @@ namespace ImageProcessor.Processors using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; - using System.Text; - using System.Text.RegularExpressions; - - using ImageProcessor.Core.Common.Extensions; using ImageProcessor.Imaging; - #endregion /// @@ -28,34 +23,6 @@ namespace ImageProcessor.Processors /// public class Crop : IGraphicsProcessor { - /// - /// The regular expression to search strings for. - /// - /// - private static readonly Regex QueryRegex = new Regex(@"crop=\d+(.\d+)?[,-]\d+(.\d+)?[,-]\d+(.\d+)?[,-]\d+(.\d+)?|cropmode=(pixels|percent)", RegexOptions.Compiled); - - /// - /// The coordinate regex. - /// - private static readonly Regex CoordinateRegex = new Regex(@"crop=\d+(.\d+)?[,-]\d+(.\d+)?[,-]\d+(.\d+)?[,-]\d+(.\d+)?", RegexOptions.Compiled); - - /// - /// The mode regex. - /// - private static readonly Regex ModeRegex = new Regex(@"cropmode=(pixels|percent)", RegexOptions.Compiled); - - #region IGraphicsProcessor Members - /// - /// Gets the regular expression to search strings for. - /// - public Regex RegexPattern - { - get - { - return QueryRegex; - } - } - /// /// Gets or sets DynamicParameter. /// @@ -65,15 +32,6 @@ namespace ImageProcessor.Processors 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. /// @@ -83,56 +41,6 @@ namespace ImageProcessor.Processors 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; - - // First merge the matches so we can parse . - StringBuilder stringBuilder = new StringBuilder(); - - 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; - } - - stringBuilder.Append(match.Value); - - index += 1; - } - } - - if (this.SortOrder < int.MaxValue) - { - // Match syntax - string toParse = stringBuilder.ToString(); - - float[] coordinates = this.ParseCoordinates(toParse); - CropMode cropMode = this.ParseMode(toParse); - - CropLayer cropLayer = new CropLayer(coordinates[0], coordinates[1], coordinates[2], coordinates[3], cropMode); - this.DynamicParameter = cropLayer; - } - - return this.SortOrder; - } - /// /// Processes the image. /// @@ -159,7 +67,7 @@ namespace ImageProcessor.Processors // Work out the percentages. float left = cropLayer.Left * sourceWidth; float top = cropLayer.Top * sourceHeight; - float width = (1 - cropLayer.Left - cropLayer.Right) * sourceWidth; + float width = (1 - cropLayer.Left - cropLayer.Right) * sourceWidth; float height = (1 - cropLayer.Top - cropLayer.Bottom) * sourceHeight; rectangleF = new RectangleF(left, top, width, height); @@ -226,55 +134,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 CropMode ParseMode(string input) - { - foreach (Match match in ModeRegex.Matches(input)) - { - // Split on = - string mode = match.Value.Split('=')[1]; - - switch (mode) - { - case "percent": - return CropMode.Percentage; - case "pixels": - return CropMode.Pixels; - } - } - - return CropMode.Pixels; - } - - /// - /// Returns the correct for the given string. - /// - /// - /// The input string containing the value to parse. - /// - /// - /// The correct . - /// - private float[] ParseCoordinates(string input) - { - float[] floats = { }; - - foreach (Match match in CoordinateRegex.Matches(input)) - { - floats = match.Value.ToPositiveFloatArray(); - } - - return floats; - } } } diff --git a/src/ImageProcessor/Processors/Quality.cs b/src/ImageProcessor/Processors/Quality.cs index 21995cd3c..6d4d10743 100644 --- a/src/ImageProcessor/Processors/Quality.cs +++ b/src/ImageProcessor/Processors/Quality.cs @@ -13,8 +13,6 @@ namespace ImageProcessor.Processors #region Using using System.Collections.Generic; using System.Drawing; - using System.Globalization; - using System.Text.RegularExpressions; #endregion /// @@ -22,23 +20,6 @@ namespace ImageProcessor.Processors /// public class Quality : IGraphicsProcessor { - /// - /// The regular expression to search strings for. - /// - private static readonly Regex QueryRegex = new Regex(@"quality=(?:100|[1-9]?[0-9])", RegexOptions.Compiled); - - #region IGraphicsProcessor Members - /// - /// Gets the regular expression to search strings for. - /// - public Regex RegexPattern - { - get - { - return QueryRegex; - } - } - /// /// Gets or sets DynamicParameter. /// @@ -48,15 +29,6 @@ namespace ImageProcessor.Processors 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. /// @@ -66,42 +38,6 @@ namespace ImageProcessor.Processors 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; - int percentage = int.Parse(match.Value.Split('=')[1], CultureInfo.InvariantCulture); - - this.DynamicParameter = percentage; - } - - index += 1; - } - } - - return this.SortOrder; - } - /// /// Processes the image. /// @@ -114,11 +50,8 @@ namespace ImageProcessor.Processors /// public Image ProcessImage(ImageFactory factory) { - // Set the internal property. factory.CurrentImageFormat.Quality = this.DynamicParameter; - return factory.Image; } - #endregion } } diff --git a/src/ImageProcessor/Processors/Saturation.cs b/src/ImageProcessor/Processors/Saturation.cs index 268de2f4a..9e07ecbfe 100644 --- a/src/ImageProcessor/Processors/Saturation.cs +++ b/src/ImageProcessor/Processors/Saturation.cs @@ -14,9 +14,6 @@ namespace ImageProcessor.Processors using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; - using System.Globalization; - using System.Text.RegularExpressions; - #endregion /// @@ -27,24 +24,7 @@ namespace ImageProcessor.Processors /// public class Saturation : IGraphicsProcessor { - /// - /// The regular expression to search strings for. - /// - /// - private static readonly Regex QueryRegex = new Regex(@"saturation=(-?(?:100)|-?([1-9]?[0-9]))", RegexOptions.Compiled); - #region IGraphicsProcessor Members - /// - /// Gets the regular expression to search strings for. - /// - public Regex RegexPattern - { - get - { - return QueryRegex; - } - } - /// /// Gets or sets DynamicParameter. /// @@ -54,15 +34,6 @@ namespace ImageProcessor.Processors 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. /// @@ -72,42 +43,6 @@ namespace ImageProcessor.Processors 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; - int percentage = int.Parse(match.Value.Split('=')[1], CultureInfo.InvariantCulture); - - this.DynamicParameter = percentage; - } - - index += 1; - } - } - - return this.SortOrder; - } - /// /// Processes the image. /// @@ -142,19 +77,19 @@ namespace ImageProcessor.Processors ColorMatrix colorMatrix = new ColorMatrix( - new float[][] + new[] { - new float[] + new[] { saturationComplementR + saturationFactor, saturationComplementR, saturationComplementR, 0, 0 }, - new float[] + new[] { saturationComplementG, saturationComplementG + saturationFactor, saturationComplementG, 0, 0 }, - new float[] + new[] { saturationComplementB, saturationComplementB, saturationComplementB + saturationFactor, 0, 0 @@ -196,4 +131,4 @@ namespace ImageProcessor.Processors } #endregion } -} +} \ 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 a11127fee..db3f37806 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/Web.config +++ b/src/TestWebsites/NET45/Test_Website_NET45/Web.config @@ -7,9 +7,9 @@ -
-
-
+
+
+
diff --git a/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config b/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config index 6aa5af4ea..6d9f621d1 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config +++ b/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config @@ -1,44 +1,40 @@ - - + - - - - - - - - - + + + + + + + + - + - - + + - - - + + - - - - - - + + + + + + - From ec04f6cb96bfc4a706a3e3dce5fb5e27d7c5c942 Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 10 Jun 2014 18:02:56 +0200 Subject: [PATCH 003/155] Improving header detection Former-commit-id: 860df41b20473a0f1f9f2eb8efaa759f02f7734c --- .../NET45/ImageProcessor.Web_NET45.csproj | 1 + .../NET45/Processors/Resize.cs | 324 ++++++++++++++++ src/ImageProcessor/ImageFactory.cs | 2 +- .../Imaging/Formats/FormatBase.cs | 2 +- .../Imaging/Formats/FormatUtilities.cs | 12 +- .../Imaging/Formats/ISupportedImageFormat.cs | 2 +- src/ImageProcessor/Imaging/ResizeLayer.cs | 15 +- src/ImageProcessor/Processors/Resize.cs | 348 +----------------- 8 files changed, 343 insertions(+), 363 deletions(-) create mode 100644 src/ImageProcessor.Web/NET45/Processors/Resize.cs diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj index 40d4d8fdd..322a8fc66 100644 --- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj +++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj @@ -67,6 +67,7 @@ + diff --git a/src/ImageProcessor.Web/NET45/Processors/Resize.cs b/src/ImageProcessor.Web/NET45/Processors/Resize.cs new file mode 100644 index 000000000..7d4a06ceb --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Processors/Resize.cs @@ -0,0 +1,324 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Resizes an image to the given dimensions. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Processors +{ + using System; + using System.Collections.Generic; + using System.Drawing; + using System.Linq; + using System.Text; + using System.Text.RegularExpressions; + using ImageProcessor.Core.Common.Extensions; + using ImageProcessor.Imaging; + using ImageProcessor.Processors; + + /// + /// Resizes an image to the given dimensions. + /// + public class Resize : IWebGraphicsProcessor + { + /// + /// The regular expression to search strings for. + /// + private static readonly Regex QueryRegex = new Regex(@"(width|height)=|(width|height)ratio=|mode=|anchor=|center=|upscale=", RegexOptions.Compiled); + + /// + /// The regular expression to search strings for the size attribute. + /// + private static readonly Regex SizeRegex = new Regex(@"(width|height)=\d+", RegexOptions.Compiled); + + /// + /// The regular expression to search strings for the ratio attribute. + /// + private static readonly Regex RatioRegex = new Regex(@"(width|height)ratio=\d+(.\d+)?", RegexOptions.Compiled); + + /// + /// The regular expression to search strings for the mode attribute. + /// + private static readonly Regex ModeRegex = new Regex(@"mode=(pad|stretch|crop|max)", RegexOptions.Compiled); + + /// + /// The regular expression to search strings for the anchor attribute. + /// + private static readonly Regex AnchorRegex = new Regex(@"anchor=(top|bottom|left|right|center)", RegexOptions.Compiled); + + /// + /// The regular expression to search strings for the center attribute. + /// + private static readonly Regex CenterRegex = new Regex(@"center=\d+(.\d+)?[,-]\d+(.\d+)", RegexOptions.Compiled); + + /// + /// The regular expression to search strings for the upscale attribute. + /// + private static readonly Regex UpscaleRegex = new Regex(@"upscale=false", RegexOptions.Compiled); + + /// + /// Initializes a new instance of the class. + /// + public Resize() + { + this.Processor = new ImageProcessor.Processors.Resize(); + } + + /// + /// 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; + + // First merge the matches so we can parse . + StringBuilder stringBuilder = new StringBuilder(); + + 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; + stringBuilder.Append(queryString); + } + + index += 1; + } + } + + // Match syntax + string toParse = stringBuilder.ToString(); + + Size size = this.ParseSize(toParse); + ResizeLayer resizeLayer = new ResizeLayer(size) + { + ResizeMode = this.ParseMode(toParse), + AnchorPosition = this.ParsePosition(toParse), + Upscale = !UpscaleRegex.IsMatch(toParse), + CenterCoordinates = this.ParseCoordinates(toParse), + }; + + this.Processor.DynamicParameter = resizeLayer; + + // Correctly parse any restrictions. + string restrictions; + this.Processor.Settings.TryGetValue("RestrictTo", out restrictions); + ((ImageProcessor.Processors.Resize)this.Processor).RestrictedSizes = this.ParseRestrictions(restrictions); + return this.SortOrder; + } + + /// + /// Returns the correct for the given string. + /// + /// + /// The input string containing the value to parse. + /// + /// + /// The . + /// + private Size ParseSize(string input) + { + const string Width = "width="; + const string Height = "height="; + const string WidthRatio = "widthratio="; + const string HeightRatio = "heightratio="; + Size size = new Size(); + + // First merge the matches so we can parse . + StringBuilder stringBuilder = new StringBuilder(); + foreach (Match match in SizeRegex.Matches(input)) + { + stringBuilder.Append(match.Value); + } + + // First cater for single dimensions. + string value = stringBuilder.ToString(); + + if (input.Contains(Width) && !input.Contains(Height)) + { + size = new Size(value.ToPositiveIntegerArray()[0], 0); + } + + if (input.Contains(Height) && !input.Contains(Width)) + { + size = new Size(0, value.ToPositiveIntegerArray()[0]); + } + + // Both dimensions supplied. + if (input.Contains(Height) && input.Contains(Width)) + { + int[] dimensions = value.ToPositiveIntegerArray(); + + // Check the order in which they have been supplied. + size = input.IndexOf(Width, StringComparison.Ordinal) < input.IndexOf(Height, StringComparison.Ordinal) + ? new Size(dimensions[0], dimensions[1]) + : new Size(dimensions[1], dimensions[0]); + } + + // Calculate any ratio driven sizes. + if (size.Width == 0 || size.Height == 0) + { + stringBuilder.Clear(); + foreach (Match match in RatioRegex.Matches(input)) + { + stringBuilder.Append(match.Value); + } + + value = stringBuilder.ToString(); + + // Replace 0 width + if (size.Width == 0 && size.Height > 0 && input.Contains(WidthRatio) && !input.Contains(HeightRatio)) + { + size.Width = (int)(value.ToPositiveFloatArray()[0] * size.Height); + } + + // Replace 0 height + if (size.Height == 0 && size.Width > 0 && input.Contains(HeightRatio) && !input.Contains(WidthRatio)) + { + size.Height = (int)(value.ToPositiveFloatArray()[0] * size.Width); + } + } + + return size; + } + + /// + /// Returns the correct for the given string. + /// + /// + /// The input string containing the value to parse. + /// + /// + /// The correct . + /// + private ResizeMode ParseMode(string input) + { + foreach (Match match in ModeRegex.Matches(input)) + { + // Split on = + string mode = match.Value.Split('=')[1]; + + switch (mode) + { + case "stretch": + return ResizeMode.Stretch; + case "crop": + return ResizeMode.Crop; + case "max": + return ResizeMode.Max; + default: + return ResizeMode.Pad; + } + } + + return ResizeMode.Pad; + } + + /// + /// Returns the correct for the given string. + /// + /// + /// The input string containing the value to parse. + /// + /// + /// The correct . + /// + private AnchorPosition ParsePosition(string input) + { + foreach (Match match in AnchorRegex.Matches(input)) + { + // Split on = + string anchor = match.Value.Split('=')[1]; + + switch (anchor) + { + case "top": + return AnchorPosition.Top; + case "bottom": + return AnchorPosition.Bottom; + case "left": + return AnchorPosition.Left; + case "right": + return AnchorPosition.Right; + default: + return AnchorPosition.Center; + } + } + + return AnchorPosition.Center; + } + + /// + /// Parses the coordinates. + /// + /// The input. + /// The array containing the coordinates + private float[] ParseCoordinates(string input) + { + float[] floats = { }; + + foreach (Match match in CenterRegex.Matches(input)) + { + floats = match.Value.ToPositiveFloatArray(); + } + + return floats; + } + + /// + /// Returns a of sizes to restrict resizing to. + /// + /// + /// The input. + /// + /// + /// The to restrict resizing to. + /// + private List ParseRestrictions(string input) + { + List sizes = new List(); + + if (!string.IsNullOrWhiteSpace(input)) + { + sizes.AddRange(input.Split(',').Select(this.ParseSize)); + } + + return sizes; + } + } +} diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index c0ac9062b..1112c2e22 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -365,7 +365,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - ResizeLayer layer = new ResizeLayer(size, Color.Transparent, ResizeMode.Max); + ResizeLayer layer = new ResizeLayer(size, ResizeMode.Max); return this.Resize(layer); } diff --git a/src/ImageProcessor/Imaging/Formats/FormatBase.cs b/src/ImageProcessor/Imaging/Formats/FormatBase.cs index de590aea2..0f317ba0c 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatBase.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatBase.cs @@ -23,7 +23,7 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public abstract byte[] FileHeader { get; } + public abstract byte[][] FileHeaders { get; } /// /// Gets the list of file extensions. diff --git a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs index d3b6f9c56..7a87ad400 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs @@ -43,11 +43,15 @@ namespace ImageProcessor.Imaging.Formats // ReSharper disable once LoopCanBeConvertedToQuery foreach (ISupportedImageFormat supportedImageFormat in supportedImageFormats) { - byte[] header = supportedImageFormat.FileHeader; - if (header.SequenceEqual(buffer.Take(header.Length))) + byte[][] headers = supportedImageFormat.FileHeaders; + + foreach (byte[] header in headers) { - stream.Position = 0; - return supportedImageFormat; + if (header.SequenceEqual(buffer.Take(header.Length))) + { + stream.Position = 0; + return supportedImageFormat; + } } } diff --git a/src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs b/src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs index 8ad4e0763..4296b1e58 100644 --- a/src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs @@ -23,7 +23,7 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - byte[] FileHeader { get; } + byte[][] FileHeaders { get; } /// /// Gets the list of file extensions. diff --git a/src/ImageProcessor/Imaging/ResizeLayer.cs b/src/ImageProcessor/Imaging/ResizeLayer.cs index 4fe81645b..dc5185922 100644 --- a/src/ImageProcessor/Imaging/ResizeLayer.cs +++ b/src/ImageProcessor/Imaging/ResizeLayer.cs @@ -26,10 +26,6 @@ namespace ImageProcessor.Imaging /// /// The containing the width and height to set the image to. /// - /// - /// The to set as the background color. - /// Used for image formats that do not support transparency (Default transparent) - /// /// /// The resize mode to apply to resized image. (Default ResizeMode.Pad) /// @@ -41,14 +37,12 @@ namespace ImageProcessor.Imaging /// public ResizeLayer( Size size, - Color? backgroundColor = null, ResizeMode resizeMode = ResizeMode.Pad, AnchorPosition anchorPosition = AnchorPosition.Center, bool upscale = true) { this.Size = size; this.Upscale = upscale; - this.BackgroundColor = backgroundColor ?? Color.Transparent; this.ResizeMode = resizeMode; this.AnchorPosition = anchorPosition; } @@ -60,11 +54,6 @@ namespace ImageProcessor.Imaging /// public Size Size { get; set; } - /// - /// Gets or sets the background color. - /// - public Color BackgroundColor { get; set; } - /// /// Gets or sets the resize mode. /// @@ -111,7 +100,6 @@ namespace ImageProcessor.Imaging return this.Size == resizeLayer.Size && this.ResizeMode == resizeLayer.ResizeMode && this.AnchorPosition == resizeLayer.AnchorPosition - && this.BackgroundColor == resizeLayer.BackgroundColor && this.Upscale == resizeLayer.Upscale; } @@ -126,8 +114,7 @@ namespace ImageProcessor.Imaging return this.Size.GetHashCode() + this.ResizeMode.GetHashCode() + this.AnchorPosition.GetHashCode() + - this.BackgroundColor.GetHashCode() + this.Upscale.GetHashCode(); } } -} +} \ No newline at end of file diff --git a/src/ImageProcessor/Processors/Resize.cs b/src/ImageProcessor/Processors/Resize.cs index 072848ee6..5cbfc2f92 100644 --- a/src/ImageProcessor/Processors/Resize.cs +++ b/src/ImageProcessor/Processors/Resize.cs @@ -18,10 +18,6 @@ namespace ImageProcessor.Processors using System.Drawing.Imaging; using System.Globalization; using System.Linq; - using System.Text; - using System.Text.RegularExpressions; - - using ImageProcessor.Core.Common.Extensions; using ImageProcessor.Imaging; #endregion @@ -30,58 +26,7 @@ namespace ImageProcessor.Processors /// public class Resize : IGraphicsProcessor { - /// - /// The regular expression to search strings for. - /// - private static readonly Regex QueryRegex = new Regex(@"(width|height)=|(width|height)ratio=|mode=|anchor=|center=|bgcolor=|upscale=", RegexOptions.Compiled); - - /// - /// The regular expression to search strings for the size attribute. - /// - private static readonly Regex SizeRegex = new Regex(@"(width|height)=\d+", RegexOptions.Compiled); - - /// - /// The regular expression to search strings for the ratio attribute. - /// - private static readonly Regex RatioRegex = new Regex(@"(width|height)ratio=\d+(.\d+)?", RegexOptions.Compiled); - - /// - /// The regular expression to search strings for the mode attribute. - /// - private static readonly Regex ModeRegex = new Regex(@"mode=(pad|stretch|crop|max)", RegexOptions.Compiled); - - /// - /// The regular expression to search strings for the anchor attribute. - /// - private static readonly Regex AnchorRegex = new Regex(@"anchor=(top|bottom|left|right|center)", RegexOptions.Compiled); - - /// - /// The regular expression to search strings for the center attribute. - /// - private static readonly Regex CenterRegex = new Regex(@"center=\d+(.\d+)?[,-]\d+(.\d+)", RegexOptions.Compiled); - - /// - /// The regular expression to search strings for the color attribute. - /// - private static readonly Regex ColorRegex = new Regex(@"bgcolor=(transparent|\d+,\d+,\d+,\d+|([0-9a-fA-F]{3}){1,2})", RegexOptions.Compiled); - - /// - /// The regular expression to search strings for the upscale attribute. - /// - private static readonly Regex UpscaleRegex = new Regex(@"upscale=false", RegexOptions.Compiled); - #region IGraphicsProcessor Members - /// - /// Gets the regular expression to search strings for. - /// - public Regex RegexPattern - { - get - { - return QueryRegex; - } - } - /// /// Gets or sets DynamicParameter. /// @@ -91,15 +36,6 @@ namespace ImageProcessor.Processors 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. /// @@ -110,56 +46,9 @@ namespace ImageProcessor.Processors } /// - /// The position in the original string where the first character of the captured substring was found. + /// Gets or sets the list of sizes to restrict resizing methods to. /// - /// - /// 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; - - // First merge the matches so we can parse . - StringBuilder stringBuilder = new StringBuilder(); - - 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; - stringBuilder.Append(queryString); - } - - index += 1; - } - } - - // Match syntax - string toParse = stringBuilder.ToString(); - - Size size = this.ParseSize(toParse); - ResizeLayer resizeLayer = new ResizeLayer(size) - { - ResizeMode = this.ParseMode(toParse), - AnchorPosition = this.ParsePosition(toParse), - BackgroundColor = this.ParseColor(toParse), - Upscale = !UpscaleRegex.IsMatch(toParse), - CenterCoordinates = this.ParseCoordinates(toParse), - }; - - this.DynamicParameter = resizeLayer; - - return this.SortOrder; - } + public List RestrictedSizes { get; set; } /// /// Processes the image. @@ -177,19 +66,16 @@ namespace ImageProcessor.Processors int height = this.DynamicParameter.Size.Height ?? 0; ResizeMode mode = this.DynamicParameter.ResizeMode; AnchorPosition anchor = this.DynamicParameter.AnchorPosition; - Color backgroundColor = this.DynamicParameter.BackgroundColor; bool upscale = this.DynamicParameter.Upscale; float[] centerCoordinates = this.DynamicParameter.CenterCoordinates; int defaultMaxWidth; int defaultMaxHeight; - string restrictions; - this.Settings.TryGetValue("RestrictTo", out restrictions); + 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); + return this.ResizeImage(factory, width, height, defaultMaxWidth, defaultMaxHeight, this.RestrictedSizes, mode, anchor, upscale, centerCoordinates); } #endregion @@ -215,9 +101,6 @@ namespace ImageProcessor.Processors /// /// A containing image resizing restrictions. /// - /// - /// The background color to pad the image with. - /// /// /// The mode with which to resize the image. /// @@ -240,7 +123,6 @@ namespace ImageProcessor.Processors int defaultMaxWidth, int defaultMaxHeight, List restrictedSizes, - Color backgroundColor, ResizeMode resizeMode = ResizeMode.Pad, AnchorPosition anchorPosition = AnchorPosition.Center, bool upscale = true, @@ -404,7 +286,7 @@ namespace ImageProcessor.Processors } // Restrict sizes - if (restrictedSizes.Any()) + if (restrictedSizes != null && restrictedSizes.Any()) { bool reject = true; foreach (Size restrictedSize in restrictedSizes) @@ -463,7 +345,6 @@ namespace ImageProcessor.Processors 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); } @@ -484,222 +365,5 @@ namespace ImageProcessor.Processors return image; } - - /// - /// Returns the correct for the given string. - /// - /// - /// The input string containing the value to parse. - /// - /// - /// The . - /// - private Size ParseSize(string input) - { - const string Width = "width="; - const string Height = "height="; - const string WidthRatio = "widthratio="; - const string HeightRatio = "heightratio="; - Size size = new Size(); - - // First merge the matches so we can parse . - StringBuilder stringBuilder = new StringBuilder(); - foreach (Match match in SizeRegex.Matches(input)) - { - stringBuilder.Append(match.Value); - } - - // First cater for single dimensions. - string value = stringBuilder.ToString(); - - if (input.Contains(Width) && !input.Contains(Height)) - { - size = new Size(value.ToPositiveIntegerArray()[0], 0); - } - - if (input.Contains(Height) && !input.Contains(Width)) - { - size = new Size(0, value.ToPositiveIntegerArray()[0]); - } - - // Both dimensions supplied. - if (input.Contains(Height) && input.Contains(Width)) - { - int[] dimensions = value.ToPositiveIntegerArray(); - - // Check the order in which they have been supplied. - size = input.IndexOf(Width, StringComparison.Ordinal) < input.IndexOf(Height, StringComparison.Ordinal) - ? new Size(dimensions[0], dimensions[1]) - : new Size(dimensions[1], dimensions[0]); - } - - // Calculate any ratio driven sizes. - if (size.Width == 0 || size.Height == 0) - { - stringBuilder.Clear(); - foreach (Match match in RatioRegex.Matches(input)) - { - stringBuilder.Append(match.Value); - } - - value = stringBuilder.ToString(); - - // Replace 0 width - if (size.Width == 0 && size.Height > 0 && input.Contains(WidthRatio) && !input.Contains(HeightRatio)) - { - size.Width = (int)(value.ToPositiveFloatArray()[0] * size.Height); - } - - // Replace 0 height - if (size.Height == 0 && size.Width > 0 && input.Contains(HeightRatio) && !input.Contains(WidthRatio)) - { - size.Height = (int)(value.ToPositiveFloatArray()[0] * size.Width); - } - } - - return size; - } - - /// - /// Returns the correct for the given string. - /// - /// - /// The input string containing the value to parse. - /// - /// - /// The correct . - /// - private ResizeMode ParseMode(string input) - { - foreach (Match match in ModeRegex.Matches(input)) - { - // Split on = - string mode = match.Value.Split('=')[1]; - - switch (mode) - { - case "stretch": - return ResizeMode.Stretch; - case "crop": - return ResizeMode.Crop; - case "max": - return ResizeMode.Max; - default: - return ResizeMode.Pad; - } - } - - return ResizeMode.Pad; - } - - /// - /// Returns the correct for the given string. - /// - /// - /// The input string containing the value to parse. - /// - /// - /// The correct . - /// - private AnchorPosition ParsePosition(string input) - { - foreach (Match match in AnchorRegex.Matches(input)) - { - // Split on = - string anchor = match.Value.Split('=')[1]; - - switch (anchor) - { - case "top": - return AnchorPosition.Top; - case "bottom": - return AnchorPosition.Bottom; - case "left": - return AnchorPosition.Left; - case "right": - return AnchorPosition.Right; - default: - return AnchorPosition.Center; - } - } - - return AnchorPosition.Center; - } - - /// - /// 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 ColorRegex.Matches(input)) - { - string value = match.Value.Split('=')[1]; - - if (value == "transparent") - { - return Color.Transparent; - } - - 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; - } - - /// - /// Returns a of sizes to restrict resizing to. - /// - /// - /// The input. - /// - /// - /// The to restrict resizing to. - /// - private List ParseRestrictions(string input) - { - List sizes = new List(); - - if (!string.IsNullOrWhiteSpace(input)) - { - sizes.AddRange(input.Split(',').Select(this.ParseSize)); - } - - return sizes; - } - - /// - /// Parses the coordinates. - /// - /// The input. - /// The array containing the coordinates - private float[] ParseCoordinates(string input) - { - float[] floats = { }; - - foreach (Match match in CenterRegex.Matches(input)) - { - floats = match.Value.ToPositiveFloatArray(); - } - - return floats; - } } -} +} \ No newline at end of file From e4b42b2d6cd29c48c1ec029544e8dc8f9469b55c Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 10 Jun 2014 18:03:27 +0200 Subject: [PATCH 004/155] Adding missing files Former-commit-id: e75715cbed7b9118d9e52905b051d98915db4ef2 --- src/ImageProcessor/Imaging/Formats/BitmapFormat.cs | 4 ++-- src/ImageProcessor/Imaging/Formats/GifFormat.cs | 4 ++-- src/ImageProcessor/Imaging/Formats/JpegFormat.cs | 11 +++++++++-- src/ImageProcessor/Imaging/Formats/PngFormat.cs | 4 ++-- src/ImageProcessor/Imaging/Formats/TiffFormat.cs | 4 ++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/ImageProcessor/Imaging/Formats/BitmapFormat.cs b/src/ImageProcessor/Imaging/Formats/BitmapFormat.cs index b971f276e..cf754e202 100644 --- a/src/ImageProcessor/Imaging/Formats/BitmapFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/BitmapFormat.cs @@ -21,11 +21,11 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public override byte[] FileHeader + public override byte[][] FileHeaders { get { - return Encoding.ASCII.GetBytes("BM"); + return new[] { Encoding.ASCII.GetBytes("BM") }; } } diff --git a/src/ImageProcessor/Imaging/Formats/GifFormat.cs b/src/ImageProcessor/Imaging/Formats/GifFormat.cs index 87c9a0d30..45d966f8f 100644 --- a/src/ImageProcessor/Imaging/Formats/GifFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/GifFormat.cs @@ -25,11 +25,11 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public override byte[] FileHeader + public override byte[][] FileHeaders { get { - return Encoding.ASCII.GetBytes("GIF"); + return new[] { Encoding.ASCII.GetBytes("GIF") }; } } diff --git a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs index 761088ddc..161ebe2e2 100644 --- a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs @@ -25,11 +25,18 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public override byte[] FileHeader + public override byte[][] FileHeaders { get { - return new byte[] { 255, 216, 255, 224 }; + return new[] + { + new byte[] { 255, 216, 255, 232 }, + new byte[] { 255, 216, 255, 227 }, + new byte[] { 255, 216, 255, 226 }, + new byte[] { 255, 216, 255, 224 }, + new byte[] { 255, 216, 255, 225 } + }; } } diff --git a/src/ImageProcessor/Imaging/Formats/PngFormat.cs b/src/ImageProcessor/Imaging/Formats/PngFormat.cs index da6b4dc5f..b3c13cc37 100644 --- a/src/ImageProcessor/Imaging/Formats/PngFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/PngFormat.cs @@ -22,11 +22,11 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public override byte[] FileHeader + public override byte[][] FileHeaders { get { - return new byte[] { 137, 80, 78, 71 }; + return new[] { new byte[] { 137, 80, 78, 71 } }; } } diff --git a/src/ImageProcessor/Imaging/Formats/TiffFormat.cs b/src/ImageProcessor/Imaging/Formats/TiffFormat.cs index 226c0efab..1b12cc80a 100644 --- a/src/ImageProcessor/Imaging/Formats/TiffFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/TiffFormat.cs @@ -23,11 +23,11 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public override byte[] FileHeader + public override byte[][] FileHeaders { get { - return new byte[] { 77, 77, 42 }; + return new[] { new byte[] { 77, 77, 42 } }; } } From e2b2602a6f3452a68690f4c3c5d18b83bf59894e Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 12 Jun 2014 10:00:02 +0200 Subject: [PATCH 005/155] Tidying up file detection Former-commit-id: d8bb807d08a118f2ba387eae4d75bb9959b9b6f3 --- src/ImageProcessor/Imaging/Formats/BitmapFormat.cs | 4 ++-- src/ImageProcessor/Imaging/Formats/FormatBase.cs | 2 +- .../Imaging/Formats/FormatUtilities.cs | 12 ++++-------- src/ImageProcessor/Imaging/Formats/GifFormat.cs | 4 ++-- .../Imaging/Formats/ISupportedImageFormat.cs | 2 +- src/ImageProcessor/Imaging/Formats/JpegFormat.cs | 11 ++--------- src/ImageProcessor/Imaging/Formats/PngFormat.cs | 4 ++-- src/ImageProcessor/Imaging/Formats/TiffFormat.cs | 4 ++-- 8 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/ImageProcessor/Imaging/Formats/BitmapFormat.cs b/src/ImageProcessor/Imaging/Formats/BitmapFormat.cs index cf754e202..b971f276e 100644 --- a/src/ImageProcessor/Imaging/Formats/BitmapFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/BitmapFormat.cs @@ -21,11 +21,11 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public override byte[][] FileHeaders + public override byte[] FileHeader { get { - return new[] { Encoding.ASCII.GetBytes("BM") }; + return Encoding.ASCII.GetBytes("BM"); } } diff --git a/src/ImageProcessor/Imaging/Formats/FormatBase.cs b/src/ImageProcessor/Imaging/Formats/FormatBase.cs index 0f317ba0c..de590aea2 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatBase.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatBase.cs @@ -23,7 +23,7 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public abstract byte[][] FileHeaders { get; } + public abstract byte[] FileHeader { get; } /// /// Gets the list of file extensions. diff --git a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs index 7a87ad400..d3b6f9c56 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs @@ -43,15 +43,11 @@ namespace ImageProcessor.Imaging.Formats // ReSharper disable once LoopCanBeConvertedToQuery foreach (ISupportedImageFormat supportedImageFormat in supportedImageFormats) { - byte[][] headers = supportedImageFormat.FileHeaders; - - foreach (byte[] header in headers) + byte[] header = supportedImageFormat.FileHeader; + if (header.SequenceEqual(buffer.Take(header.Length))) { - if (header.SequenceEqual(buffer.Take(header.Length))) - { - stream.Position = 0; - return supportedImageFormat; - } + stream.Position = 0; + return supportedImageFormat; } } diff --git a/src/ImageProcessor/Imaging/Formats/GifFormat.cs b/src/ImageProcessor/Imaging/Formats/GifFormat.cs index 45d966f8f..87c9a0d30 100644 --- a/src/ImageProcessor/Imaging/Formats/GifFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/GifFormat.cs @@ -25,11 +25,11 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public override byte[][] FileHeaders + public override byte[] FileHeader { get { - return new[] { Encoding.ASCII.GetBytes("GIF") }; + return Encoding.ASCII.GetBytes("GIF"); } } diff --git a/src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs b/src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs index 4296b1e58..8ad4e0763 100644 --- a/src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/ISupportedImageFormat.cs @@ -23,7 +23,7 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - byte[][] FileHeaders { get; } + byte[] FileHeader { get; } /// /// Gets the list of file extensions. diff --git a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs index 161ebe2e2..78265d458 100644 --- a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs @@ -25,18 +25,11 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public override byte[][] FileHeaders + public override byte[] FileHeader { get { - return new[] - { - new byte[] { 255, 216, 255, 232 }, - new byte[] { 255, 216, 255, 227 }, - new byte[] { 255, 216, 255, 226 }, - new byte[] { 255, 216, 255, 224 }, - new byte[] { 255, 216, 255, 225 } - }; + return new byte[] { 255, 216, 255 }; } } diff --git a/src/ImageProcessor/Imaging/Formats/PngFormat.cs b/src/ImageProcessor/Imaging/Formats/PngFormat.cs index b3c13cc37..da6b4dc5f 100644 --- a/src/ImageProcessor/Imaging/Formats/PngFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/PngFormat.cs @@ -22,11 +22,11 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public override byte[][] FileHeaders + public override byte[] FileHeader { get { - return new[] { new byte[] { 137, 80, 78, 71 } }; + return new byte[] { 137, 80, 78, 71 }; } } diff --git a/src/ImageProcessor/Imaging/Formats/TiffFormat.cs b/src/ImageProcessor/Imaging/Formats/TiffFormat.cs index 1b12cc80a..226c0efab 100644 --- a/src/ImageProcessor/Imaging/Formats/TiffFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/TiffFormat.cs @@ -23,11 +23,11 @@ namespace ImageProcessor.Imaging.Formats /// /// Gets the file header. /// - public override byte[][] FileHeaders + public override byte[] FileHeader { get { - return new[] { new byte[] { 77, 77, 42 } }; + return new byte[] { 77, 77, 42 }; } } From 01c222d4071098d522aec48766a212ff6649b468 Mon Sep 17 00:00:00 2001 From: James South Date: Wed, 18 Jun 2014 22:21:12 +0100 Subject: [PATCH 006/155] Updating cache checker. Original method was too processor intensive Former-commit-id: 689734e40fcd1a41d219e7b7e720c76943d179ba --- .../NET45/ImageProcessor.Web_NET45.csproj | 7 +- .../NET45/Processors/Filter.cs | 161 ++++++++++++++++++ .../Filters/MatrixFilterRegexAttribute.cs | 37 ---- .../Imaging/Filters/MatrixFilters.cs | 32 ++-- src/ImageProcessor/Processors/Filter.cs | 130 +------------- 5 files changed, 175 insertions(+), 192 deletions(-) create mode 100644 src/ImageProcessor.Web/NET45/Processors/Filter.cs delete mode 100644 src/ImageProcessor/Imaging/Filters/MatrixFilterRegexAttribute.cs diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj index 322a8fc66..694840487 100644 --- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj +++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj @@ -61,10 +61,12 @@ + + @@ -87,11 +89,6 @@ - - - Designer - - -
-
-
+
+
+
From eebb79819a9ccf151c5e96391b8ed4bdcc0faf5c Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 24 Jun 2014 23:32:06 +0100 Subject: [PATCH 027/155] Adding transparent webp support Former-commit-id: bde73846512628e8364d54420c2f1dac7af748e4 --- .../HttpModules/ImageProcessingModule.cs | 5 +- .../Imaging/Formats/WebPFormat.cs | 71 +++++++++++++------ src/ImageProcessorConsole/Program.cs | 27 +++++-- .../images/input/circle.png | 3 + .../images/input/rotate.jpg.REMOVED.git-id | 1 + .../images/output/circle.webp | 3 + .../images/output/rotate.webp | 3 + 7 files changed, 85 insertions(+), 28 deletions(-) create mode 100644 src/ImageProcessorConsole/images/input/circle.png create mode 100644 src/ImageProcessorConsole/images/input/rotate.jpg.REMOVED.git-id create mode 100644 src/ImageProcessorConsole/images/output/circle.webp create mode 100644 src/ImageProcessorConsole/images/output/rotate.webp diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index 91ec40aab..f2bd71ad3 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -359,13 +359,14 @@ namespace ImageProcessor.Web.HttpModules IPrincipal user = context.User ?? new GenericPrincipal(new GenericIdentity(string.Empty, string.Empty), new string[0]); // Do we have permission to call UrlAuthorizationModule.CheckUrlAccessForPrincipal? - PermissionSet permission = new PermissionSet(PermissionState.None); + PermissionSet permission = new PermissionSet(PermissionState.Unrestricted); permission.AddPermission(new AspNetHostingPermission(AspNetHostingPermissionLevel.Unrestricted)); bool hasPermission = permission.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet); bool isAllowed = true; - // Run the rewritten path past the auth system again, using the result as the default "AllowAccess" value + // Run the rewritten path past the authorization system again. + // We can then use the result as the default "AllowAccess" value if (hasPermission && !context.SkipAuthorization) { isAllowed = UrlAuthorizationModule.CheckUrlAccessForPrincipal(virtualCachedPath, user, "GET"); diff --git a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs index 5253983e3..15e4e4313 100644 --- a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs @@ -13,6 +13,7 @@ namespace ImageProcessor.Imaging.Formats { using System; + using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Drawing.Imaging; @@ -20,6 +21,8 @@ namespace ImageProcessor.Imaging.Formats using System.Runtime.InteropServices; using System.Text; + using ImageProcessor.Core.Common.Exceptions; + /// /// Provides the necessary information to support webp images. /// Adapted from @@ -72,6 +75,35 @@ namespace ImageProcessor.Imaging.Formats } } + /// + /// Applies the given processor the current image. + /// + /// The processor delegate. + /// The . + public override void ApplyProcessor(Func processor, ImageFactory factory) + { + base.ApplyProcessor(processor, factory); + + // Set the property item information from any Exif metadata. + // We do this here so that they can be changed between processor methods. + if (factory.PreserveExifData) + { + foreach (KeyValuePair propertItem in factory.ExifPropertyItems) + { + try + { + factory.Image.SetPropertyItem(propertItem.Value); + } + // ReSharper disable once EmptyGeneralCatchClause + catch + { + // Do nothing. The image format does not handle EXIF data. + // TODO: empty catch is fierce code smell. + } + } + } + } + /// /// Decodes the image to process. /// @@ -151,49 +183,48 @@ namespace ImageProcessor.Imaging.Formats IntPtr ptrData = pinnedWebP.AddrOfPinnedObject(); uint dataSize = (uint)webpData.Length; - int imgWidth; - int imgHeight; + int width; + int height; - if (WebPGetInfo(ptrData, dataSize, out imgWidth, out imgHeight) != 1) + if (WebPGetInfo(ptrData, dataSize, out width, out height) != 1) { - // TODO: Throw error? - return null; + throw new ImageFormatException("WebP image is corrupted."); } // Create a BitmapData and Lock all pixels to be written - Bitmap bmp = new Bitmap(imgWidth, imgHeight, PixelFormat.Format24bppRgb); - BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat); + Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); + BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat); // Allocate memory for uncompress image - int outputBufferSize = bmpData.Stride * imgHeight; + int outputBufferSize = bitmapData.Stride * height; IntPtr outputBuffer = Marshal.AllocHGlobal(outputBufferSize); // Uncompress the image - outputBuffer = WebPDecodeBGRInto(ptrData, dataSize, outputBuffer, outputBufferSize, bmpData.Stride); + outputBuffer = WebPDecodeBGRAInto(ptrData, dataSize, outputBuffer, outputBufferSize, bitmapData.Stride); // Write image to bitmap using Marshal byte[] buffer = new byte[outputBufferSize]; Marshal.Copy(outputBuffer, buffer, 0, outputBufferSize); - Marshal.Copy(buffer, 0, bmpData.Scan0, outputBufferSize); + Marshal.Copy(buffer, 0, bitmapData.Scan0, outputBufferSize); // Unlock the pixels - bmp.UnlockBits(bmpData); + bitmap.UnlockBits(bitmapData); // Free memory pinnedWebP.Free(); Marshal.FreeHGlobal(outputBuffer); - return bmp; + return bitmap; } /// - /// Lossly encodes the image in bitmap. + /// Lossy encodes the image in bitmap. /// /// /// Bitmap with the image /// /// - /// Quality. 0 = minimum ... 100 = maximimun quality + /// Quality. 0 = minimum ... 100 = maximum quality /// /// /// The byte array containing the encoded image data. @@ -207,9 +238,9 @@ namespace ImageProcessor.Imaging.Formats try { - BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); + BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); IntPtr unmanagedData; - int size = WebPEncodeBGR(bmpData.Scan0, bitmap.Width, bitmap.Height, bmpData.Stride, quality, out unmanagedData); + int size = WebPEncodeBGRA(bmpData.Scan0, bitmap.Width, bitmap.Height, bmpData.Stride, quality, out unmanagedData); // Copy image compress data to output array webpData = new byte[size]; @@ -266,16 +297,16 @@ namespace ImageProcessor.Imaging.Formats /// Size of allocated buffer /// /// - /// Specifies the distance between scanlines + /// Specifies the distance between scan-lines /// /// /// output_buffer if function succeeds; NULL otherwise /// [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr WebPDecodeBGRInto(IntPtr data, uint dataSize, IntPtr outputBuffer, int outputBufferSize, int outputStride); + private static extern IntPtr WebPDecodeBGRAInto(IntPtr data, uint dataSize, IntPtr outputBuffer, int outputBufferSize, int outputStride); /// - /// Lossless encoding images pointed to by *data in WebP format + /// Lossy encoding images pointed to by *data in WebP format /// /// /// Pointer to RGB image data @@ -299,7 +330,7 @@ namespace ImageProcessor.Imaging.Formats /// Size of WebP Image /// [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] - private static extern int WebPEncodeBGR(IntPtr rgb, int width, int height, int stride, float qualityFactor, out IntPtr output); + private static extern int WebPEncodeBGRA(IntPtr rgb, int width, int height, int stride, float qualityFactor, out IntPtr output); /// /// Frees the unmanaged memory. diff --git a/src/ImageProcessorConsole/Program.cs b/src/ImageProcessorConsole/Program.cs index cb33aef79..20e92e803 100644 --- a/src/ImageProcessorConsole/Program.cs +++ b/src/ImageProcessorConsole/Program.cs @@ -10,8 +10,11 @@ namespace ImageProcessorConsole { using System; + using System.Collections.Generic; using System.Drawing; using System.IO; + using System.Linq; + using ImageProcessor; using ImageProcessor.Imaging.Formats; @@ -37,8 +40,10 @@ namespace ImageProcessorConsole di.Create(); } - //FileInfo[] files = di.GetFiles("*.gif"); - FileInfo[] files = di.GetFiles(); + FileInfo[] files = di.GetFiles("*.jpg"); + //FileInfo[] files = di.GetFiles(); + //var files = GetFilesByExtensions(di, ".gif", ".webp"); + foreach (FileInfo fileInfo in files) { @@ -47,20 +52,30 @@ namespace ImageProcessorConsole // ImageProcessor using (MemoryStream inStream = new MemoryStream(photoBytes)) { - using (ImageFactory imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory(true)) { Size size = new Size(200, 200); // Load, resize, set the format and quality and save an image. imageFactory.Load(inStream) + .AutoRotate() .Constrain(size) - //.Format(new JpegFormat()) + .Format(new WebPFormat()) + .Quality(5) // ReSharper disable once AssignNullToNotNullAttribute - // .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".jpg"))); - .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name))); + .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".webp"))); + //.Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name))); } } } } + + public static IEnumerable GetFilesByExtensions(DirectoryInfo dir, params string[] extensions) + { + if (extensions == null) + throw new ArgumentNullException("extensions"); + IEnumerable files = dir.EnumerateFiles(); + return files.Where(f => extensions.Contains(f.Extension, StringComparer.OrdinalIgnoreCase)); + } } } diff --git a/src/ImageProcessorConsole/images/input/circle.png b/src/ImageProcessorConsole/images/input/circle.png new file mode 100644 index 000000000..3d96cf303 --- /dev/null +++ b/src/ImageProcessorConsole/images/input/circle.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3df296a3fd58930899d308558b128db760879cb776afba8f2d6511aba3934dd0 +size 6957 diff --git a/src/ImageProcessorConsole/images/input/rotate.jpg.REMOVED.git-id b/src/ImageProcessorConsole/images/input/rotate.jpg.REMOVED.git-id new file mode 100644 index 000000000..bf0538b24 --- /dev/null +++ b/src/ImageProcessorConsole/images/input/rotate.jpg.REMOVED.git-id @@ -0,0 +1 @@ +406a6a7916628c0c0bea8243565a7162ebd5a505 \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/circle.webp b/src/ImageProcessorConsole/images/output/circle.webp new file mode 100644 index 000000000..0a022dff6 --- /dev/null +++ b/src/ImageProcessorConsole/images/output/circle.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac5bfc52fe066984db96d0b169a7fb7ebd76f3a1cf946ba02a167475377903c2 +size 1228 diff --git a/src/ImageProcessorConsole/images/output/rotate.webp b/src/ImageProcessorConsole/images/output/rotate.webp new file mode 100644 index 000000000..fa870fffe --- /dev/null +++ b/src/ImageProcessorConsole/images/output/rotate.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3543de5854cc0a8a95b5249548abc8150040542a127ac6d89eb6338b8dfa3a83 +size 1812 From 3053267c3d16f7945d2ff26a40bbbed7396176c2 Mon Sep 17 00:00:00 2001 From: James South Date: Wed, 25 Jun 2014 14:23:42 +0100 Subject: [PATCH 028/155] Refactoring and sense checking Former-commit-id: 152ad831191fe1413038822f39a0a4fcdcda8ab2 --- build/Build.bat | 6 +- .../NuSpecs/ImageProcessor.Web.Config.nuspec | 14 +-- build/NuSpecs/ImageProcessor.Web.nuspec | 4 +- build/NuSpecs/ImageProcessor.nuspec | 1 + .../web.config.transform | 10 +-- .../ImageProcessor.Web/web.config.transform | 4 + .../NET45/Caching/DiskCache.cs | 3 +- .../NET45/Configuration/ImageCacheSection.cs | 2 +- .../Configuration/Resources/processing.config | 3 +- .../Helpers/CommonParameterParserUtility.cs | 3 +- .../HttpModules/ImageProcessingModule.cs | 2 +- .../NET45/Processors/Crop.cs | 3 +- .../NET45/Processors/Format.cs | 8 +- .../NET45/Processors/Resize.cs | 3 +- .../NET45/Processors/Watermark.cs | 3 +- .../NET45/Properties/AssemblyInfo.cs | 4 +- .../Common/Exceptions/ImageFormatException.cs | 3 +- .../Exceptions/ImageProcessingException.cs | 2 +- .../Common/Extensions/DoubleExtensions.cs | 2 +- .../Common/Extensions/IntegerExtensions.cs | 2 +- .../Common/Extensions/StringExtensions.cs | 6 +- .../ImageProcessorBootstrapper.cs | 3 +- src/ImageProcessor/ImageFactory.cs | 3 +- src/ImageProcessor/ImageProcessor.csproj | 10 +-- src/ImageProcessor/Imaging/Convolution.cs | 2 +- .../Imaging/Filters/ComicMatrixFilter.cs | 4 +- .../Imaging/Formats/WebPFormat.cs | 85 ++++++++++++------- src/ImageProcessor/Processors/Alpha.cs | 3 +- src/ImageProcessor/Processors/AutoRotate.cs | 3 +- .../Processors/BackgroundColor.cs | 3 +- src/ImageProcessor/Processors/Brightness.cs | 3 +- src/ImageProcessor/Processors/Contrast.cs | 3 +- src/ImageProcessor/Processors/Crop.cs | 3 +- src/ImageProcessor/Processors/Filter.cs | 3 +- src/ImageProcessor/Processors/Flip.cs | 3 +- src/ImageProcessor/Processors/Format.cs | 3 +- src/ImageProcessor/Processors/GaussianBlur.cs | 3 +- .../Processors/GaussianSharpen.cs | 3 +- src/ImageProcessor/Processors/Quality.cs | 3 +- src/ImageProcessor/Processors/Resize.cs | 3 +- src/ImageProcessor/Processors/Rotate.cs | 3 +- .../Processors/RoundedCorners.cs | 3 +- src/ImageProcessor/Processors/Saturation.cs | 3 +- src/ImageProcessor/Processors/Tint.cs | 3 +- src/ImageProcessor/Processors/Vignette.cs | 3 +- src/ImageProcessor/Processors/Watermark.cs | 3 +- src/ImageProcessor/Properties/AssemblyInfo.cs | 4 +- .../config/imageprocessor/processing.config | 41 ++++----- .../NET45/Test_Website_NET45/Views/Web.config | 2 +- .../NET45/Test_Website_NET45/Web.config | 5 ++ .../config/imageprocessor/processing.config | 2 + .../config/imageprocessor/security.config | 4 +- 52 files changed, 186 insertions(+), 124 deletions(-) rename src/ImageProcessor/{Core => }/Common/Exceptions/ImageFormatException.cs (94%) rename src/ImageProcessor/{Core => }/Common/Exceptions/ImageProcessingException.cs (97%) rename src/ImageProcessor/{Core => }/Common/Extensions/DoubleExtensions.cs (96%) rename src/ImageProcessor/{Core => }/Common/Extensions/IntegerExtensions.cs (97%) rename src/ImageProcessor/{Core => }/Common/Extensions/StringExtensions.cs (98%) diff --git a/build/Build.bat b/build/Build.bat index 61973a204..f39a94e86 100644 --- a/build/Build.bat +++ b/build/Build.bat @@ -1,7 +1,7 @@ @ECHO OFF -SET version=1.9.3.0 -SET webversion=3.2.7.0 -SET webconfigversion=1.1.2.0 +SET version=2.0.0.0 +SET webversion=4.0.0.0 +SET webconfigversion=2.0.0.0 ECHO Building ImageProcessor %version%, ImageProcess.Web %webversion% and ImageProcess.Web.Config %webconfigversion% diff --git a/build/NuSpecs/ImageProcessor.Web.Config.nuspec b/build/NuSpecs/ImageProcessor.Web.Config.nuspec index cb27a3fb2..eb605f2b8 100644 --- a/build/NuSpecs/ImageProcessor.Web.Config.nuspec +++ b/build/NuSpecs/ImageProcessor.Web.Config.nuspec @@ -21,19 +21,19 @@ Feedback is always welcome Image Imaging ASP Performance Processing HttpModule Cache Resize Rotate RoundedCorners Flip Crop Filter Effects Quality Watermark Alpha Vignette Saturation Brightness Contrast Gif Jpg Jpeg Bitmap Png Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated - - + + - - + + - - - + + + \ No newline at end of file diff --git a/build/NuSpecs/ImageProcessor.Web.nuspec b/build/NuSpecs/ImageProcessor.Web.nuspec index 5e640a422..840d438a2 100644 --- a/build/NuSpecs/ImageProcessor.Web.nuspec +++ b/build/NuSpecs/ImageProcessor.Web.nuspec @@ -27,10 +27,10 @@ Feedback is always welcome - + - + diff --git a/build/NuSpecs/ImageProcessor.nuspec b/build/NuSpecs/ImageProcessor.nuspec index 80bdd79a1..85b661b2e 100644 --- a/build/NuSpecs/ImageProcessor.nuspec +++ b/build/NuSpecs/ImageProcessor.nuspec @@ -25,5 +25,6 @@ Feedback is always welcome. + \ No newline at end of file diff --git a/build/content/ImageProcessor.Web.Config/web.config.transform b/build/content/ImageProcessor.Web.Config/web.config.transform index c2ed6d5a1..3c88a71b1 100644 --- a/build/content/ImageProcessor.Web.Config/web.config.transform +++ b/build/content/ImageProcessor.Web.Config/web.config.transform @@ -2,9 +2,9 @@ -
-
-
+
+
+
@@ -13,8 +13,4 @@ - - - - diff --git a/build/content/ImageProcessor.Web/web.config.transform b/build/content/ImageProcessor.Web/web.config.transform index a541ff10e..7d02ee462 100644 --- a/build/content/ImageProcessor.Web/web.config.transform +++ b/build/content/ImageProcessor.Web/web.config.transform @@ -7,6 +7,10 @@ + + + + diff --git a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs index f64fad546..23612916b 100644 --- a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs +++ b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs @@ -19,7 +19,8 @@ namespace ImageProcessor.Web.Caching using System.Threading.Tasks; using System.Web; using System.Web.Hosting; - using ImageProcessor.Core.Common.Extensions; + + using ImageProcessor.Common.Extensions; using ImageProcessor.Web.Configuration; using ImageProcessor.Web.Helpers; #endregion diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs index 27e5320c3..04a550729 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs @@ -15,7 +15,7 @@ namespace ImageProcessor.Web.Configuration using System.IO; using System.Xml; - using ImageProcessor.Core.Common.Extensions; + using ImageProcessor.Common.Extensions; using ImageProcessor.Web.Helpers; #endregion diff --git a/src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config b/src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config index 3d3aec8f8..e1ecdfa59 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config +++ b/src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config @@ -4,12 +4,13 @@ + - + diff --git a/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs index 88f935076..ae71ca7ef 100644 --- a/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs +++ b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Web.Helpers using System.Drawing; using System.Globalization; using System.Text.RegularExpressions; - using ImageProcessor.Core.Common.Extensions; + + using ImageProcessor.Common.Extensions; using ImageProcessor.Imaging; /// diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index f2bd71ad3..67f3aee5d 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -29,7 +29,7 @@ namespace ImageProcessor.Web.HttpModules using System.Web.Hosting; using System.Web.Security; - using ImageProcessor.Core.Common.Extensions; + using ImageProcessor.Common.Extensions; using ImageProcessor.Web.Caching; using ImageProcessor.Web.Configuration; using ImageProcessor.Web.Helpers; diff --git a/src/ImageProcessor.Web/NET45/Processors/Crop.cs b/src/ImageProcessor.Web/NET45/Processors/Crop.cs index a446e37b8..372d277c3 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Crop.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Crop.cs @@ -12,7 +12,8 @@ namespace ImageProcessor.Web.Processors { using System.Text; using System.Text.RegularExpressions; - using ImageProcessor.Core.Common.Extensions; + + using ImageProcessor.Common.Extensions; using ImageProcessor.Imaging; using ImageProcessor.Processors; diff --git a/src/ImageProcessor.Web/NET45/Processors/Format.cs b/src/ImageProcessor.Web/NET45/Processors/Format.cs index 436361175..b419f211f 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Format.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Format.cs @@ -11,9 +11,12 @@ namespace ImageProcessor.Web.Processors { using System; + using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; + using System.Web; + using ImageProcessor.Configuration; using ImageProcessor.Imaging.Formats; using ImageProcessor.Processors; @@ -135,13 +138,14 @@ namespace ImageProcessor.Web.Processors identifier = identifier.ToLowerInvariant(); string finalIdentifier = identifier.Equals("png8") ? "png" : identifier; ISupportedImageFormat newFormat = null; - ISupportedImageFormat format = ImageProcessorBootstrapper.Instance.SupportedImageFormats - .FirstOrDefault(f => f.FileExtensions.Any(e => e.Equals(finalIdentifier, StringComparison.InvariantCultureIgnoreCase))); + List formats = ImageProcessorBootstrapper.Instance.SupportedImageFormats.ToList(); + ISupportedImageFormat format = formats.FirstOrDefault(f => f.FileExtensions.Any(e => e.Equals(finalIdentifier, StringComparison.InvariantCultureIgnoreCase))); if (format != null) { // Return a new instance as we want to use instance properties. newFormat = Activator.CreateInstance(format.GetType()) as ISupportedImageFormat; + if (newFormat != null) { // I wish this wasn't hard-coded but there's no way I can diff --git a/src/ImageProcessor.Web/NET45/Processors/Resize.cs b/src/ImageProcessor.Web/NET45/Processors/Resize.cs index 7d4a06ceb..95d962958 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Resize.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Resize.cs @@ -16,7 +16,8 @@ namespace ImageProcessor.Web.Processors using System.Linq; using System.Text; using System.Text.RegularExpressions; - using ImageProcessor.Core.Common.Extensions; + + using ImageProcessor.Common.Extensions; using ImageProcessor.Imaging; using ImageProcessor.Processors; diff --git a/src/ImageProcessor.Web/NET45/Processors/Watermark.cs b/src/ImageProcessor.Web/NET45/Processors/Watermark.cs index 641131761..27e83e288 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Watermark.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Watermark.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Web.Processors using System.Globalization; using System.Linq; using System.Text.RegularExpressions; - using ImageProcessor.Core.Common.Extensions; + + using ImageProcessor.Common.Extensions; using ImageProcessor.Imaging; using ImageProcessor.Processors; using ImageProcessor.Web.Helpers; diff --git a/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs b/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs index 8763d6242..d5ad131ff 100644 --- a/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs +++ b/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ using ImageProcessor.Web.HttpModules; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.2.7.0")] -[assembly: AssemblyFileVersion("3.2.7.0")] \ No newline at end of file +[assembly: AssemblyVersion("4.0.0.0")] +[assembly: AssemblyFileVersion("4.0.0.0")] \ No newline at end of file diff --git a/src/ImageProcessor/Core/Common/Exceptions/ImageFormatException.cs b/src/ImageProcessor/Common/Exceptions/ImageFormatException.cs similarity index 94% rename from src/ImageProcessor/Core/Common/Exceptions/ImageFormatException.cs rename to src/ImageProcessor/Common/Exceptions/ImageFormatException.cs index e858b6fcc..992bd9737 100644 --- a/src/ImageProcessor/Core/Common/Exceptions/ImageFormatException.cs +++ b/src/ImageProcessor/Common/Exceptions/ImageFormatException.cs @@ -8,10 +8,9 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Core.Common.Exceptions +namespace ImageProcessor.Common.Exceptions { using System; - using System.Runtime.Serialization; /// /// The exception that is thrown when loading the supported image format types has failed. diff --git a/src/ImageProcessor/Core/Common/Exceptions/ImageProcessingException.cs b/src/ImageProcessor/Common/Exceptions/ImageProcessingException.cs similarity index 97% rename from src/ImageProcessor/Core/Common/Exceptions/ImageProcessingException.cs rename to src/ImageProcessor/Common/Exceptions/ImageProcessingException.cs index db1adf2a6..44579604a 100644 --- a/src/ImageProcessor/Core/Common/Exceptions/ImageProcessingException.cs +++ b/src/ImageProcessor/Common/Exceptions/ImageProcessingException.cs @@ -8,7 +8,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Core.Common.Exceptions +namespace ImageProcessor.Common.Exceptions { using System; diff --git a/src/ImageProcessor/Core/Common/Extensions/DoubleExtensions.cs b/src/ImageProcessor/Common/Extensions/DoubleExtensions.cs similarity index 96% rename from src/ImageProcessor/Core/Common/Extensions/DoubleExtensions.cs rename to src/ImageProcessor/Common/Extensions/DoubleExtensions.cs index a8980c5c6..acc5b12c3 100644 --- a/src/ImageProcessor/Core/Common/Extensions/DoubleExtensions.cs +++ b/src/ImageProcessor/Common/Extensions/DoubleExtensions.cs @@ -8,7 +8,7 @@ //
// -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Core.Common.Extensions +namespace ImageProcessor.Common.Extensions { /// /// Encapsulates a series of time saving extension methods to the class. diff --git a/src/ImageProcessor/Core/Common/Extensions/IntegerExtensions.cs b/src/ImageProcessor/Common/Extensions/IntegerExtensions.cs similarity index 97% rename from src/ImageProcessor/Core/Common/Extensions/IntegerExtensions.cs rename to src/ImageProcessor/Common/Extensions/IntegerExtensions.cs index c4aa90bd8..e04798c0b 100644 --- a/src/ImageProcessor/Core/Common/Extensions/IntegerExtensions.cs +++ b/src/ImageProcessor/Common/Extensions/IntegerExtensions.cs @@ -8,7 +8,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Core.Common.Extensions +namespace ImageProcessor.Common.Extensions { using System.Globalization; diff --git a/src/ImageProcessor/Core/Common/Extensions/StringExtensions.cs b/src/ImageProcessor/Common/Extensions/StringExtensions.cs similarity index 98% rename from src/ImageProcessor/Core/Common/Extensions/StringExtensions.cs rename to src/ImageProcessor/Common/Extensions/StringExtensions.cs index a60590f66..fd7d54139 100644 --- a/src/ImageProcessor/Core/Common/Extensions/StringExtensions.cs +++ b/src/ImageProcessor/Common/Extensions/StringExtensions.cs @@ -8,10 +8,8 @@ //
// -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Core.Common.Extensions +namespace ImageProcessor.Common.Extensions { - #region Using - using System; using System.Globalization; using System.Linq; @@ -19,8 +17,6 @@ namespace ImageProcessor.Core.Common.Extensions using System.Text; using System.Text.RegularExpressions; - #endregion - /// /// Encapsulates a series of time saving extension methods to the class. /// diff --git a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs index 594ce5185..e1d59b7f6 100644 --- a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs +++ b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs @@ -13,7 +13,8 @@ namespace ImageProcessor.Configuration using System; using System.Collections.Generic; using System.Linq; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; using ImageProcessor.Imaging.Formats; /// diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 97e749cbc..db5e38beb 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -17,7 +17,8 @@ namespace ImageProcessor using System.Drawing; using System.Drawing.Imaging; using System.IO; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; using ImageProcessor.Imaging; using ImageProcessor.Imaging.Filters; using ImageProcessor.Imaging.Formats; diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 7e0c0b4f4..cab9513c1 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -60,12 +60,12 @@ - - + + - - - + + + diff --git a/src/ImageProcessor/Imaging/Convolution.cs b/src/ImageProcessor/Imaging/Convolution.cs index 26ff21f6f..bc8496ab2 100644 --- a/src/ImageProcessor/Imaging/Convolution.cs +++ b/src/ImageProcessor/Imaging/Convolution.cs @@ -15,7 +15,7 @@ namespace ImageProcessor.Imaging using System.Drawing.Imaging; using System.Runtime.InteropServices; - using ImageProcessor.Core.Common.Extensions; + using ImageProcessor.Common.Extensions; /// /// Provides methods for applying blurring and sharpening effects to an image.. diff --git a/src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs b/src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs index 872551b56..7d90d0bf9 100644 --- a/src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs +++ b/src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs @@ -17,7 +17,9 @@ namespace ImageProcessor.Imaging.Filters using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Runtime.InteropServices; - using ImageProcessor.Core.Common.Extensions; + + using ImageProcessor.Common.Extensions; + #endregion /// diff --git a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs index 15e4e4313..d0bff7a19 100644 --- a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs @@ -21,7 +21,7 @@ namespace ImageProcessor.Imaging.Formats using System.Runtime.InteropServices; using System.Text; - using ImageProcessor.Core.Common.Exceptions; + using ImageProcessor.Common.Exceptions; /// /// Provides the necessary information to support webp images. @@ -163,6 +163,10 @@ namespace ImageProcessor.Imaging.Formats memoryStream.Position = stream.Position = 0; } } + else + { + throw new ImageFormatException("Unable to encode WebP image."); + } return image; } @@ -183,36 +187,52 @@ namespace ImageProcessor.Imaging.Formats IntPtr ptrData = pinnedWebP.AddrOfPinnedObject(); uint dataSize = (uint)webpData.Length; + Bitmap bitmap = null; + BitmapData bitmapData = null; + IntPtr outputBuffer = IntPtr.Zero; int width; int height; if (WebPGetInfo(ptrData, dataSize, out width, out height) != 1) { - throw new ImageFormatException("WebP image is corrupted."); + throw new ImageFormatException("WebP image header is corrupted."); } - // Create a BitmapData and Lock all pixels to be written - Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); - BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat); + try + { + // Create a BitmapData and Lock all pixels to be written + bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); + bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat); - // Allocate memory for uncompress image - int outputBufferSize = bitmapData.Stride * height; - IntPtr outputBuffer = Marshal.AllocHGlobal(outputBufferSize); + // Allocate memory for uncompress image + int outputBufferSize = bitmapData.Stride * height; + outputBuffer = Marshal.AllocHGlobal(outputBufferSize); - // Uncompress the image - outputBuffer = WebPDecodeBGRAInto(ptrData, dataSize, outputBuffer, outputBufferSize, bitmapData.Stride); + // Uncompress the image + outputBuffer = WebPDecodeBGRAInto(ptrData, dataSize, outputBuffer, outputBufferSize, bitmapData.Stride); - // Write image to bitmap using Marshal - byte[] buffer = new byte[outputBufferSize]; - Marshal.Copy(outputBuffer, buffer, 0, outputBufferSize); - Marshal.Copy(buffer, 0, bitmapData.Scan0, outputBufferSize); + if (bitmapData.Scan0 != outputBuffer) + { + throw new ImageFormatException("Failed to decode WebP image with error " + (long)outputBuffer); + } - // Unlock the pixels - bitmap.UnlockBits(bitmapData); + // Write image to bitmap using Marshal + byte[] buffer = new byte[outputBufferSize]; + Marshal.Copy(outputBuffer, buffer, 0, outputBufferSize); + Marshal.Copy(buffer, 0, bitmapData.Scan0, outputBufferSize); + } + finally + { + // Unlock the pixels + if (bitmap != null) + { + bitmap.UnlockBits(bitmapData); + } - // Free memory - pinnedWebP.Free(); - Marshal.FreeHGlobal(outputBuffer); + // Free memory + pinnedWebP.Free(); + Marshal.FreeHGlobal(outputBuffer); + } return bitmap; } @@ -235,29 +255,34 @@ namespace ImageProcessor.Imaging.Formats private static bool EncodeLossly(Bitmap bitmap, int quality, out byte[] webpData) { webpData = null; + BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); + IntPtr unmanagedData = IntPtr.Zero; + bool encoded; try { - BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); - IntPtr unmanagedData; + // Attempt to lossy encode the image. int size = WebPEncodeBGRA(bmpData.Scan0, bitmap.Width, bitmap.Height, bmpData.Stride, quality, out unmanagedData); // Copy image compress data to output array webpData = new byte[size]; Marshal.Copy(unmanagedData, webpData, 0, size); - + encoded = true; + } + catch + { + encoded = false; + } + finally + { // Unlock the pixels bitmap.UnlockBits(bmpData); // Free memory WebPFree(unmanagedData); - - return true; - } - catch - { - return false; } + + return encoded; } /// @@ -335,13 +360,13 @@ namespace ImageProcessor.Imaging.Formats /// /// Frees the unmanaged memory. /// - /// + /// /// The pointer. /// /// /// 1 if success, otherwise error code returned in the case of (a) error(s). /// [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] - private static extern int WebPFree(IntPtr p); + private static extern int WebPFree(IntPtr pointer); } } \ No newline at end of file diff --git a/src/ImageProcessor/Processors/Alpha.cs b/src/ImageProcessor/Processors/Alpha.cs index e921233e8..a27e5f6f9 100644 --- a/src/ImageProcessor/Processors/Alpha.cs +++ b/src/ImageProcessor/Processors/Alpha.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Processors using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; /// /// Encapsulates methods to change the alpha component of the image to effect its transparency. diff --git a/src/ImageProcessor/Processors/AutoRotate.cs b/src/ImageProcessor/Processors/AutoRotate.cs index 1fcf81f48..7368d2574 100644 --- a/src/ImageProcessor/Processors/AutoRotate.cs +++ b/src/ImageProcessor/Processors/AutoRotate.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Processors using System; using System.Collections.Generic; using System.Drawing; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; using ImageProcessor.Imaging; /// diff --git a/src/ImageProcessor/Processors/BackgroundColor.cs b/src/ImageProcessor/Processors/BackgroundColor.cs index 6d785f1f3..a41396f90 100644 --- a/src/ImageProcessor/Processors/BackgroundColor.cs +++ b/src/ImageProcessor/Processors/BackgroundColor.cs @@ -13,7 +13,8 @@ namespace ImageProcessor.Processors using System; using System.Collections.Generic; using System.Drawing; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; /// /// Changes the background color of an image. diff --git a/src/ImageProcessor/Processors/Brightness.cs b/src/ImageProcessor/Processors/Brightness.cs index 4df039a07..51fb2be41 100644 --- a/src/ImageProcessor/Processors/Brightness.cs +++ b/src/ImageProcessor/Processors/Brightness.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Processors using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; /// /// Encapsulates methods to change the brightness component of the image. diff --git a/src/ImageProcessor/Processors/Contrast.cs b/src/ImageProcessor/Processors/Contrast.cs index a6fec199d..8289b4537 100644 --- a/src/ImageProcessor/Processors/Contrast.cs +++ b/src/ImageProcessor/Processors/Contrast.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Processors using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; /// /// Encapsulates methods to change the contrast component of the image. diff --git a/src/ImageProcessor/Processors/Crop.cs b/src/ImageProcessor/Processors/Crop.cs index 2b0f3c417..d0b8cb9ae 100644 --- a/src/ImageProcessor/Processors/Crop.cs +++ b/src/ImageProcessor/Processors/Crop.cs @@ -15,7 +15,8 @@ namespace ImageProcessor.Processors using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; using ImageProcessor.Imaging; /// diff --git a/src/ImageProcessor/Processors/Filter.cs b/src/ImageProcessor/Processors/Filter.cs index f98a041c0..e8130afa3 100644 --- a/src/ImageProcessor/Processors/Filter.cs +++ b/src/ImageProcessor/Processors/Filter.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Processors using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; using ImageProcessor.Imaging.Filters; /// diff --git a/src/ImageProcessor/Processors/Flip.cs b/src/ImageProcessor/Processors/Flip.cs index 5f57e5c9c..839edc34d 100644 --- a/src/ImageProcessor/Processors/Flip.cs +++ b/src/ImageProcessor/Processors/Flip.cs @@ -13,7 +13,8 @@ namespace ImageProcessor.Processors using System; using System.Collections.Generic; using System.Drawing; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; /// /// Flips an image horizontally or vertically. diff --git a/src/ImageProcessor/Processors/Format.cs b/src/ImageProcessor/Processors/Format.cs index 2f3af85a1..2695180af 100644 --- a/src/ImageProcessor/Processors/Format.cs +++ b/src/ImageProcessor/Processors/Format.cs @@ -13,7 +13,8 @@ namespace ImageProcessor.Processors using System; using System.Collections.Generic; using System.Drawing; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; using ImageProcessor.Imaging.Formats; /// diff --git a/src/ImageProcessor/Processors/GaussianBlur.cs b/src/ImageProcessor/Processors/GaussianBlur.cs index 3e2959094..1ddf9e787 100644 --- a/src/ImageProcessor/Processors/GaussianBlur.cs +++ b/src/ImageProcessor/Processors/GaussianBlur.cs @@ -13,7 +13,8 @@ namespace ImageProcessor.Processors using System; using System.Collections.Generic; using System.Drawing; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; using ImageProcessor.Imaging; /// diff --git a/src/ImageProcessor/Processors/GaussianSharpen.cs b/src/ImageProcessor/Processors/GaussianSharpen.cs index 2949a899a..8aaf84e5d 100644 --- a/src/ImageProcessor/Processors/GaussianSharpen.cs +++ b/src/ImageProcessor/Processors/GaussianSharpen.cs @@ -13,7 +13,8 @@ namespace ImageProcessor.Processors using System; using System.Collections.Generic; using System.Drawing; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; using ImageProcessor.Imaging; /// diff --git a/src/ImageProcessor/Processors/Quality.cs b/src/ImageProcessor/Processors/Quality.cs index 9d53ccb9e..015c519eb 100644 --- a/src/ImageProcessor/Processors/Quality.cs +++ b/src/ImageProcessor/Processors/Quality.cs @@ -13,7 +13,8 @@ namespace ImageProcessor.Processors using System; using System.Collections.Generic; using System.Drawing; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; /// /// Encapsulates methods to change the quality component of the image. diff --git a/src/ImageProcessor/Processors/Resize.cs b/src/ImageProcessor/Processors/Resize.cs index f52587492..3495dd3a0 100644 --- a/src/ImageProcessor/Processors/Resize.cs +++ b/src/ImageProcessor/Processors/Resize.cs @@ -17,7 +17,8 @@ namespace ImageProcessor.Processors using System.Drawing.Imaging; using System.Globalization; using System.Linq; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; using ImageProcessor.Imaging; /// diff --git a/src/ImageProcessor/Processors/Rotate.cs b/src/ImageProcessor/Processors/Rotate.cs index 4e1bd8142..70fabd1cc 100644 --- a/src/ImageProcessor/Processors/Rotate.cs +++ b/src/ImageProcessor/Processors/Rotate.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Processors using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; /// /// Encapsulates methods to rotate an image. diff --git a/src/ImageProcessor/Processors/RoundedCorners.cs b/src/ImageProcessor/Processors/RoundedCorners.cs index ebd26ef24..5df2367fe 100644 --- a/src/ImageProcessor/Processors/RoundedCorners.cs +++ b/src/ImageProcessor/Processors/RoundedCorners.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Processors using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; using ImageProcessor.Imaging; /// diff --git a/src/ImageProcessor/Processors/Saturation.cs b/src/ImageProcessor/Processors/Saturation.cs index f0e245821..b8d2a0819 100644 --- a/src/ImageProcessor/Processors/Saturation.cs +++ b/src/ImageProcessor/Processors/Saturation.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Processors using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; /// /// Encapsulates methods to change the saturation component of the image. diff --git a/src/ImageProcessor/Processors/Tint.cs b/src/ImageProcessor/Processors/Tint.cs index 9943a0cc3..603c7fd11 100644 --- a/src/ImageProcessor/Processors/Tint.cs +++ b/src/ImageProcessor/Processors/Tint.cs @@ -15,7 +15,8 @@ namespace ImageProcessor.Processors using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; /// /// Tints an image with the given color. diff --git a/src/ImageProcessor/Processors/Vignette.cs b/src/ImageProcessor/Processors/Vignette.cs index 9d4f12241..3be2beee1 100644 --- a/src/ImageProcessor/Processors/Vignette.cs +++ b/src/ImageProcessor/Processors/Vignette.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Processors using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; /// /// Encapsulates methods with which to add a vignette image effect to an image. diff --git a/src/ImageProcessor/Processors/Watermark.cs b/src/ImageProcessor/Processors/Watermark.cs index 9ce4771ff..e06eb812a 100644 --- a/src/ImageProcessor/Processors/Watermark.cs +++ b/src/ImageProcessor/Processors/Watermark.cs @@ -14,7 +14,8 @@ namespace ImageProcessor.Processors using System.Collections.Generic; using System.Drawing; using System.Drawing.Text; - using ImageProcessor.Core.Common.Exceptions; + + using ImageProcessor.Common.Exceptions; using ImageProcessor.Imaging; /// diff --git a/src/ImageProcessor/Properties/AssemblyInfo.cs b/src/ImageProcessor/Properties/AssemblyInfo.cs index bea6c1401..840a38ec8 100644 --- a/src/ImageProcessor/Properties/AssemblyInfo.cs +++ b/src/ImageProcessor/Properties/AssemblyInfo.cs @@ -32,6 +32,6 @@ using System.Security; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.9.3.0")] -[assembly: AssemblyFileVersion("1.9.3.0")] +[assembly: AssemblyVersion("2.0.0.0")] +[assembly: AssemblyFileVersion("2.0.0.0")] diff --git a/src/TestWebsites/NET4/config/imageprocessor/processing.config b/src/TestWebsites/NET4/config/imageprocessor/processing.config index 85283e9f2..9628cf652 100644 --- a/src/TestWebsites/NET4/config/imageprocessor/processing.config +++ b/src/TestWebsites/NET4/config/imageprocessor/processing.config @@ -4,41 +4,42 @@ - - - - - - - - - + + + + + + + + + + - + - - + + - - - + + - - - - - + + + + + + diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Web.config b/src/TestWebsites/NET45/Test_Website_NET45/Views/Web.config index 826ce19e8..3d9efc26a 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/Views/Web.config +++ b/src/TestWebsites/NET45/Test_Website_NET45/Views/Web.config @@ -45,11 +45,11 @@ + - diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Web.config b/src/TestWebsites/NET45/Test_Website_NET45/Web.config index d20021463..7f87cedd1 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/Web.config +++ b/src/TestWebsites/NET45/Test_Website_NET45/Web.config @@ -44,10 +44,15 @@ + + + + + diff --git a/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config b/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config index 6d9f621d1..2dc2d374e 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config +++ b/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config @@ -3,6 +3,8 @@ + + diff --git a/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/security.config b/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/security.config index 78b957605..d4781f99c 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/security.config +++ b/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/security.config @@ -1,9 +1,9 @@  - + - + From 666527058222247c0c2ace34a346e3a6cfb951a6 Mon Sep 17 00:00:00 2001 From: James South Date: Wed, 25 Jun 2014 15:11:10 +0100 Subject: [PATCH 029/155] FxCop tidy up Former-commit-id: 0a41cfb5d46dc42fc0e7140800b1972f5b6cc205 --- .../Common/Exceptions/ImageFormatException.cs | 1 + .../Exceptions/ImageProcessingException.cs | 1 + src/ImageProcessor/ImageProcessor.csproj | 1 + .../Imaging/Formats/JpegFormat.cs | 11 +- .../Imaging/Formats/NativeMethods.cs | 107 ++++++++++++++++++ .../Imaging/Formats/TiffFormat.cs | 11 +- .../Imaging/Formats/WebPFormat.cs | 103 +---------------- src/ImageProcessor/Settings.StyleCop | 1 + 8 files changed, 118 insertions(+), 118 deletions(-) create mode 100644 src/ImageProcessor/Imaging/Formats/NativeMethods.cs diff --git a/src/ImageProcessor/Common/Exceptions/ImageFormatException.cs b/src/ImageProcessor/Common/Exceptions/ImageFormatException.cs index 992bd9737..1d4169a88 100644 --- a/src/ImageProcessor/Common/Exceptions/ImageFormatException.cs +++ b/src/ImageProcessor/Common/Exceptions/ImageFormatException.cs @@ -15,6 +15,7 @@ namespace ImageProcessor.Common.Exceptions /// /// The exception that is thrown when loading the supported image format types has failed. /// + [Serializable] public sealed class ImageFormatException : Exception { /// diff --git a/src/ImageProcessor/Common/Exceptions/ImageProcessingException.cs b/src/ImageProcessor/Common/Exceptions/ImageProcessingException.cs index 44579604a..02b6be4f2 100644 --- a/src/ImageProcessor/Common/Exceptions/ImageProcessingException.cs +++ b/src/ImageProcessor/Common/Exceptions/ImageProcessingException.cs @@ -15,6 +15,7 @@ namespace ImageProcessor.Common.Exceptions /// /// The exception that is thrown when processing an image has failed. /// + [Serializable] public sealed class ImageProcessingException : Exception { /// diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index cab9513c1..68702ed09 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -76,6 +76,7 @@ + diff --git a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs index 0111ee1d6..ae5fd05c3 100644 --- a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs @@ -81,16 +81,7 @@ namespace ImageProcessor.Imaging.Formats { foreach (KeyValuePair propertItem in factory.ExifPropertyItems) { - try - { - factory.Image.SetPropertyItem(propertItem.Value); - } - // ReSharper disable once EmptyGeneralCatchClause - catch - { - // Do nothing. The image format does not handle EXIF data. - // TODO: empty catch is fierce code smell. - } + factory.Image.SetPropertyItem(propertItem.Value); } } } diff --git a/src/ImageProcessor/Imaging/Formats/NativeMethods.cs b/src/ImageProcessor/Imaging/Formats/NativeMethods.cs new file mode 100644 index 000000000..eb9062e91 --- /dev/null +++ b/src/ImageProcessor/Imaging/Formats/NativeMethods.cs @@ -0,0 +1,107 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Provides access to unmanaged native methods. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Imaging.Formats +{ + using System; + using System.Runtime.InteropServices; + + /// + /// Provides access to unmanaged native methods. + /// + internal static class NativeMethods + { + #region WebP + /// + /// Validate the WebP image header and retrieve the image height and width. Pointers *width and *height can be passed NULL if deemed irrelevant + /// + /// + /// Pointer to WebP image data + /// + /// + /// This is the size of the memory block pointed to by data containing the image data + /// + /// + /// The width range is limited currently from 1 to 16383 + /// + /// + /// The height range is limited currently from 1 to 16383 + /// + /// + /// 1 if success, otherwise error code returned in the case of (a) formatting error(s). + /// + [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int WebPGetInfo(IntPtr data, uint dataSize, out int width, out int height); + + /// + /// Decode WEBP image pointed to by *data and returns BGR samples into a pre-allocated buffer + /// + /// + /// Pointer to WebP image data + /// + /// + /// This is the size of the memory block pointed to by data containing the image data + /// + /// + /// Pointer to decoded WebP image + /// + /// + /// Size of allocated buffer + /// + /// + /// Specifies the distance between scan-lines + /// + /// + /// output_buffer if function succeeds; NULL otherwise + /// + [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern IntPtr WebPDecodeBGRAInto(IntPtr data, uint dataSize, IntPtr outputBuffer, int outputBufferSize, int outputStride); + + /// + /// Lossy encoding images pointed to by *data in WebP format + /// + /// + /// Pointer to RGB image data + /// + /// + /// The width range is limited currently from 1 to 16383 + /// + /// + /// The height range is limited currently from 1 to 16383 + /// + /// + /// The stride. + /// + /// + /// Ranges from 0 (lower quality) to 100 (highest quality). Controls the loss and quality during compression + /// + /// + /// output_buffer with WebP image + /// + /// + /// Size of WebP Image + /// + [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int WebPEncodeBGRA(IntPtr rgb, int width, int height, int stride, float qualityFactor, out IntPtr output); + + /// + /// Frees the unmanaged memory. + /// + /// + /// The pointer. + /// + /// + /// 1 if success, otherwise error code returned in the case of (a) error(s). + /// + [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int WebPFree(IntPtr pointer); + #endregion + } +} diff --git a/src/ImageProcessor/Imaging/Formats/TiffFormat.cs b/src/ImageProcessor/Imaging/Formats/TiffFormat.cs index b708abd7d..e761bc4b3 100644 --- a/src/ImageProcessor/Imaging/Formats/TiffFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/TiffFormat.cs @@ -83,16 +83,7 @@ namespace ImageProcessor.Imaging.Formats { foreach (KeyValuePair propertItem in factory.ExifPropertyItems) { - try - { - factory.Image.SetPropertyItem(propertItem.Value); - } - // ReSharper disable once EmptyGeneralCatchClause - catch - { - // Do nothing. The image format does not handle EXIF data. - // TODO: empty catch is fierce code smell. - } + factory.Image.SetPropertyItem(propertItem.Value); } } } diff --git a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs index d0bff7a19..d8c9bbf33 100644 --- a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs @@ -90,16 +90,7 @@ namespace ImageProcessor.Imaging.Formats { foreach (KeyValuePair propertItem in factory.ExifPropertyItems) { - try - { - factory.Image.SetPropertyItem(propertItem.Value); - } - // ReSharper disable once EmptyGeneralCatchClause - catch - { - // Do nothing. The image format does not handle EXIF data. - // TODO: empty catch is fierce code smell. - } + factory.Image.SetPropertyItem(propertItem.Value); } } } @@ -193,7 +184,7 @@ namespace ImageProcessor.Imaging.Formats int width; int height; - if (WebPGetInfo(ptrData, dataSize, out width, out height) != 1) + if (NativeMethods.WebPGetInfo(ptrData, dataSize, out width, out height) != 1) { throw new ImageFormatException("WebP image header is corrupted."); } @@ -209,7 +200,7 @@ namespace ImageProcessor.Imaging.Formats outputBuffer = Marshal.AllocHGlobal(outputBufferSize); // Uncompress the image - outputBuffer = WebPDecodeBGRAInto(ptrData, dataSize, outputBuffer, outputBufferSize, bitmapData.Stride); + outputBuffer = NativeMethods.WebPDecodeBGRAInto(ptrData, dataSize, outputBuffer, outputBufferSize, bitmapData.Stride); if (bitmapData.Scan0 != outputBuffer) { @@ -262,7 +253,7 @@ namespace ImageProcessor.Imaging.Formats try { // Attempt to lossy encode the image. - int size = WebPEncodeBGRA(bmpData.Scan0, bitmap.Width, bitmap.Height, bmpData.Stride, quality, out unmanagedData); + int size = NativeMethods.WebPEncodeBGRA(bmpData.Scan0, bitmap.Width, bitmap.Height, bmpData.Stride, quality, out unmanagedData); // Copy image compress data to output array webpData = new byte[size]; @@ -279,94 +270,10 @@ namespace ImageProcessor.Imaging.Formats bitmap.UnlockBits(bmpData); // Free memory - WebPFree(unmanagedData); + NativeMethods.WebPFree(unmanagedData); } return encoded; } - - /// - /// Validate the WebP image header and retrieve the image height and width. Pointers *width and *height can be passed NULL if deemed irrelevant - /// - /// - /// Pointer to WebP image data - /// - /// - /// This is the size of the memory block pointed to by data containing the image data - /// - /// - /// The width range is limited currently from 1 to 16383 - /// - /// - /// The height range is limited currently from 1 to 16383 - /// - /// - /// 1 if success, otherwise error code returned in the case of (a) formatting error(s). - /// - [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] - private static extern int WebPGetInfo(IntPtr data, uint dataSize, out int width, out int height); - - /// - /// Decode WEBP image pointed to by *data and returns BGR samples into a pre-allocated buffer - /// - /// - /// Pointer to WebP image data - /// - /// - /// This is the size of the memory block pointed to by data containing the image data - /// - /// - /// Pointer to decoded WebP image - /// - /// - /// Size of allocated buffer - /// - /// - /// Specifies the distance between scan-lines - /// - /// - /// output_buffer if function succeeds; NULL otherwise - /// - [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr WebPDecodeBGRAInto(IntPtr data, uint dataSize, IntPtr outputBuffer, int outputBufferSize, int outputStride); - - /// - /// Lossy encoding images pointed to by *data in WebP format - /// - /// - /// Pointer to RGB image data - /// - /// - /// The width range is limited currently from 1 to 16383 - /// - /// - /// The height range is limited currently from 1 to 16383 - /// - /// - /// The stride. - /// - /// - /// Ranges from 0 (lower quality) to 100 (highest quality). Controls the loss and quality during compression - /// - /// - /// output_buffer with WebP image - /// - /// - /// Size of WebP Image - /// - [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] - private static extern int WebPEncodeBGRA(IntPtr rgb, int width, int height, int stride, float qualityFactor, out IntPtr output); - - /// - /// Frees the unmanaged memory. - /// - /// - /// The pointer. - /// - /// - /// 1 if success, otherwise error code returned in the case of (a) error(s). - /// - [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] - private static extern int WebPFree(IntPtr pointer); } } \ No newline at end of file diff --git a/src/ImageProcessor/Settings.StyleCop b/src/ImageProcessor/Settings.StyleCop index d643471e4..a8aa884a1 100644 --- a/src/ImageProcessor/Settings.StyleCop +++ b/src/ImageProcessor/Settings.StyleCop @@ -10,6 +10,7 @@ halftoning lomograph Lomograph + lossy octree png quantizer From c507cc598e1538f191a6889f4b42f378dad0489e Mon Sep 17 00:00:00 2001 From: James South Date: Wed, 25 Jun 2014 19:02:07 +0100 Subject: [PATCH 030/155] Funky Nuget stuff Still can't copy unmanaged binaries across. Former-commit-id: 7e31a7b715087b080fb5d38c225d662dd6cb91bb --- build/NuSpecs/ImageProcessor.nuspec | 4 +- .../ImageProcessor/imageprocessor.targets | 10 ++ src/ImageProcessor/ImageProcessor.csproj | 5 +- .../Imaging/Formats/NativeMethods.cs | 100 ++++++++++++++++-- .../Imaging/Formats/WebPFormat.cs | 60 +++++++++-- src/ImageProcessor/libwebp.dll.REMOVED.git-id | 1 - .../x64/libwebp.dll.REMOVED.git-id | 1 + .../x86/libwebp.dll.REMOVED.git-id | 1 + src/ImageProcessorConsole/Program.cs | 2 +- .../images/output/120430.gif.REMOVED.git-id | 1 - .../images/output/4.sm.webp | 3 - .../images/output/Tl4Yb.gif.REMOVED.git-id | 1 - .../images/output/circle.webp | 3 - .../images/output/nLpfllv.gif.REMOVED.git-id | 1 - .../images/output/rotate.webp | 4 +- .../images/output/test.webp | 3 - 16 files changed, 166 insertions(+), 34 deletions(-) create mode 100644 build/content/ImageProcessor/imageprocessor.targets delete mode 100644 src/ImageProcessor/libwebp.dll.REMOVED.git-id create mode 100644 src/ImageProcessor/x64/libwebp.dll.REMOVED.git-id create mode 100644 src/ImageProcessor/x86/libwebp.dll.REMOVED.git-id delete mode 100644 src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id delete mode 100644 src/ImageProcessorConsole/images/output/4.sm.webp delete mode 100644 src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id delete mode 100644 src/ImageProcessorConsole/images/output/circle.webp delete mode 100644 src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id delete mode 100644 src/ImageProcessorConsole/images/output/test.webp diff --git a/build/NuSpecs/ImageProcessor.nuspec b/build/NuSpecs/ImageProcessor.nuspec index 85b661b2e..30e157086 100644 --- a/build/NuSpecs/ImageProcessor.nuspec +++ b/build/NuSpecs/ImageProcessor.nuspec @@ -25,6 +25,8 @@ Feedback is always welcome. - + + + \ No newline at end of file diff --git a/build/content/ImageProcessor/imageprocessor.targets b/build/content/ImageProcessor/imageprocessor.targets new file mode 100644 index 000000000..6922fa306 --- /dev/null +++ b/build/content/ImageProcessor/imageprocessor.targets @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 68702ed09..802dadb56 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -130,7 +130,10 @@ - + + PreserveNewest + + PreserveNewest diff --git a/src/ImageProcessor/Imaging/Formats/NativeMethods.cs b/src/ImageProcessor/Imaging/Formats/NativeMethods.cs index eb9062e91..059c5259a 100644 --- a/src/ImageProcessor/Imaging/Formats/NativeMethods.cs +++ b/src/ImageProcessor/Imaging/Formats/NativeMethods.cs @@ -37,8 +37,53 @@ namespace ImageProcessor.Imaging.Formats /// /// 1 if success, otherwise error code returned in the case of (a) formatting error(s). /// - [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern int WebPGetInfo(IntPtr data, uint dataSize, out int width, out int height); + [DllImport("x86\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPGetInfo")] + public static extern int WebPGetInfo86(IntPtr data, uint dataSize, out int width, out int height); + + /// + /// Validate the WebP image header and retrieve the image height and width. Pointers *width and *height can be passed NULL if deemed irrelevant + /// + /// + /// Pointer to WebP image data + /// + /// + /// This is the size of the memory block pointed to by data containing the image data + /// + /// + /// The width range is limited currently from 1 to 16383 + /// + /// + /// The height range is limited currently from 1 to 16383 + /// + /// + /// 1 if success, otherwise error code returned in the case of (a) formatting error(s). + /// + [DllImport("x64\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPGetInfo")] + public static extern int WebPGetInfo64(IntPtr data, uint dataSize, out int width, out int height); + + /// + /// Decode WEBP image pointed to by *data and returns BGR samples into a pre-allocated buffer + /// + /// + /// Pointer to WebP image data + /// + /// + /// This is the size of the memory block pointed to by data containing the image data + /// + /// + /// Pointer to decoded WebP image + /// + /// + /// Size of allocated buffer + /// + /// + /// Specifies the distance between scan-lines + /// + /// + /// output_buffer if function succeeds; NULL otherwise + /// + [DllImport("x86\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPDecodeBGRAInto")] + public static extern IntPtr WebPDecodeBGRAInto86(IntPtr data, uint dataSize, IntPtr outputBuffer, int outputBufferSize, int outputStride); /// /// Decode WEBP image pointed to by *data and returns BGR samples into a pre-allocated buffer @@ -61,8 +106,35 @@ namespace ImageProcessor.Imaging.Formats /// /// output_buffer if function succeeds; NULL otherwise /// - [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr WebPDecodeBGRAInto(IntPtr data, uint dataSize, IntPtr outputBuffer, int outputBufferSize, int outputStride); + [DllImport("x64\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPDecodeBGRAInto")] + public static extern IntPtr WebPDecodeBGRAInto64(IntPtr data, uint dataSize, IntPtr outputBuffer, int outputBufferSize, int outputStride); + + /// + /// Lossy encoding images pointed to by *data in WebP format + /// + /// + /// Pointer to RGB image data + /// + /// + /// The width range is limited currently from 1 to 16383 + /// + /// + /// The height range is limited currently from 1 to 16383 + /// + /// + /// The stride. + /// + /// + /// Ranges from 0 (lower quality) to 100 (highest quality). Controls the loss and quality during compression + /// + /// + /// output_buffer with WebP image + /// + /// + /// Size of WebP Image + /// + [DllImport("x86\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPEncodeBGRA")] + public static extern int WebPEncodeBGRA86(IntPtr rgb, int width, int height, int stride, float qualityFactor, out IntPtr output); /// /// Lossy encoding images pointed to by *data in WebP format @@ -88,8 +160,20 @@ namespace ImageProcessor.Imaging.Formats /// /// Size of WebP Image /// - [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern int WebPEncodeBGRA(IntPtr rgb, int width, int height, int stride, float qualityFactor, out IntPtr output); + [DllImport("x64\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPEncodeBGRA")] + public static extern int WebPEncodeBGRA64(IntPtr rgb, int width, int height, int stride, float qualityFactor, out IntPtr output); + + /// + /// Frees the unmanaged memory. + /// + /// + /// The pointer. + /// + /// + /// 1 if success, otherwise error code returned in the case of (a) error(s). + /// + [DllImport("x86\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPFree")] + public static extern int WebPFree86(IntPtr pointer); /// /// Frees the unmanaged memory. @@ -100,8 +184,8 @@ namespace ImageProcessor.Imaging.Formats /// /// 1 if success, otherwise error code returned in the case of (a) error(s). /// - [DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern int WebPFree(IntPtr pointer); + [DllImport("x64\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPFree")] + public static extern int WebPFree64(IntPtr pointer); #endregion } } diff --git a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs index d8c9bbf33..1617d37be 100644 --- a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs @@ -31,6 +31,12 @@ namespace ImageProcessor.Imaging.Formats [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")] public class WebPFormat : FormatBase { + /// + /// Whether the process is running in 63bit mode. Used for calling the correct dllimport method. + /// Clunky I know but I couldn't get dynamic methods to work. + /// + private static readonly bool Is64Bit = Environment.Is64BitProcess; + /// /// Gets the file headers. /// @@ -184,9 +190,19 @@ namespace ImageProcessor.Imaging.Formats int width; int height; - if (NativeMethods.WebPGetInfo(ptrData, dataSize, out width, out height) != 1) + if (Is64Bit) + { + if (NativeMethods.WebPGetInfo64(ptrData, dataSize, out width, out height) != 1) + { + throw new ImageFormatException("WebP image header is corrupted."); + } + } + else { - throw new ImageFormatException("WebP image header is corrupted."); + if (NativeMethods.WebPGetInfo86(ptrData, dataSize, out width, out height) != 1) + { + throw new ImageFormatException("WebP image header is corrupted."); + } } try @@ -199,8 +215,17 @@ namespace ImageProcessor.Imaging.Formats int outputBufferSize = bitmapData.Stride * height; outputBuffer = Marshal.AllocHGlobal(outputBufferSize); - // Uncompress the image - outputBuffer = NativeMethods.WebPDecodeBGRAInto(ptrData, dataSize, outputBuffer, outputBufferSize, bitmapData.Stride); + // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression + if (Is64Bit) + { + // Uncompress the image + outputBuffer = NativeMethods.WebPDecodeBGRAInto64(ptrData, dataSize, outputBuffer, outputBufferSize, bitmapData.Stride); + } + else + { + // Uncompress the image + outputBuffer = NativeMethods.WebPDecodeBGRAInto86(ptrData, dataSize, outputBuffer, outputBufferSize, bitmapData.Stride); + } if (bitmapData.Scan0 != outputBuffer) { @@ -252,8 +277,19 @@ namespace ImageProcessor.Imaging.Formats try { - // Attempt to lossy encode the image. - int size = NativeMethods.WebPEncodeBGRA(bmpData.Scan0, bitmap.Width, bitmap.Height, bmpData.Stride, quality, out unmanagedData); + int size; + + // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression + if (Is64Bit) + { + // Attempt to lossy encode the image. + size = NativeMethods.WebPEncodeBGRA64(bmpData.Scan0, bitmap.Width, bitmap.Height, bmpData.Stride, quality, out unmanagedData); + } + else + { + // Attempt to lossy encode the image. + size = NativeMethods.WebPEncodeBGRA86(bmpData.Scan0, bitmap.Width, bitmap.Height, bmpData.Stride, quality, out unmanagedData); + } // Copy image compress data to output array webpData = new byte[size]; @@ -269,8 +305,16 @@ namespace ImageProcessor.Imaging.Formats // Unlock the pixels bitmap.UnlockBits(bmpData); - // Free memory - NativeMethods.WebPFree(unmanagedData); + if (Is64Bit) + { + // Free memory + NativeMethods.WebPFree64(unmanagedData); + } + else + { + // Free memory + NativeMethods.WebPFree86(unmanagedData); + } } return encoded; diff --git a/src/ImageProcessor/libwebp.dll.REMOVED.git-id b/src/ImageProcessor/libwebp.dll.REMOVED.git-id deleted file mode 100644 index e05b4f051..000000000 --- a/src/ImageProcessor/libwebp.dll.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -ed0333da619a813e8337d77ba7ee206ea5f20a51 \ No newline at end of file diff --git a/src/ImageProcessor/x64/libwebp.dll.REMOVED.git-id b/src/ImageProcessor/x64/libwebp.dll.REMOVED.git-id new file mode 100644 index 000000000..35684c541 --- /dev/null +++ b/src/ImageProcessor/x64/libwebp.dll.REMOVED.git-id @@ -0,0 +1 @@ +dcadab1b5b86469758707bff22558b33e5c51552 \ No newline at end of file diff --git a/src/ImageProcessor/x86/libwebp.dll.REMOVED.git-id b/src/ImageProcessor/x86/libwebp.dll.REMOVED.git-id new file mode 100644 index 000000000..129db9826 --- /dev/null +++ b/src/ImageProcessor/x86/libwebp.dll.REMOVED.git-id @@ -0,0 +1 @@ +ad47008dd1e64ea220bc745e28f568277434d661 \ No newline at end of file diff --git a/src/ImageProcessorConsole/Program.cs b/src/ImageProcessorConsole/Program.cs index 20e92e803..64053c5ed 100644 --- a/src/ImageProcessorConsole/Program.cs +++ b/src/ImageProcessorConsole/Program.cs @@ -52,7 +52,7 @@ namespace ImageProcessorConsole // ImageProcessor using (MemoryStream inStream = new MemoryStream(photoBytes)) { - using (ImageFactory imageFactory = new ImageFactory(true)) + using (ImageFactory imageFactory = new ImageFactory()) { Size size = new Size(200, 200); diff --git a/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id deleted file mode 100644 index 71ce555c1..000000000 --- a/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -30ec5c05548fd350f9b7c699715848b9fbfb8ca9 \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/4.sm.webp b/src/ImageProcessorConsole/images/output/4.sm.webp deleted file mode 100644 index 1cce96a6c..000000000 --- a/src/ImageProcessorConsole/images/output/4.sm.webp +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bc9ccd29734ed06d2916389cc363955924f4bbb200fea91c113ae2b9334eca1f -size 12162 diff --git a/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id deleted file mode 100644 index 6515d65a0..000000000 --- a/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -fdc62fc2d056ab885eb9e8fd12b9155ee86d7c43 \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/circle.webp b/src/ImageProcessorConsole/images/output/circle.webp deleted file mode 100644 index 0a022dff6..000000000 --- a/src/ImageProcessorConsole/images/output/circle.webp +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ac5bfc52fe066984db96d0b169a7fb7ebd76f3a1cf946ba02a167475377903c2 -size 1228 diff --git a/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id deleted file mode 100644 index 4487aede0..000000000 --- a/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -23a1c81a2d1422076373796e0c47f5d968c56d0b \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/rotate.webp b/src/ImageProcessorConsole/images/output/rotate.webp index fa870fffe..8bc9002cd 100644 --- a/src/ImageProcessorConsole/images/output/rotate.webp +++ b/src/ImageProcessorConsole/images/output/rotate.webp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3543de5854cc0a8a95b5249548abc8150040542a127ac6d89eb6338b8dfa3a83 -size 1812 +oid sha256:37d346c1cc3fe9635397d508ee332740f1043f942d940871e4cfc3b616cf5279 +size 1792 diff --git a/src/ImageProcessorConsole/images/output/test.webp b/src/ImageProcessorConsole/images/output/test.webp deleted file mode 100644 index 4534523db..000000000 --- a/src/ImageProcessorConsole/images/output/test.webp +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b41b4fe144f9d3eaee706b516021efc7abc598f17655d9592866963bfa62f3ad -size 5590 From c3a2d51171cc52f59a3204f3d1fea2afa82f7bbd Mon Sep 17 00:00:00 2001 From: James South Date: Wed, 25 Jun 2014 19:15:05 +0100 Subject: [PATCH 031/155] A poor man's attempt at powershell Former-commit-id: 16299f097898120fc12e1998872db7316fa8007d --- build/NuSpecs/ImageProcessor.nuspec | 11 ++++++++--- build/tools/imageprocessor.ps1 | 12 ++++++++++++ build/tools/install.ps1 | 11 +++++++++++ build/tools/uninstall.ps1 | 9 +++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 build/tools/imageprocessor.ps1 create mode 100644 build/tools/install.ps1 create mode 100644 build/tools/uninstall.ps1 diff --git a/build/NuSpecs/ImageProcessor.nuspec b/build/NuSpecs/ImageProcessor.nuspec index 30e157086..f0d5f134e 100644 --- a/build/NuSpecs/ImageProcessor.nuspec +++ b/build/NuSpecs/ImageProcessor.nuspec @@ -22,11 +22,16 @@ Feedback is always welcome. James South en-GB Image Imaging ASP Performance Processing Resize AutoRotate Rotate RoundedCorners Flip Crop Filter Effects Quality Watermark Alpha Vignette Saturation Brightness Contrast Gif Jpg Jpeg Bitmap Png Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF + + + - - - + + + + + \ No newline at end of file diff --git a/build/tools/imageprocessor.ps1 b/build/tools/imageprocessor.ps1 new file mode 100644 index 000000000..7b8be180f --- /dev/null +++ b/build/tools/imageprocessor.ps1 @@ -0,0 +1,12 @@ +$solutionDir = [System.IO.Path]::GetDirectoryName($dte.Solution.FullName) + "\" +$path = $installPath.Replace($solutionDir, "`$(SolutionDir)") + +$NativeAssembliesDir = Join-Path $path "lib" +$x86 = $(Join-Path $NativeAssembliesDir "x86\*.*") +$x64 = $(Join-Path $NativeAssembliesDir "x64\*.*") + +$ImageProcessorPostBuildCmd = " +if not exist `"`$(TargetDir)x86`" md `"`$(TargetDir)x86`" +xcopy /s /y `"$x86`" `"`$(TargetDir)x86`" +if not exist `"`$(TargetDir)amd64`" md `"`$(TargetDir)x64`" +xcopy /s /y `"$x64`" `"`$(TargetDir)x64`"" \ No newline at end of file diff --git a/build/tools/install.ps1 b/build/tools/install.ps1 new file mode 100644 index 000000000..567ea0276 --- /dev/null +++ b/build/tools/install.ps1 @@ -0,0 +1,11 @@ +param($installPath, $toolsPath, $package, $project) + +. (Join-Path $toolsPath "imageprocessor.ps1") + +# Get the current Post Build Event cmd +$currentPostBuildCmd = $project.Properties.Item("PostBuildEvent").Value + +# Append our post build command if it's not already there +if (!$currentPostBuildCmd.Contains($ImageProcessorPostBuildCmd)) { + $project.Properties.Item("PostBuildEvent").Value += $ImageProcessorPostBuildCmd +} \ No newline at end of file diff --git a/build/tools/uninstall.ps1 b/build/tools/uninstall.ps1 new file mode 100644 index 000000000..4fa6c12ca --- /dev/null +++ b/build/tools/uninstall.ps1 @@ -0,0 +1,9 @@ +param($installPath, $toolsPath, $package, $project) + +. (Join-Path $toolsPath "imageprocessor.ps1") + +# Get the current Post Build Event cmd +$currentPostBuildCmd = $project.Properties.Item("PostBuildEvent").Value + +# Remove our post build command from it (if it's there) +$project.Properties.Item("PostBuildEvent").Value = $currentPostBuildCmd.Replace($ImageProcessorPostBuildCmd, "") From bcf8f560b94333901c39130864e1ac53955572cf Mon Sep 17 00:00:00 2001 From: James South Date: Wed, 25 Jun 2014 22:10:03 +0100 Subject: [PATCH 032/155] Yay! Nuget win! Former-commit-id: 985bf753a90ce3f31fe7b29781d6279be869044f --- build/NuSpecs/ImageProcessor.nuspec | 11 +++------ .../ImageProcessor/imageprocessor.targets | 23 ++++++++++++++----- build/tools/imageprocessor.ps1 | 12 ---------- build/tools/install.ps1 | 11 --------- build/tools/uninstall.ps1 | 9 -------- 5 files changed, 20 insertions(+), 46 deletions(-) delete mode 100644 build/tools/imageprocessor.ps1 delete mode 100644 build/tools/install.ps1 delete mode 100644 build/tools/uninstall.ps1 diff --git a/build/NuSpecs/ImageProcessor.nuspec b/build/NuSpecs/ImageProcessor.nuspec index f0d5f134e..8041f5dfc 100644 --- a/build/NuSpecs/ImageProcessor.nuspec +++ b/build/NuSpecs/ImageProcessor.nuspec @@ -22,16 +22,11 @@ Feedback is always welcome. James South en-GB Image Imaging ASP Performance Processing Resize AutoRotate Rotate RoundedCorners Flip Crop Filter Effects Quality Watermark Alpha Vignette Saturation Brightness Contrast Gif Jpg Jpeg Bitmap Png Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF - - - - - - - - + + + \ No newline at end of file diff --git a/build/content/ImageProcessor/imageprocessor.targets b/build/content/ImageProcessor/imageprocessor.targets index 6922fa306..0b161e3c5 100644 --- a/build/content/ImageProcessor/imageprocessor.targets +++ b/build/content/ImageProcessor/imageprocessor.targets @@ -1,10 +1,21 @@ - - - - - - + + + + + + + + + $(PrepareForRunDependsOn); + CopyNativeBinaries + + + + + + \ No newline at end of file diff --git a/build/tools/imageprocessor.ps1 b/build/tools/imageprocessor.ps1 deleted file mode 100644 index 7b8be180f..000000000 --- a/build/tools/imageprocessor.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -$solutionDir = [System.IO.Path]::GetDirectoryName($dte.Solution.FullName) + "\" -$path = $installPath.Replace($solutionDir, "`$(SolutionDir)") - -$NativeAssembliesDir = Join-Path $path "lib" -$x86 = $(Join-Path $NativeAssembliesDir "x86\*.*") -$x64 = $(Join-Path $NativeAssembliesDir "x64\*.*") - -$ImageProcessorPostBuildCmd = " -if not exist `"`$(TargetDir)x86`" md `"`$(TargetDir)x86`" -xcopy /s /y `"$x86`" `"`$(TargetDir)x86`" -if not exist `"`$(TargetDir)amd64`" md `"`$(TargetDir)x64`" -xcopy /s /y `"$x64`" `"`$(TargetDir)x64`"" \ No newline at end of file diff --git a/build/tools/install.ps1 b/build/tools/install.ps1 deleted file mode 100644 index 567ea0276..000000000 --- a/build/tools/install.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -param($installPath, $toolsPath, $package, $project) - -. (Join-Path $toolsPath "imageprocessor.ps1") - -# Get the current Post Build Event cmd -$currentPostBuildCmd = $project.Properties.Item("PostBuildEvent").Value - -# Append our post build command if it's not already there -if (!$currentPostBuildCmd.Contains($ImageProcessorPostBuildCmd)) { - $project.Properties.Item("PostBuildEvent").Value += $ImageProcessorPostBuildCmd -} \ No newline at end of file diff --git a/build/tools/uninstall.ps1 b/build/tools/uninstall.ps1 deleted file mode 100644 index 4fa6c12ca..000000000 --- a/build/tools/uninstall.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -param($installPath, $toolsPath, $package, $project) - -. (Join-Path $toolsPath "imageprocessor.ps1") - -# Get the current Post Build Event cmd -$currentPostBuildCmd = $project.Properties.Item("PostBuildEvent").Value - -# Remove our post build command from it (if it's there) -$project.Properties.Item("PostBuildEvent").Value = $currentPostBuildCmd.Replace($ImageProcessorPostBuildCmd, "") From 10e62d5a9d62e40bc34f39d0829103695959aeb8 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Wed, 25 Jun 2014 23:59:37 +0200 Subject: [PATCH 033/155] Creates a new Mono project so it can at least build (not yet run) on Xamarin/Mono Former-commit-id: 96e8b233cd5d9f20c13b1691cfe2ff187c51267d --- .../HttpModules/ImageProcessingModule.cs | 4 +- .../ImageProcessorConsole.csproj | 6 +- src/ImageProcessor_Mono.sln | 132 ++++++++++++++++++ 3 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 src/ImageProcessor_Mono.sln diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index 22c03bef7..154038d54 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -125,7 +125,7 @@ namespace ImageProcessor.Web.HttpModules preserveExifMetaData = ImageProcessorConfig.Instance.PreserveExifMetaData; } -#if NET45 +#if NET45 && !__MonoCS__ EventHandlerTaskAsyncHelper wrapper = new EventHandlerTaskAsyncHelper(this.PostAuthorizeRequest); context.AddOnPostAuthorizeRequestAsync(wrapper.BeginEventHandler, wrapper.EndEventHandler); #else @@ -194,7 +194,7 @@ namespace ImageProcessor.Web.HttpModules } #endregion -#if NET45 +#if NET45 && !__MonoCS__ /// /// Occurs when the user for the current request has been authorized. diff --git a/src/ImageProcessorConsole/ImageProcessorConsole.csproj b/src/ImageProcessorConsole/ImageProcessorConsole.csproj index 39b66751b..9cf9bf603 100644 --- a/src/ImageProcessorConsole/ImageProcessorConsole.csproj +++ b/src/ImageProcessorConsole/ImageProcessorConsole.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,7 +9,7 @@ Properties ImageProcessorConsole ImageProcessorConsole - v4.5.1 + v4.5 512 true @@ -51,7 +51,7 @@ - {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} ImageProcessor diff --git a/src/ImageProcessor_Mono.sln b/src/ImageProcessor_Mono.sln new file mode 100644 index 000000000..d7e1410a8 --- /dev/null +++ b/src/ImageProcessor_Mono.sln @@ -0,0 +1,132 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.30110.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C427A497-74DC-49B1-8420-D6E68354F29B}" + ProjectSection(SolutionItems) = preProject + ImageProcessor.vsmdi = ImageProcessor.vsmdi + Local.testsettings = Local.testsettings + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E656CDE-124D-4FAF-837C-0EF1E192D418}" + ProjectSection(SolutionItems) = preProject + .nuget\NuGet.Config = .nuget\NuGet.Config + .nuget\NuGet.exe = .nuget\NuGet.exe + .nuget\NuGet.targets = .nuget\NuGet.targets + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor", "ImageProcessor\ImageProcessor.csproj", "{3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_MVC_NET4", "TestWebsites\NET4\Test_Website_MVC_NET4.csproj", "{30327C08-7574-4D7E-AC95-6A58753C6855}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET4", "ImageProcessor.Web\NET4\ImageProcessor.Web_NET4.csproj", "{4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET45", "ImageProcessor.Web\NET45\ImageProcessor.Web_NET45.csproj", "{D011A778-59C8-4BFA-A770-C350216BF161}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessorConsole", "ImageProcessorConsole\ImageProcessorConsole.csproj", "{7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + All|Any CPU = All|Any CPU + All|Mixed Platforms = All|Mixed Platforms + All|x86 = All|x86 + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.ActiveCfg = All|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.Build.0 = All|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.ActiveCfg = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.Build.0 = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.ActiveCfg = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.Build.0 = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.ActiveCfg = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.Build.0 = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.Build.0 = Release|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.Build.0 = Release|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.ActiveCfg = Release|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.Build.0 = Release|x86 + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.Build.0 = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|x86.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|x86.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.Build.0 = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|x86.ActiveCfg = Release|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Any CPU.ActiveCfg = All|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Any CPU.Build.0 = All|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Mixed Platforms.ActiveCfg = All|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Mixed Platforms.Build.0 = All|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|x86.ActiveCfg = All|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Any CPU.Build.0 = Release|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|x86.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|x86.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|x86.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|x86.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.All|Any CPU.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.All|Any CPU.Build.0 = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.All|Mixed Platforms.Build.0 = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.All|x86.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Debug|x86.ActiveCfg = Debug|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Any CPU.Build.0 = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Release|x86.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = ImageProcessor\ImageProcessor.csproj + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(TestCaseManagementSettings) = postSolution + CategoryFile = ImageProcessor.vsmdi + EndGlobalSection +EndGlobal From b6db3874b7ca3c43ee1d0bc838574bfa687ff0b4 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Wed, 25 Jun 2014 23:59:58 +0200 Subject: [PATCH 034/155] Ignores Xamarin files Former-commit-id: fe9740cac43f2c1a4bf827cde89239dd6dde00fc --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 6b6928926..2fc43e4a1 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,9 @@ local.properties .builds **/*.dotCover +# Xamarin +*.userprefs + ## TODO: If you have NuGet Package Restore enabled, uncomment this packages/ From 1492b18d918608177b27db9fe837a79053cd4dc4 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Thu, 26 Jun 2014 00:08:55 +0200 Subject: [PATCH 035/155] Removes MVC test project from Mono solution because of heavy dependencies Former-commit-id: 3e6881f9bdaa8a0f53ab4f580565f9092b27f739 --- src/ImageProcessor_Mono.sln | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/ImageProcessor_Mono.sln b/src/ImageProcessor_Mono.sln index d7e1410a8..7d47a2ca6 100644 --- a/src/ImageProcessor_Mono.sln +++ b/src/ImageProcessor_Mono.sln @@ -18,8 +18,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E656C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor", "ImageProcessor\ImageProcessor.csproj", "{3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_MVC_NET4", "TestWebsites\NET4\Test_Website_MVC_NET4.csproj", "{30327C08-7574-4D7E-AC95-6A58753C6855}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET4", "ImageProcessor.Web\NET4\ImageProcessor.Web_NET4.csproj", "{4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET45", "ImageProcessor.Web\NET45\ImageProcessor.Web_NET45.csproj", "{D011A778-59C8-4BFA-A770-C350216BF161}" @@ -39,24 +37,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.ActiveCfg = All|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.Build.0 = All|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.ActiveCfg = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.Build.0 = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.ActiveCfg = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.Build.0 = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.Build.0 = Debug|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.ActiveCfg = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.Build.0 = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.ActiveCfg = Release|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.Build.0 = Release|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.Build.0 = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.ActiveCfg = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.Build.0 = Release|x86 {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU From 1866ec65ba910f69978214d04d9ac608379fc8a0 Mon Sep 17 00:00:00 2001 From: James South Date: Wed, 25 Jun 2014 23:50:23 +0100 Subject: [PATCH 036/155] Fixing issue #59 Former-commit-id: ac374bb3f3acd7ff84cde23959bcfa134f79dbae --- src/ImageProcessor.Web/NET45/Caching/DiskCache.cs | 6 +++--- .../NET45/Configuration/ImageProcessingSection.cs | 4 ++-- .../NET45/Configuration/ImageProcessorConfiguration.cs | 4 ++-- src/ImageProcessor.Web/NET45/Helpers/RemoteFile.cs | 2 +- src/ImageProcessor.Web/NET45/Processors/Crop.cs | 2 +- src/ImageProcessor.Web/NET45/Processors/Saturation.cs | 2 +- src/ImageProcessor/Imaging/ExifPropertyTag.cs | 2 +- src/ImageProcessor/Imaging/ExifPropertyTagType.cs | 4 ++-- src/ImageProcessor/Imaging/Formats/FormatUtilities.cs | 2 +- src/ImageProcessor/Imaging/Formats/GifEncoder.cs | 4 ++-- src/ImageProcessor/Imaging/Formats/GifInfo.cs | 4 ++-- src/ImageProcessor/Imaging/Formats/WebPFormat.cs | 4 ++-- src/ImageProcessor/Processors/Rotate.cs | 2 +- src/ImageProcessor/Processors/Saturation.cs | 2 +- 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs index 23612916b..f1cefc657 100644 --- a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs +++ b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs @@ -42,9 +42,9 @@ namespace ImageProcessor.Web.Caching /// /// NTFS directories can handle up to 10,000 files in the directory before slowing down. /// This will help us to ensure that don't go over that limit. - /// - /// - /// + /// + /// + /// /// private const int MaxFilesCount = 100; diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs index 3942280f6..3332080b9 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs @@ -5,7 +5,7 @@ // // // Represents an image processing section within a configuration file. -// Nested syntax adapted from +// Nested syntax adapted from // // -------------------------------------------------------------------------------------------------------------------- @@ -21,7 +21,7 @@ namespace ImageProcessor.Web.Configuration /// /// Represents an image processing section within a configuration file. - /// Nested syntax adapted from + /// Nested syntax adapted from /// public sealed class ImageProcessingSection : ConfigurationSection { diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs index e871a5c35..be4966966 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs @@ -5,7 +5,7 @@ // // // Encapsulates methods to allow the retrieval of ImageProcessor settings. -// +// // // -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Web.Configuration @@ -24,7 +24,7 @@ namespace ImageProcessor.Web.Configuration /// /// Encapsulates methods to allow the retrieval of ImageProcessor settings. - /// + /// /// public sealed class ImageProcessorConfiguration { diff --git a/src/ImageProcessor.Web/NET45/Helpers/RemoteFile.cs b/src/ImageProcessor.Web/NET45/Helpers/RemoteFile.cs index 1fa38568c..6845d8453 100644 --- a/src/ImageProcessor.Web/NET45/Helpers/RemoteFile.cs +++ b/src/ImageProcessor.Web/NET45/Helpers/RemoteFile.cs @@ -40,7 +40,7 @@ namespace ImageProcessor.Web.Helpers /// There shouldn't be any security issues there, as the internal WebRequest instance is still calling it remotely. /// Any local files that shouldn't be accessed by this won't be allowed by the remote call. /// - /// Adapted from BlogEngine.Net + /// Adapted from BlogEngine.Net /// internal sealed class RemoteFile { diff --git a/src/ImageProcessor.Web/NET45/Processors/Crop.cs b/src/ImageProcessor.Web/NET45/Processors/Crop.cs index 372d277c3..c621ebd1a 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Crop.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Crop.cs @@ -24,7 +24,7 @@ namespace ImageProcessor.Web.Processors { /// /// The regular expression to search strings for. - /// + /// /// private static readonly Regex QueryRegex = new Regex(@"(crop=|cropmode=)[^&]+", RegexOptions.Compiled); diff --git a/src/ImageProcessor.Web/NET45/Processors/Saturation.cs b/src/ImageProcessor.Web/NET45/Processors/Saturation.cs index 3a98bde7e..02a750ab1 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Saturation.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Saturation.cs @@ -18,7 +18,7 @@ namespace ImageProcessor.Web.Processors /// Encapsulates methods to change the saturation component of the image. /// /// - /// + /// /// public class Saturation : IWebGraphicsProcessor { diff --git a/src/ImageProcessor/Imaging/ExifPropertyTag.cs b/src/ImageProcessor/Imaging/ExifPropertyTag.cs index 3af48741d..3e714d03c 100644 --- a/src/ImageProcessor/Imaging/ExifPropertyTag.cs +++ b/src/ImageProcessor/Imaging/ExifPropertyTag.cs @@ -12,7 +12,7 @@ namespace ImageProcessor.Imaging { /// /// The following enum gives descriptions of the property items supported by Windows GDI+. - /// + /// /// TODO: Add more XML descriptions. /// public enum ExifPropertyTag diff --git a/src/ImageProcessor/Imaging/ExifPropertyTagType.cs b/src/ImageProcessor/Imaging/ExifPropertyTagType.cs index 2c3a1b352..1d0d470f7 100644 --- a/src/ImageProcessor/Imaging/ExifPropertyTagType.cs +++ b/src/ImageProcessor/Imaging/ExifPropertyTagType.cs @@ -5,7 +5,7 @@ // // // Specifies the data type of the values stored in the value data member of that same PropertyItem object. -// +// // // -------------------------------------------------------------------------------------------------------------------- @@ -13,7 +13,7 @@ namespace ImageProcessor.Imaging { /// /// Specifies the data type of the values stored in the value data member of that same PropertyItem object. - /// + /// /// public enum ExifPropertyTagType : short { diff --git a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs index a382e6449..36d2e3c07 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs @@ -27,7 +27,7 @@ namespace ImageProcessor.Imaging.Formats { /// /// Gets the correct from the given stream. - /// + /// /// /// /// The to read from. diff --git a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs index d667f35f5..612a453bf 100644 --- a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs +++ b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs @@ -9,7 +9,7 @@ // Always wire this up in a using block. // Disposing the encoder will complete the file. // Uses default .NET GIF encoding and adds animation headers. -// Adapted from +// Adapted from // // // -------------------------------------------------------------------------------------------------------------------- @@ -27,7 +27,7 @@ namespace ImageProcessor.Imaging.Formats /// Always wire this up in a using block. /// Disposing the encoder will complete the file. /// Uses default .NET GIF encoding and adds animation headers. - /// Adapted from + /// Adapted from /// /// public class GifEncoder : IDisposable diff --git a/src/ImageProcessor/Imaging/Formats/GifInfo.cs b/src/ImageProcessor/Imaging/Formats/GifInfo.cs index c0b75bae3..2fdc1d715 100644 --- a/src/ImageProcessor/Imaging/Formats/GifInfo.cs +++ b/src/ImageProcessor/Imaging/Formats/GifInfo.cs @@ -5,7 +5,7 @@ // // // Provides information about an image. -// +// // // -------------------------------------------------------------------------------------------------------------------- @@ -16,7 +16,7 @@ namespace ImageProcessor.Imaging.Formats /// /// Provides information about an image. - /// + /// /// public class GifInfo { diff --git a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs index 1617d37be..25b0205e3 100644 --- a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs @@ -5,7 +5,7 @@ // // // Provides the necessary information to support webp images. -// Adapted from +// Adapted from // by Jose M. Piñeiro // // -------------------------------------------------------------------------------------------------------------------- @@ -25,7 +25,7 @@ namespace ImageProcessor.Imaging.Formats /// /// Provides the necessary information to support webp images. - /// Adapted from + /// Adapted from /// by Jose M. Piñeiro /// [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1650:ElementDocumentationMustBeSpelledCorrectly", Justification = "Reviewed. Suppression is OK here.")] diff --git a/src/ImageProcessor/Processors/Rotate.cs b/src/ImageProcessor/Processors/Rotate.cs index 70fabd1cc..2e5931dcc 100644 --- a/src/ImageProcessor/Processors/Rotate.cs +++ b/src/ImageProcessor/Processors/Rotate.cs @@ -100,7 +100,7 @@ namespace ImageProcessor.Processors /// The angle in degrees at which to rotate the image. /// The image rotated to the given angle at the given position. /// - /// Based on + /// Based on /// private Bitmap RotateImage(Image image, float rotateAtX, float rotateAtY, float angle) { diff --git a/src/ImageProcessor/Processors/Saturation.cs b/src/ImageProcessor/Processors/Saturation.cs index b8d2a0819..341d287f3 100644 --- a/src/ImageProcessor/Processors/Saturation.cs +++ b/src/ImageProcessor/Processors/Saturation.cs @@ -21,7 +21,7 @@ namespace ImageProcessor.Processors /// Encapsulates methods to change the saturation component of the image. /// /// - /// + /// /// public class Saturation : IGraphicsProcessor { From 3a5f658db3967abdb4353cf7030de13eac492f4d Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 26 Jun 2014 13:57:03 +0100 Subject: [PATCH 037/155] Fixing embedded resource reference Former-commit-id: c735cd18a0a6f6b73bc98bcae1c32cd6e04cbd38 --- .../NET45/Configuration/ImageCacheSection.cs | 2 +- .../NET45/Configuration/ImageProcessingSection.cs | 2 +- .../NET45/Configuration/ImageSecuritySection.cs | 2 +- src/TestWebsites/NET45/Test_Website_NET45/Web.config | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs index 04a550729..8e5abad95 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs @@ -79,7 +79,7 @@ namespace ImageProcessor.Web.Configuration return imageCacheSection; } - string section = ResourceHelpers.ResourceAsString("ImageProcessor.Web.Config.Resources.cache.config"); + string section = ResourceHelpers.ResourceAsString("ImageProcessor.Web.Configuration.Resources.cache.config"); XmlReader reader = new XmlTextReader(new StringReader(section)); imageCacheSection = new ImageCacheSection(); imageCacheSection.DeserializeSection(reader); diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs index 3332080b9..23f8bc9ca 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs @@ -83,7 +83,7 @@ namespace ImageProcessor.Web.Configuration return imageProcessingSection; } - string section = ResourceHelpers.ResourceAsString("ImageProcessor.Web.Config.Resources.processing.config"); + string section = ResourceHelpers.ResourceAsString("ImageProcessor.Web.Configuration.Resources.processing.config"); XmlReader reader = new XmlTextReader(new StringReader(section)); imageProcessingSection = new ImageProcessingSection(); imageProcessingSection.DeserializeSection(reader); diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageSecuritySection.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageSecuritySection.cs index 29079fdc2..c58b07579 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageSecuritySection.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageSecuritySection.cs @@ -116,7 +116,7 @@ namespace ImageProcessor.Web.Configuration return imageSecuritySection; } - string section = ResourceHelpers.ResourceAsString("ImageProcessor.Web.Config.Resources.security.config"); + string section = ResourceHelpers.ResourceAsString("ImageProcessor.Web.Configuration.Resources.security.config"); XmlReader reader = new XmlTextReader(new StringReader(section)); imageSecuritySection = new ImageSecuritySection(); imageSecuritySection.DeserializeSection(reader); diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Web.config b/src/TestWebsites/NET45/Test_Website_NET45/Web.config index 7f87cedd1..1b2a7cfde 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/Web.config +++ b/src/TestWebsites/NET45/Test_Website_NET45/Web.config @@ -6,17 +6,17 @@ - + - + From be6f51fbace863b9c0fba4a08c345222e79e8918 Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 26 Jun 2014 22:30:08 +0100 Subject: [PATCH 038/155] Separating Unit Tests Hopefully rebuilding the projects will fix the AppVeyor issues. Former-commit-id: 2beec9222b2fc35ed26d6bbd6b6b12bd2a95f780 --- .../ImageProcessor.UnitTests.csproj | 282 ++++++++++-------- .../Properties/AssemblyInfo.cs | 36 +++ src/ImageProcessor.UnitTests/packages.config | 2 +- .../ImageProcessor.Web.UnitTests.csproj | 106 +++++++ .../Properties/AssemblyInfo.cs | 36 +++ .../RegularExpressionUnitTests.cs | 26 +- .../packages.config | 4 + src/ImageProcessor.sln | 182 +++++------ src/packages/repositories.config | 2 + 9 files changed, 458 insertions(+), 218 deletions(-) create mode 100644 src/ImageProcessor.UnitTests/Properties/AssemblyInfo.cs create mode 100644 src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj create mode 100644 src/ImageProcessor.Web.UnitTests/Properties/AssemblyInfo.cs rename src/{ImageProcessor.UnitTests => ImageProcessor.Web.UnitTests}/RegularExpressionUnitTests.cs (87%) create mode 100644 src/ImageProcessor.Web.UnitTests/packages.config diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index afce9a1d2..2be742cb4 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -1,178 +1,215 @@  - + Debug AnyCPU - {03CA9055-F997-428C-BF28-F50F991777C6} + {633B1C4C-4823-47BE-9A01-A665F3118C8C} Library + Properties ImageProcessor.UnitTests ImageProcessor.UnitTests - - + v4.0 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest ..\ true - v4.5 + true full false - bin\Debug - DEBUG; + bin\Debug\ + DEBUG;TRACE prompt 4 - false - false - full + pdbonly true - bin\Release + bin\Release\ + TRACE prompt 4 - false - false - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - + + + + + + + + + + - + - - - {d011a778-59c8-4bfa-a770-c350216bf161} - ImageProcessor.Web_NET45 - - - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} - ImageProcessor - + - - + + Images\1182076_e8c402e938_z.jpg + + + Images\bus.jpg + + Images\Chrysanthemum.jpg - PreserveNewest - - + + + Images\circle.png + + + Images\cmyk.jpg + + + Images\cmyk.png + + + Images\color-vision-test.gif + + Images\Desert.jpg - PreserveNewest - - + + + Images\emma.jpg + + + Images\falahill_design__160p.jpg + + + Images\fid11246.jpg + + + Images\fid9141.jpg + + + Images\header_1.jpg + + Images\Hydrangeas.jpg - PreserveNewest - - + + Images\Jellyfish.jpg - PreserveNewest - - + + + Images\jrt.jpg + + Images\Koala.jpg - PreserveNewest - - + + Images\Lighthouse.jpg - PreserveNewest - - + + + Images\lomo.jpg + + + Images\meter.gif + + + Images\negative.png + + + Images\negative2.png + + Images\Penguins-200.jpg - PreserveNewest - - + + Images\Penguins-8.png - PreserveNewest - - + + Images\Penguins.bmp - PreserveNewest - - + + Images\Penguins.gif - PreserveNewest - - + + Images\Penguins.jpg - PreserveNewest - - + + Images\Penguins.png - PreserveNewest - - + + Images\Penguins.tif - PreserveNewest - - - Images\Tulips.jpg - PreserveNewest - - - Images\bus.jpg - PreserveNewest - - - Images\cmyk.jpg - PreserveNewest - - - Images\cmyk.png - PreserveNewest - - - Images\jrt.jpg - PreserveNewest - - - Images\meter.gif - PreserveNewest - - + + Images\rocks.jpg - PreserveNewest - - + + Images\rotate.jpg - PreserveNewest - - + + Images\sample1.jpg - PreserveNewest - - + + Images\srgb.jpg - PreserveNewest - - + + Images\srgb.png - PreserveNewest - - + + Images\text.png - PreserveNewest - - + + Images\thor.jpg - PreserveNewest - - + + + Images\Tulips.jpg + + Images\udendørs-374.jpg - PreserveNewest - - + + Images\udendørs.jpg - PreserveNewest - + + + Images\war_horse_quad.jpg + + + Images\WP_000009.jpg + - + + + {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} + ImageProcessor + + + + + + + False + + + False + + + False + + + False + + + + + + @@ -180,4 +217,11 @@ + \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Properties/AssemblyInfo.cs b/src/ImageProcessor.UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..fb042a1d3 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImageProcessor.UnitTests2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ImageProcessor.UnitTests2")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3003f5a6-eb11-4eee-bfaa-448deb3a31d9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/ImageProcessor.UnitTests/packages.config b/src/ImageProcessor.UnitTests/packages.config index 5a3253fcb..a18b325a4 100644 --- a/src/ImageProcessor.UnitTests/packages.config +++ b/src/ImageProcessor.UnitTests/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj b/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj new file mode 100644 index 000000000..17c54d202 --- /dev/null +++ b/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj @@ -0,0 +1,106 @@ + + + + Debug + AnyCPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260} + Library + Properties + ImageProcessor.Web.UnitTests + ImageProcessor.Web.UnitTests + v4.5.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + ..\ + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + ..\packages\NUnit.2.6.3\lib\nunit.framework.dll + + + + + + + + + + + + + + + + + + + + + + {d011a778-59c8-4bfa-a770-c350216bf161} + ImageProcessor.Web_NET45 + + + {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} + ImageProcessor + + + + + + + False + + + False + + + False + + + False + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/src/ImageProcessor.Web.UnitTests/Properties/AssemblyInfo.cs b/src/ImageProcessor.Web.UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..db6aa3c94 --- /dev/null +++ b/src/ImageProcessor.Web.UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImageProcessor.Web.UnitTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ImageProcessor.Web.UnitTests")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("74919969-6a75-4d26-b1b8-0626aa10af6d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/ImageProcessor.UnitTests/RegularExpressionUnitTests.cs b/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs similarity index 87% rename from src/ImageProcessor.UnitTests/RegularExpressionUnitTests.cs rename to src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs index 417e94f8c..c41454563 100644 --- a/src/ImageProcessor.UnitTests/RegularExpressionUnitTests.cs +++ b/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs @@ -8,7 +8,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.UnitTests +namespace ImageProcessor.Web.UnitTests { using System.Drawing; using ImageProcessor.Imaging; @@ -31,7 +31,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "alpha=56"; const int Expected = 56; - Web.Processors.Alpha alpha = new Web.Processors.Alpha(); + Processors.Alpha alpha = new Processors.Alpha(); alpha.MatchRegexIndex(Querystring); int actual = alpha.Processor.DynamicParameter; @@ -48,7 +48,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "brightness=56"; const int Expected = 56; - Web.Processors.Brightness brightness = new Web.Processors.Brightness(); + Processors.Brightness brightness = new Processors.Brightness(); brightness.MatchRegexIndex(Querystring); int actual = brightness.Processor.DynamicParameter; @@ -65,7 +65,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "contrast=56"; const int Expected = 56; - Web.Processors.Contrast contrast = new Web.Processors.Contrast(); + Processors.Contrast contrast = new Processors.Contrast(); contrast.MatchRegexIndex(Querystring); int actual = contrast.Processor.DynamicParameter; @@ -82,7 +82,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "crop=0,0,150,300"; CropLayer expected = new CropLayer(0, 0, 150, 300, CropMode.Pixels); - Web.Processors.Crop crop = new Web.Processors.Crop(); + Processors.Crop crop = new Processors.Crop(); crop.MatchRegexIndex(Querystring); CropLayer actual = crop.Processor.DynamicParameter; @@ -99,7 +99,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "filter=lomograph"; IMatrixFilter expected = MatrixFilters.Lomograph; - Web.Processors.Filter filter = new Web.Processors.Filter(); + Processors.Filter filter = new Processors.Filter(); filter.MatchRegexIndex(Querystring); IMatrixFilter actual = filter.Processor.DynamicParameter; @@ -116,7 +116,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "format=gif"; ISupportedImageFormat expected = new GifFormat(); - Web.Processors.Format format = new Web.Processors.Format(); + Processors.Format format = new Processors.Format(); format.MatchRegexIndex(Querystring); ISupportedImageFormat actual = format.Processor.DynamicParameter; @@ -133,7 +133,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "quality=56"; const int Expected = 56; - Web.Processors.Quality quality = new Web.Processors.Quality(); + Processors.Quality quality = new Processors.Quality(); quality.MatchRegexIndex(Querystring); int actual = quality.Processor.DynamicParameter; @@ -150,7 +150,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "width=300"; ResizeLayer expected = new ResizeLayer(new Size(300, 0)); - Web.Processors.Resize resize = new Web.Processors.Resize(); + Processors.Resize resize = new Processors.Resize(); resize.MatchRegexIndex(Querystring); ResizeLayer actual = resize.Processor.DynamicParameter; @@ -167,7 +167,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "rotate=270"; const int Expected = 270; - Web.Processors.Rotate rotate = new Web.Processors.Rotate(); + Processors.Rotate rotate = new Processors.Rotate(); rotate.MatchRegexIndex(Querystring); int actual = rotate.Processor.DynamicParameter; @@ -183,7 +183,7 @@ namespace ImageProcessor.UnitTests { const string Querystring = "roundedcorners=30"; RoundedCornerLayer expected = new RoundedCornerLayer(30, true, true, true, true); - Web.Processors.RoundedCorners roundedCorners = new Web.Processors.RoundedCorners(); + Processors.RoundedCorners roundedCorners = new Processors.RoundedCorners(); roundedCorners.MatchRegexIndex(Querystring); RoundedCornerLayer actual = roundedCorners.Processor.DynamicParameter; @@ -202,12 +202,12 @@ namespace ImageProcessor.UnitTests Color expectedHex = ColorTranslator.FromHtml("#" + "6aa6cc"); Color expectedRgba = Color.FromArgb(255, 106, 166, 204); - Web.Processors.Tint tint = new Web.Processors.Tint(); + Processors.Tint tint = new Processors.Tint(); tint.MatchRegexIndex(HexQuerystring); Color actualHex = tint.Processor.DynamicParameter; Assert.AreEqual(expectedHex, actualHex); - tint = new Web.Processors.Tint(); + tint = new Processors.Tint(); tint.MatchRegexIndex(RgbaQuerystring); Color actualRgba = tint.Processor.DynamicParameter; Assert.AreEqual(expectedRgba, actualRgba); diff --git a/src/ImageProcessor.Web.UnitTests/packages.config b/src/ImageProcessor.Web.UnitTests/packages.config new file mode 100644 index 000000000..139d5138c --- /dev/null +++ b/src/ImageProcessor.Web.UnitTests/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/ImageProcessor.sln b/src/ImageProcessor.sln index 186a446c7..a12d17c68 100644 --- a/src/ImageProcessor.sln +++ b/src/ImageProcessor.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -VisualStudioVersion = 12.0.30110.0 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30501.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C427A497-74DC-49B1-8420-D6E68354F29B}" ProjectSection(SolutionItems) = preProject @@ -32,7 +32,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_Webforms_NET45 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessorConsole", "ImageProcessorConsole\ImageProcessorConsole.csproj", "{7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.UnitTests", "ImageProcessor.UnitTests\ImageProcessor.UnitTests.csproj", "{03CA9055-F997-428C-BF28-F50F991777C6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web.UnitTests", "ImageProcessor.Web.UnitTests\ImageProcessor.Web.UnitTests.csproj", "{961340C8-8C93-401D-A0A2-FF9EC61E5260}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.UnitTests", "ImageProcessor.UnitTests\ImageProcessor.UnitTests.csproj", "{633B1C4C-4823-47BE-9A01-A665F3118C8C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -47,24 +49,21 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {03CA9055-F997-428C-BF28-F50F991777C6}.All|Any CPU.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.All|Any CPU.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.All|Mixed Platforms.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.All|Mixed Platforms.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.All|x86.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.All|x86.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|x86.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|x86.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Any CPU.Build.0 = Release|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|x86.ActiveCfg = Release|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|x86.Build.0 = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.Build.0 = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|x86.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|x86.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.Build.0 = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|x86.ActiveCfg = Release|Any CPU {23CE0FC0-9E59-4C93-A604-A4A98A6284D1}.All|Any CPU.ActiveCfg = Release|Any CPU {23CE0FC0-9E59-4C93-A604-A4A98A6284D1}.All|Any CPU.Build.0 = Release|Any CPU {23CE0FC0-9E59-4C93-A604-A4A98A6284D1}.All|Mixed Platforms.ActiveCfg = Release|Any CPU @@ -97,21 +96,21 @@ Global {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.Build.0 = Release|x86 {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.ActiveCfg = Release|x86 {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.Build.0 = Release|x86 - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.Build.0 = All|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|x86.ActiveCfg = All|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|x86.ActiveCfg = Debug|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.Build.0 = Release|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|x86.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Any CPU.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Any CPU.Build.0 = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Mixed Platforms.Build.0 = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|x86.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|x86.ActiveCfg = Debug|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Any CPU.Build.0 = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|x86.ActiveCfg = Release|Any CPU {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Any CPU.ActiveCfg = All|Any CPU {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Any CPU.Build.0 = All|Any CPU {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Mixed Platforms.ActiveCfg = All|Any CPU @@ -127,36 +126,6 @@ Global {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Mixed Platforms.Build.0 = Release|Any CPU {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|x86.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.Build.0 = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.Build.0 = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|x86.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|x86.ActiveCfg = Debug|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.Build.0 = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|x86.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Any CPU.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Any CPU.Build.0 = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Mixed Platforms.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Mixed Platforms.Build.0 = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|x86.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|x86.ActiveCfg = Debug|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Any CPU.Build.0 = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|x86.ActiveCfg = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.All|Any CPU.ActiveCfg = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.All|Any CPU.Build.0 = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.All|Mixed Platforms.ActiveCfg = Release|Any CPU @@ -172,30 +141,73 @@ Global {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Mixed Platforms.Build.0 = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.Release|x86.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Any CPU.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Any CPU.Build.0 = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Mixed Platforms.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Mixed Platforms.Build.0 = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|x86.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|x86.ActiveCfg = Debug|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Any CPU.Build.0 = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|x86.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Any CPU.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Any CPU.Build.0 = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Mixed Platforms.Build.0 = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|x86.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|x86.ActiveCfg = Debug|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Any CPU.Build.0 = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|x86.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|x86.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|x86.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|x86.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.All|Any CPU.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.All|Any CPU.Build.0 = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.All|Mixed Platforms.Build.0 = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.All|x86.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Debug|Any CPU.Build.0 = Debug|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Debug|x86.ActiveCfg = Debug|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Release|Any CPU.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Release|Any CPU.Build.0 = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Release|x86.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.All|Any CPU.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.All|Any CPU.Build.0 = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.All|Mixed Platforms.Build.0 = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.All|x86.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Debug|x86.ActiveCfg = Debug|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|Any CPU.Build.0 = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection - GlobalSection(NestedProjects) = preSolution + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = ImageProcessorConsole\ImageProcessorConsole.csproj EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(TestCaseManagementSettings) = postSolution CategoryFile = ImageProcessor.vsmdi EndGlobalSection diff --git a/src/packages/repositories.config b/src/packages/repositories.config index 73ccce20c..14108b962 100644 --- a/src/packages/repositories.config +++ b/src/packages/repositories.config @@ -1,6 +1,8 @@  + + From 25e47ea86ac628bcae21f0dc0b20a3d3b881620f Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 26 Jun 2014 22:59:30 +0100 Subject: [PATCH 039/155] Moving Images in unit test Former-commit-id: 2df5d6efd190867743f5a3f13ee70bc11257e614 --- .../ImageFactoryUnitTests.cs | 2 +- .../ImageProcessor.UnitTests.csproj | 133 ++---------------- .../Images/Chrysanthemum.jpg.REMOVED.git-id | 1 + .../Images/Desert.jpg.REMOVED.git-id | 1 + .../Images/Penguins.bmp.REMOVED.git-id | 1 + .../Images/Penguins.gif.REMOVED.git-id | 1 + .../Images/cmyk.png.REMOVED.git-id | 1 + 7 files changed, 14 insertions(+), 126 deletions(-) create mode 100644 src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 940702f9c..a63f95ff2 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -42,7 +42,7 @@ namespace ImageProcessor.UnitTests [TestCase("Penguins.gif", "image/gif")] public void TestLoadImageFromFile(string fileName, string expectedMime) { - var testPhoto = Path.Combine(this.localPath, string.Format("Images/{0}", fileName)); + string testPhoto = Path.Combine(this.localPath, string.Format("../../Images/{0}", fileName)); using (ImageFactory imageFactory = new ImageFactory()) { imageFactory.Load(testPhoto); diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index 2be742cb4..81516b4b6 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -59,137 +59,20 @@ - - - Images\1182076_e8c402e938_z.jpg - - - Images\bus.jpg - - - Images\Chrysanthemum.jpg - - - Images\circle.png - - - Images\cmyk.jpg - - - Images\cmyk.png - - - Images\color-vision-test.gif - - - Images\Desert.jpg - - - Images\emma.jpg - - - Images\falahill_design__160p.jpg - - - Images\fid11246.jpg - - - Images\fid9141.jpg - - - Images\header_1.jpg - - - Images\Hydrangeas.jpg - - - Images\Jellyfish.jpg - - - Images\jrt.jpg - - - Images\Koala.jpg - - - Images\Lighthouse.jpg - - - Images\lomo.jpg - - - Images\meter.gif - - - Images\negative.png - - - Images\negative2.png - - - Images\Penguins-200.jpg - - - Images\Penguins-8.png - - - Images\Penguins.bmp - - - Images\Penguins.gif - - - Images\Penguins.jpg - - - Images\Penguins.png - - - Images\Penguins.tif - - - Images\rocks.jpg - - - Images\rotate.jpg - - - Images\sample1.jpg - - - Images\srgb.jpg - - - Images\srgb.png - - - Images\text.png - - - Images\thor.jpg - - - Images\Tulips.jpg - - - Images\udendørs-374.jpg - - - Images\udendørs.jpg - - - Images\war_horse_quad.jpg - - - Images\WP_000009.jpg - - {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} ImageProcessor + + + + + + + + diff --git a/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id new file mode 100644 index 000000000..d067665c9 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id @@ -0,0 +1 @@ +757c2a628dd03b1cbe4b3ef07c153897a702b57a \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id new file mode 100644 index 000000000..228aac3ab --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id @@ -0,0 +1 @@ +0b88c91336ff8073f34d21ccd683a01f0e0995da \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id new file mode 100644 index 000000000..74f69293c --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id @@ -0,0 +1 @@ +8150b46ab27c62ba51aaba551eef3f1a30f08de9 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id new file mode 100644 index 000000000..ce873d473 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id @@ -0,0 +1 @@ +6ad3b846d4697584ff601ac481b14a4d3bbb5736 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id new file mode 100644 index 000000000..aeca7b93c --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id @@ -0,0 +1 @@ +db4d55a332254cd6b41336c06f207682bf5a966f \ No newline at end of file From 46dc7d29df425264d5e87bfbe00c8409c6f1eb78 Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 26 Jun 2014 23:31:00 +0100 Subject: [PATCH 040/155] No client profile in NET 4.5+ http://msdn.microsoft.com/en-us/library/cc656912(v=vs.110).aspx Former-commit-id: 762f547b5b64681e0ec0cd383d5bfd30f9c6de71 --- src/ImageProcessorConsole/App.config | 6 +++--- src/ImageProcessorConsole/ImageProcessorConsole.csproj | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ImageProcessorConsole/App.config b/src/ImageProcessorConsole/App.config index 9c05822ff..d1428ad71 100644 --- a/src/ImageProcessorConsole/App.config +++ b/src/ImageProcessorConsole/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/src/ImageProcessorConsole/ImageProcessorConsole.csproj b/src/ImageProcessorConsole/ImageProcessorConsole.csproj index df60cf14b..fba366b0c 100644 --- a/src/ImageProcessorConsole/ImageProcessorConsole.csproj +++ b/src/ImageProcessorConsole/ImageProcessorConsole.csproj @@ -1,5 +1,5 @@  - + Debug @@ -12,7 +12,8 @@ v4.5 512 true - Client + + AnyCPU From 288a2f61e1407b2fe315c9a46d950bc2020c9bc0 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Wed, 25 Jun 2014 23:59:37 +0200 Subject: [PATCH 041/155] Creates a new Mono project so it can at least build (not yet run) on Xamarin/Mono Former-commit-id: b625d699fc6c68456157f8509e8e219d67c6c204 --- .../HttpModules/ImageProcessingModule.cs | 4 +- .../ImageProcessorConsole.csproj | 1 + src/ImageProcessor_Mono.sln | 132 ++++++++++++++++++ 3 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 src/ImageProcessor_Mono.sln diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index 67f3aee5d..33877e15b 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -126,7 +126,7 @@ namespace ImageProcessor.Web.HttpModules preserveExifMetaData = ImageProcessorConfiguration.Instance.PreserveExifMetaData; } -#if NET45 +#if NET45 && !__MonoCS__ EventHandlerTaskAsyncHelper wrapper = new EventHandlerTaskAsyncHelper(this.PostAuthorizeRequest); context.AddOnPostAuthorizeRequestAsync(wrapper.BeginEventHandler, wrapper.EndEventHandler); #else @@ -194,7 +194,7 @@ namespace ImageProcessor.Web.HttpModules } #endregion -#if NET45 +#if NET45 && !__MonoCS__ /// /// Occurs when the user for the current request has been authorized. diff --git a/src/ImageProcessorConsole/ImageProcessorConsole.csproj b/src/ImageProcessorConsole/ImageProcessorConsole.csproj index 09423698e..df60cf14b 100644 --- a/src/ImageProcessorConsole/ImageProcessorConsole.csproj +++ b/src/ImageProcessorConsole/ImageProcessorConsole.csproj @@ -9,6 +9,7 @@ Properties ImageProcessorConsole ImageProcessorConsole + v4.5 512 true Client diff --git a/src/ImageProcessor_Mono.sln b/src/ImageProcessor_Mono.sln new file mode 100644 index 000000000..d7e1410a8 --- /dev/null +++ b/src/ImageProcessor_Mono.sln @@ -0,0 +1,132 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +VisualStudioVersion = 12.0.30110.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C427A497-74DC-49B1-8420-D6E68354F29B}" + ProjectSection(SolutionItems) = preProject + ImageProcessor.vsmdi = ImageProcessor.vsmdi + Local.testsettings = Local.testsettings + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E656CDE-124D-4FAF-837C-0EF1E192D418}" + ProjectSection(SolutionItems) = preProject + .nuget\NuGet.Config = .nuget\NuGet.Config + .nuget\NuGet.exe = .nuget\NuGet.exe + .nuget\NuGet.targets = .nuget\NuGet.targets + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor", "ImageProcessor\ImageProcessor.csproj", "{3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_MVC_NET4", "TestWebsites\NET4\Test_Website_MVC_NET4.csproj", "{30327C08-7574-4D7E-AC95-6A58753C6855}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET4", "ImageProcessor.Web\NET4\ImageProcessor.Web_NET4.csproj", "{4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET45", "ImageProcessor.Web\NET45\ImageProcessor.Web_NET45.csproj", "{D011A778-59C8-4BFA-A770-C350216BF161}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessorConsole", "ImageProcessorConsole\ImageProcessorConsole.csproj", "{7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + All|Any CPU = All|Any CPU + All|Mixed Platforms = All|Mixed Platforms + All|x86 = All|x86 + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.ActiveCfg = All|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.Build.0 = All|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.ActiveCfg = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.Build.0 = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.ActiveCfg = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.Build.0 = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.ActiveCfg = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.Build.0 = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.Build.0 = Release|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.Build.0 = Release|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.ActiveCfg = Release|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.Build.0 = Release|x86 + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.Build.0 = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|x86.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|x86.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.Build.0 = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|x86.ActiveCfg = Release|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Any CPU.ActiveCfg = All|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Any CPU.Build.0 = All|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Mixed Platforms.ActiveCfg = All|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Mixed Platforms.Build.0 = All|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|x86.ActiveCfg = All|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|x86.ActiveCfg = Debug|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Any CPU.Build.0 = Release|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|x86.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|x86.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|x86.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|x86.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.All|Any CPU.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.All|Any CPU.Build.0 = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.All|Mixed Platforms.Build.0 = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.All|x86.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Debug|x86.ActiveCfg = Debug|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Any CPU.Build.0 = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {D011A778-59C8-4BFA-A770-C350216BF161}.Release|x86.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = ImageProcessor\ImageProcessor.csproj + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(TestCaseManagementSettings) = postSolution + CategoryFile = ImageProcessor.vsmdi + EndGlobalSection +EndGlobal From 6d37f951bfd7e9afb08f98886e4bcfd6151e9358 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Thu, 26 Jun 2014 00:08:55 +0200 Subject: [PATCH 042/155] Removes MVC test project from Mono solution because of heavy dependencies Former-commit-id: 659283d5017efeda799e0bf5227ed07e2ce41c15 --- src/ImageProcessor_Mono.sln | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/ImageProcessor_Mono.sln b/src/ImageProcessor_Mono.sln index d7e1410a8..7d47a2ca6 100644 --- a/src/ImageProcessor_Mono.sln +++ b/src/ImageProcessor_Mono.sln @@ -18,8 +18,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E656C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor", "ImageProcessor\ImageProcessor.csproj", "{3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_MVC_NET4", "TestWebsites\NET4\Test_Website_MVC_NET4.csproj", "{30327C08-7574-4D7E-AC95-6A58753C6855}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET4", "ImageProcessor.Web\NET4\ImageProcessor.Web_NET4.csproj", "{4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET45", "ImageProcessor.Web\NET45\ImageProcessor.Web_NET45.csproj", "{D011A778-59C8-4BFA-A770-C350216BF161}" @@ -39,24 +37,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.ActiveCfg = All|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.Build.0 = All|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.ActiveCfg = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.Build.0 = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.ActiveCfg = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.Build.0 = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.Build.0 = Debug|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.ActiveCfg = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.Build.0 = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.ActiveCfg = Release|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.Build.0 = Release|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.Build.0 = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.ActiveCfg = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.Build.0 = Release|x86 {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU From b3b6c09dbadd91b97b0edbd68c46142a249b3ebe Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 26 Jun 2014 22:30:08 +0100 Subject: [PATCH 043/155] Separating Unit Tests Hopefully rebuilding the projects will fix the AppVeyor issues. Former-commit-id: 3fe1413372e450bc1a33be212c36687cd85d7678 --- .../ImageProcessor.UnitTests.csproj | 282 ++++++++++-------- .../Properties/AssemblyInfo.cs | 36 +++ src/ImageProcessor.UnitTests/packages.config | 2 +- .../ImageProcessor.Web.UnitTests.csproj | 106 +++++++ .../Properties/AssemblyInfo.cs | 36 +++ .../RegularExpressionUnitTests.cs | 26 +- .../packages.config | 4 + src/ImageProcessor.sln | 182 +++++------ src/packages/repositories.config | 2 + 9 files changed, 458 insertions(+), 218 deletions(-) create mode 100644 src/ImageProcessor.UnitTests/Properties/AssemblyInfo.cs create mode 100644 src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj create mode 100644 src/ImageProcessor.Web.UnitTests/Properties/AssemblyInfo.cs rename src/{ImageProcessor.UnitTests => ImageProcessor.Web.UnitTests}/RegularExpressionUnitTests.cs (87%) create mode 100644 src/ImageProcessor.Web.UnitTests/packages.config diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index afce9a1d2..2be742cb4 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -1,178 +1,215 @@  - + Debug AnyCPU - {03CA9055-F997-428C-BF28-F50F991777C6} + {633B1C4C-4823-47BE-9A01-A665F3118C8C} Library + Properties ImageProcessor.UnitTests ImageProcessor.UnitTests - - + v4.0 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest ..\ true - v4.5 + true full false - bin\Debug - DEBUG; + bin\Debug\ + DEBUG;TRACE prompt 4 - false - false - full + pdbonly true - bin\Release + bin\Release\ + TRACE prompt 4 - false - false - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - + + + + + + + + + + - + - - - {d011a778-59c8-4bfa-a770-c350216bf161} - ImageProcessor.Web_NET45 - - - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} - ImageProcessor - + - - + + Images\1182076_e8c402e938_z.jpg + + + Images\bus.jpg + + Images\Chrysanthemum.jpg - PreserveNewest - - + + + Images\circle.png + + + Images\cmyk.jpg + + + Images\cmyk.png + + + Images\color-vision-test.gif + + Images\Desert.jpg - PreserveNewest - - + + + Images\emma.jpg + + + Images\falahill_design__160p.jpg + + + Images\fid11246.jpg + + + Images\fid9141.jpg + + + Images\header_1.jpg + + Images\Hydrangeas.jpg - PreserveNewest - - + + Images\Jellyfish.jpg - PreserveNewest - - + + + Images\jrt.jpg + + Images\Koala.jpg - PreserveNewest - - + + Images\Lighthouse.jpg - PreserveNewest - - + + + Images\lomo.jpg + + + Images\meter.gif + + + Images\negative.png + + + Images\negative2.png + + Images\Penguins-200.jpg - PreserveNewest - - + + Images\Penguins-8.png - PreserveNewest - - + + Images\Penguins.bmp - PreserveNewest - - + + Images\Penguins.gif - PreserveNewest - - + + Images\Penguins.jpg - PreserveNewest - - + + Images\Penguins.png - PreserveNewest - - + + Images\Penguins.tif - PreserveNewest - - - Images\Tulips.jpg - PreserveNewest - - - Images\bus.jpg - PreserveNewest - - - Images\cmyk.jpg - PreserveNewest - - - Images\cmyk.png - PreserveNewest - - - Images\jrt.jpg - PreserveNewest - - - Images\meter.gif - PreserveNewest - - + + Images\rocks.jpg - PreserveNewest - - + + Images\rotate.jpg - PreserveNewest - - + + Images\sample1.jpg - PreserveNewest - - + + Images\srgb.jpg - PreserveNewest - - + + Images\srgb.png - PreserveNewest - - + + Images\text.png - PreserveNewest - - + + Images\thor.jpg - PreserveNewest - - + + + Images\Tulips.jpg + + Images\udendørs-374.jpg - PreserveNewest - - + + Images\udendørs.jpg - PreserveNewest - + + + Images\war_horse_quad.jpg + + + Images\WP_000009.jpg + - + + + {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} + ImageProcessor + + + + + + + False + + + False + + + False + + + False + + + + + + @@ -180,4 +217,11 @@ + \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Properties/AssemblyInfo.cs b/src/ImageProcessor.UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..fb042a1d3 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImageProcessor.UnitTests2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ImageProcessor.UnitTests2")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3003f5a6-eb11-4eee-bfaa-448deb3a31d9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/ImageProcessor.UnitTests/packages.config b/src/ImageProcessor.UnitTests/packages.config index 5a3253fcb..a18b325a4 100644 --- a/src/ImageProcessor.UnitTests/packages.config +++ b/src/ImageProcessor.UnitTests/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj b/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj new file mode 100644 index 000000000..17c54d202 --- /dev/null +++ b/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj @@ -0,0 +1,106 @@ + + + + Debug + AnyCPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260} + Library + Properties + ImageProcessor.Web.UnitTests + ImageProcessor.Web.UnitTests + v4.5.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + ..\ + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + ..\packages\NUnit.2.6.3\lib\nunit.framework.dll + + + + + + + + + + + + + + + + + + + + + + {d011a778-59c8-4bfa-a770-c350216bf161} + ImageProcessor.Web_NET45 + + + {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} + ImageProcessor + + + + + + + False + + + False + + + False + + + False + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/src/ImageProcessor.Web.UnitTests/Properties/AssemblyInfo.cs b/src/ImageProcessor.Web.UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..db6aa3c94 --- /dev/null +++ b/src/ImageProcessor.Web.UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImageProcessor.Web.UnitTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ImageProcessor.Web.UnitTests")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("74919969-6a75-4d26-b1b8-0626aa10af6d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/ImageProcessor.UnitTests/RegularExpressionUnitTests.cs b/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs similarity index 87% rename from src/ImageProcessor.UnitTests/RegularExpressionUnitTests.cs rename to src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs index 417e94f8c..c41454563 100644 --- a/src/ImageProcessor.UnitTests/RegularExpressionUnitTests.cs +++ b/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs @@ -8,7 +8,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.UnitTests +namespace ImageProcessor.Web.UnitTests { using System.Drawing; using ImageProcessor.Imaging; @@ -31,7 +31,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "alpha=56"; const int Expected = 56; - Web.Processors.Alpha alpha = new Web.Processors.Alpha(); + Processors.Alpha alpha = new Processors.Alpha(); alpha.MatchRegexIndex(Querystring); int actual = alpha.Processor.DynamicParameter; @@ -48,7 +48,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "brightness=56"; const int Expected = 56; - Web.Processors.Brightness brightness = new Web.Processors.Brightness(); + Processors.Brightness brightness = new Processors.Brightness(); brightness.MatchRegexIndex(Querystring); int actual = brightness.Processor.DynamicParameter; @@ -65,7 +65,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "contrast=56"; const int Expected = 56; - Web.Processors.Contrast contrast = new Web.Processors.Contrast(); + Processors.Contrast contrast = new Processors.Contrast(); contrast.MatchRegexIndex(Querystring); int actual = contrast.Processor.DynamicParameter; @@ -82,7 +82,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "crop=0,0,150,300"; CropLayer expected = new CropLayer(0, 0, 150, 300, CropMode.Pixels); - Web.Processors.Crop crop = new Web.Processors.Crop(); + Processors.Crop crop = new Processors.Crop(); crop.MatchRegexIndex(Querystring); CropLayer actual = crop.Processor.DynamicParameter; @@ -99,7 +99,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "filter=lomograph"; IMatrixFilter expected = MatrixFilters.Lomograph; - Web.Processors.Filter filter = new Web.Processors.Filter(); + Processors.Filter filter = new Processors.Filter(); filter.MatchRegexIndex(Querystring); IMatrixFilter actual = filter.Processor.DynamicParameter; @@ -116,7 +116,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "format=gif"; ISupportedImageFormat expected = new GifFormat(); - Web.Processors.Format format = new Web.Processors.Format(); + Processors.Format format = new Processors.Format(); format.MatchRegexIndex(Querystring); ISupportedImageFormat actual = format.Processor.DynamicParameter; @@ -133,7 +133,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "quality=56"; const int Expected = 56; - Web.Processors.Quality quality = new Web.Processors.Quality(); + Processors.Quality quality = new Processors.Quality(); quality.MatchRegexIndex(Querystring); int actual = quality.Processor.DynamicParameter; @@ -150,7 +150,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "width=300"; ResizeLayer expected = new ResizeLayer(new Size(300, 0)); - Web.Processors.Resize resize = new Web.Processors.Resize(); + Processors.Resize resize = new Processors.Resize(); resize.MatchRegexIndex(Querystring); ResizeLayer actual = resize.Processor.DynamicParameter; @@ -167,7 +167,7 @@ namespace ImageProcessor.UnitTests const string Querystring = "rotate=270"; const int Expected = 270; - Web.Processors.Rotate rotate = new Web.Processors.Rotate(); + Processors.Rotate rotate = new Processors.Rotate(); rotate.MatchRegexIndex(Querystring); int actual = rotate.Processor.DynamicParameter; @@ -183,7 +183,7 @@ namespace ImageProcessor.UnitTests { const string Querystring = "roundedcorners=30"; RoundedCornerLayer expected = new RoundedCornerLayer(30, true, true, true, true); - Web.Processors.RoundedCorners roundedCorners = new Web.Processors.RoundedCorners(); + Processors.RoundedCorners roundedCorners = new Processors.RoundedCorners(); roundedCorners.MatchRegexIndex(Querystring); RoundedCornerLayer actual = roundedCorners.Processor.DynamicParameter; @@ -202,12 +202,12 @@ namespace ImageProcessor.UnitTests Color expectedHex = ColorTranslator.FromHtml("#" + "6aa6cc"); Color expectedRgba = Color.FromArgb(255, 106, 166, 204); - Web.Processors.Tint tint = new Web.Processors.Tint(); + Processors.Tint tint = new Processors.Tint(); tint.MatchRegexIndex(HexQuerystring); Color actualHex = tint.Processor.DynamicParameter; Assert.AreEqual(expectedHex, actualHex); - tint = new Web.Processors.Tint(); + tint = new Processors.Tint(); tint.MatchRegexIndex(RgbaQuerystring); Color actualRgba = tint.Processor.DynamicParameter; Assert.AreEqual(expectedRgba, actualRgba); diff --git a/src/ImageProcessor.Web.UnitTests/packages.config b/src/ImageProcessor.Web.UnitTests/packages.config new file mode 100644 index 000000000..139d5138c --- /dev/null +++ b/src/ImageProcessor.Web.UnitTests/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/ImageProcessor.sln b/src/ImageProcessor.sln index 186a446c7..a12d17c68 100644 --- a/src/ImageProcessor.sln +++ b/src/ImageProcessor.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -VisualStudioVersion = 12.0.30110.0 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30501.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C427A497-74DC-49B1-8420-D6E68354F29B}" ProjectSection(SolutionItems) = preProject @@ -32,7 +32,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_Webforms_NET45 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessorConsole", "ImageProcessorConsole\ImageProcessorConsole.csproj", "{7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.UnitTests", "ImageProcessor.UnitTests\ImageProcessor.UnitTests.csproj", "{03CA9055-F997-428C-BF28-F50F991777C6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web.UnitTests", "ImageProcessor.Web.UnitTests\ImageProcessor.Web.UnitTests.csproj", "{961340C8-8C93-401D-A0A2-FF9EC61E5260}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.UnitTests", "ImageProcessor.UnitTests\ImageProcessor.UnitTests.csproj", "{633B1C4C-4823-47BE-9A01-A665F3118C8C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -47,24 +49,21 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {03CA9055-F997-428C-BF28-F50F991777C6}.All|Any CPU.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.All|Any CPU.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.All|Mixed Platforms.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.All|Mixed Platforms.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.All|x86.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.All|x86.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|x86.ActiveCfg = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|x86.Build.0 = Debug|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Any CPU.Build.0 = Release|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|x86.ActiveCfg = Release|Any CPU - {03CA9055-F997-428C-BF28-F50F991777C6}.Release|x86.Build.0 = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.Build.0 = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|x86.ActiveCfg = All|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|x86.ActiveCfg = Debug|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.Build.0 = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|x86.ActiveCfg = Release|Any CPU {23CE0FC0-9E59-4C93-A604-A4A98A6284D1}.All|Any CPU.ActiveCfg = Release|Any CPU {23CE0FC0-9E59-4C93-A604-A4A98A6284D1}.All|Any CPU.Build.0 = Release|Any CPU {23CE0FC0-9E59-4C93-A604-A4A98A6284D1}.All|Mixed Platforms.ActiveCfg = Release|Any CPU @@ -97,21 +96,21 @@ Global {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.Build.0 = Release|x86 {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.ActiveCfg = Release|x86 {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.Build.0 = Release|x86 - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.Build.0 = All|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|x86.ActiveCfg = All|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Debug|x86.ActiveCfg = Debug|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Any CPU.Build.0 = Release|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.Release|x86.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Any CPU.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Any CPU.Build.0 = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Mixed Platforms.Build.0 = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|x86.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|x86.ActiveCfg = Debug|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Any CPU.Build.0 = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|x86.ActiveCfg = Release|Any CPU {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Any CPU.ActiveCfg = All|Any CPU {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Any CPU.Build.0 = All|Any CPU {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Mixed Platforms.ActiveCfg = All|Any CPU @@ -127,36 +126,6 @@ Global {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Mixed Platforms.Build.0 = Release|Any CPU {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|x86.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.Build.0 = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.Build.0 = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|x86.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|x86.ActiveCfg = Debug|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.Build.0 = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|x86.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Any CPU.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Any CPU.Build.0 = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Mixed Platforms.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Mixed Platforms.Build.0 = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|x86.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|x86.ActiveCfg = Debug|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Any CPU.Build.0 = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|x86.ActiveCfg = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.All|Any CPU.ActiveCfg = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.All|Any CPU.Build.0 = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.All|Mixed Platforms.ActiveCfg = Release|Any CPU @@ -172,30 +141,73 @@ Global {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.Release|Mixed Platforms.Build.0 = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.Release|x86.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Any CPU.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Any CPU.Build.0 = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Mixed Platforms.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Mixed Platforms.Build.0 = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|x86.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Debug|x86.ActiveCfg = Debug|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Any CPU.Build.0 = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|x86.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Any CPU.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Any CPU.Build.0 = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|Mixed Platforms.Build.0 = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.All|x86.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Debug|x86.ActiveCfg = Debug|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Any CPU.Build.0 = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}.Release|x86.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Any CPU.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|Mixed Platforms.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.All|x86.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Debug|x86.ActiveCfg = Debug|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Any CPU.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}.Release|x86.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.All|Any CPU.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.All|Any CPU.Build.0 = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.All|Mixed Platforms.Build.0 = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.All|x86.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Debug|Any CPU.Build.0 = Debug|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Debug|x86.ActiveCfg = Debug|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Release|Any CPU.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Release|Any CPU.Build.0 = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {961340C8-8C93-401D-A0A2-FF9EC61E5260}.Release|x86.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.All|Any CPU.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.All|Any CPU.Build.0 = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.All|Mixed Platforms.Build.0 = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.All|x86.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Debug|x86.ActiveCfg = Debug|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|Any CPU.Build.0 = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection - GlobalSection(NestedProjects) = preSolution + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = ImageProcessorConsole\ImageProcessorConsole.csproj EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(TestCaseManagementSettings) = postSolution CategoryFile = ImageProcessor.vsmdi EndGlobalSection diff --git a/src/packages/repositories.config b/src/packages/repositories.config index 73ccce20c..14108b962 100644 --- a/src/packages/repositories.config +++ b/src/packages/repositories.config @@ -1,6 +1,8 @@  + + From 54d237180121ca92208916ee068a8247509cf07f Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 26 Jun 2014 22:59:30 +0100 Subject: [PATCH 044/155] Moving Images in unit test Former-commit-id: fbac18062ba6e6102eb2437bfbd830022ce1885b --- .../ImageFactoryUnitTests.cs | 2 +- .../ImageProcessor.UnitTests.csproj | 133 ++---------------- .../Images/Chrysanthemum.jpg.REMOVED.git-id | 1 + .../Images/Desert.jpg.REMOVED.git-id | 1 + .../Images/Penguins.bmp.REMOVED.git-id | 1 + .../Images/Penguins.gif.REMOVED.git-id | 1 + .../Images/cmyk.png.REMOVED.git-id | 1 + 7 files changed, 14 insertions(+), 126 deletions(-) create mode 100644 src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 940702f9c..a63f95ff2 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -42,7 +42,7 @@ namespace ImageProcessor.UnitTests [TestCase("Penguins.gif", "image/gif")] public void TestLoadImageFromFile(string fileName, string expectedMime) { - var testPhoto = Path.Combine(this.localPath, string.Format("Images/{0}", fileName)); + string testPhoto = Path.Combine(this.localPath, string.Format("../../Images/{0}", fileName)); using (ImageFactory imageFactory = new ImageFactory()) { imageFactory.Load(testPhoto); diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index 2be742cb4..81516b4b6 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -59,137 +59,20 @@ - - - Images\1182076_e8c402e938_z.jpg - - - Images\bus.jpg - - - Images\Chrysanthemum.jpg - - - Images\circle.png - - - Images\cmyk.jpg - - - Images\cmyk.png - - - Images\color-vision-test.gif - - - Images\Desert.jpg - - - Images\emma.jpg - - - Images\falahill_design__160p.jpg - - - Images\fid11246.jpg - - - Images\fid9141.jpg - - - Images\header_1.jpg - - - Images\Hydrangeas.jpg - - - Images\Jellyfish.jpg - - - Images\jrt.jpg - - - Images\Koala.jpg - - - Images\Lighthouse.jpg - - - Images\lomo.jpg - - - Images\meter.gif - - - Images\negative.png - - - Images\negative2.png - - - Images\Penguins-200.jpg - - - Images\Penguins-8.png - - - Images\Penguins.bmp - - - Images\Penguins.gif - - - Images\Penguins.jpg - - - Images\Penguins.png - - - Images\Penguins.tif - - - Images\rocks.jpg - - - Images\rotate.jpg - - - Images\sample1.jpg - - - Images\srgb.jpg - - - Images\srgb.png - - - Images\text.png - - - Images\thor.jpg - - - Images\Tulips.jpg - - - Images\udendørs-374.jpg - - - Images\udendørs.jpg - - - Images\war_horse_quad.jpg - - - Images\WP_000009.jpg - - {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} ImageProcessor + + + + + + + + diff --git a/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id new file mode 100644 index 000000000..d067665c9 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id @@ -0,0 +1 @@ +757c2a628dd03b1cbe4b3ef07c153897a702b57a \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id new file mode 100644 index 000000000..228aac3ab --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id @@ -0,0 +1 @@ +0b88c91336ff8073f34d21ccd683a01f0e0995da \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id new file mode 100644 index 000000000..74f69293c --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id @@ -0,0 +1 @@ +8150b46ab27c62ba51aaba551eef3f1a30f08de9 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id new file mode 100644 index 000000000..ce873d473 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id @@ -0,0 +1 @@ +6ad3b846d4697584ff601ac481b14a4d3bbb5736 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id new file mode 100644 index 000000000..aeca7b93c --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id @@ -0,0 +1 @@ +db4d55a332254cd6b41336c06f207682bf5a966f \ No newline at end of file From 10452c34e063f1aec388b5dc0de3111766f2f9c2 Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 26 Jun 2014 23:31:00 +0100 Subject: [PATCH 045/155] No client profile in NET 4.5+ http://msdn.microsoft.com/en-us/library/cc656912(v=vs.110).aspx Former-commit-id: 52b2d9d854666e730273f6ee15c5aa3acbcdd228 --- src/ImageProcessorConsole/App.config | 6 +++--- src/ImageProcessorConsole/ImageProcessorConsole.csproj | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ImageProcessorConsole/App.config b/src/ImageProcessorConsole/App.config index 9c05822ff..d1428ad71 100644 --- a/src/ImageProcessorConsole/App.config +++ b/src/ImageProcessorConsole/App.config @@ -1,6 +1,6 @@ - + - + - \ No newline at end of file + diff --git a/src/ImageProcessorConsole/ImageProcessorConsole.csproj b/src/ImageProcessorConsole/ImageProcessorConsole.csproj index df60cf14b..fba366b0c 100644 --- a/src/ImageProcessorConsole/ImageProcessorConsole.csproj +++ b/src/ImageProcessorConsole/ImageProcessorConsole.csproj @@ -1,5 +1,5 @@  - + Debug @@ -12,7 +12,8 @@ v4.5 512 true - Client + + AnyCPU From 9e7591c36dc3fa973102bebbcc7f5de8ac47ddd7 Mon Sep 17 00:00:00 2001 From: James South Date: Fri, 27 Jun 2014 12:20:41 +0100 Subject: [PATCH 046/155] Hopefully fixing reflection load exceptions. Former-commit-id: ed1f13eef59d53031687c4c0bdc4ebb4fcf21e77 --- build/Build.bat | 2 +- .../ImageProcessorConfiguration.cs | 9 ++-- .../Common/Extensions/AssemblyExtensions.cs | 41 +++++++++++++++++++ .../ImageProcessorBootstrapper.cs | 6 +-- src/ImageProcessor/ImageProcessor.csproj | 1 + 5 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 src/ImageProcessor/Common/Extensions/AssemblyExtensions.cs diff --git a/build/Build.bat b/build/Build.bat index 0f1c369bb..513d111e3 100644 --- a/build/Build.bat +++ b/build/Build.bat @@ -8,7 +8,7 @@ ECHO Building ImageProcessor %version%, ImageProcess.Web %webversion% and ImageP ECHO Installing the Microsoft.Bcl.Build package before anything else, otherwise you'd have to run build.cmd twice SET nuGetFolder=%CD%\..\src\packages\ -..\src\.nuget\NuGet.exe install ..\src\ImageProcessor.Web\NET45\packages.config -OutputDirectory %nuGetFolder% +..\src\.nuget\NuGet.exe install ..\src\ImageProcessor.Web\NET4\packages.config -OutputDirectory %nuGetFolder% ECHO Removing _BuildOutput directory so everything is nice and clean RD _BuildOutput /q /s diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs index be4966966..89bcf39d7 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs @@ -10,18 +10,17 @@ // -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Web.Configuration { - #region Using using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Web.Compilation; + + using ImageProcessor.Common.Extensions; using ImageProcessor.Processors; using ImageProcessor.Web.Processors; - #endregion - /// /// Encapsulates methods to allow the retrieval of ImageProcessor settings. /// @@ -301,8 +300,8 @@ namespace ImageProcessor.Web.Configuration // Build a list of native IGraphicsProcessor instances. List availableTypes = BuildManager.GetReferencedAssemblies() .Cast() - .SelectMany(s => s.GetTypes()) - .Where(t => t != null && type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract) + .SelectMany(s => s.GetLoadableTypes()) + .Where(t => type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract) .ToList(); // Create them and add. diff --git a/src/ImageProcessor/Common/Extensions/AssemblyExtensions.cs b/src/ImageProcessor/Common/Extensions/AssemblyExtensions.cs new file mode 100644 index 000000000..763697ef0 --- /dev/null +++ b/src/ImageProcessor/Common/Extensions/AssemblyExtensions.cs @@ -0,0 +1,41 @@ + +namespace ImageProcessor.Common.Extensions +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Reflection; + + /// + /// Encapsulates a series of time saving extension methods to the class. + /// + public static class AssemblyExtensions + { + /// + /// Gets a collection of loadable types from the given assembly. + /// Adapted from + /// + /// + /// The to load the types from. + /// + /// + /// The loadable . + /// + public static IEnumerable GetLoadableTypes(this Assembly assembly) + { + if (assembly == null) + { + throw new ArgumentNullException("assembly"); + } + + try + { + return assembly.GetTypes(); + } + catch (ReflectionTypeLoadException ex) + { + return ex.Types.Where(t => t != null); + } + } + } +} diff --git a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs index e1d59b7f6..e6a7f1962 100644 --- a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs +++ b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs @@ -13,8 +13,8 @@ namespace ImageProcessor.Configuration using System; using System.Collections.Generic; using System.Linq; - using ImageProcessor.Common.Exceptions; + using ImageProcessor.Common.Extensions; using ImageProcessor.Imaging.Formats; /// @@ -65,8 +65,8 @@ namespace ImageProcessor.Configuration Type type = typeof(ISupportedImageFormat); List availableTypes = AppDomain.CurrentDomain .GetAssemblies() - .SelectMany(s => s.GetTypes()) - .Where(t => t != null && type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract) + .SelectMany(s => s.GetLoadableTypes()) + .Where(t => type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract) .ToList(); this.SupportedImageFormats = availableTypes diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 34f818362..4521b06eb 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -59,6 +59,7 @@ + From cf4aefa5c01ade86da4499bb4216e178dddfcd5e Mon Sep 17 00:00:00 2001 From: James South Date: Fri, 27 Jun 2014 15:53:51 +0100 Subject: [PATCH 047/155] Adding build status badge Former-commit-id: d7d78e4c731a7c1d945add87ed6d3c96137a7829 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 14d8451e7..ec07138b5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ ImageProcessor =============== +[![Build status](https://ci.appveyor.com/api/projects/status/8ypr7527dnao04yr)](https://ci.appveyor.com/project/JamesSouth/imageprocessor) + Imageprocessor is a lightweight library written in C# that allows you to manipulate images on-the-fly using .NET 4.0. It's fast, extensible, easy to use, comes bundled with some great features and is fully open source. From 14eaf8b266f0f11579ed4f87506eff1c3adc605a Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 15:42:31 +0200 Subject: [PATCH 048/155] Adds new test of factory for loading an image from a memory stream Former-commit-id: 98343f28edb50392fcad4d871451559a441e3152 --- .../ImageFactoryUnitTests.cs | 33 +++ .../ImageProcessor.UnitTests.csproj | 202 ++++++++++++------ src/ImageProcessor_Mono.sln | 26 ++- 3 files changed, 190 insertions(+), 71 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index a63f95ff2..1fc782073 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -51,5 +51,38 @@ namespace ImageProcessor.UnitTests Assert.IsNotNull(imageFactory.Image); } } + + /// > + /// Tests the loading of image from a memory stream + /// + /// + /// The file Name. + /// + /// + /// The expected mime type. + /// + [Test] + [TestCase("Chrysanthemum.jpg", "image/jpeg")] + [TestCase("Desert.jpg", "image/jpeg")] + [TestCase("cmyk.png", "image/png")] + [TestCase("Penguins.bmp", "image/bmp")] + [TestCase("Penguins.gif", "image/gif")] + public void TestLoadImageFromMemory(string fileName, string expectedMime) + { + string testPhoto = Path.Combine(this.localPath, string.Format("../../Images/{0}", fileName)); + byte[] photoBytes = File.ReadAllBytes(testPhoto); + + // ImageProcessor + using (MemoryStream inStream = new MemoryStream(photoBytes)) + { + using (ImageFactory imageFactory = new ImageFactory()) + { + imageFactory.Load(inStream); + Assert.AreEqual(null, imageFactory.ImagePath); + Assert.AreEqual(expectedMime, imageFactory.CurrentImageFormat.MimeType); + Assert.IsNotNull(imageFactory.Image); + } + } + } } } \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index 81516b4b6..d5841e6c2 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -1,98 +1,177 @@  - + Debug AnyCPU - {633B1C4C-4823-47BE-9A01-A665F3118C8C} + {03CA9055-F997-428C-BF28-F50F991777C6} Library - Properties ImageProcessor.UnitTests ImageProcessor.UnitTests - v4.0 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest + + ..\ true - + v4.5 true full false - bin\Debug\ - DEBUG;TRACE + bin\Debug + DEBUG; prompt 4 + false + false - pdbonly + full true - bin\Release\ - TRACE + bin\Release prompt 4 + false + false + + ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - + + - - - - - - - - - - - - + + + {D011A778-59C8-4BFA-A770-C350216BF161} + ImageProcessor.Web_NET45 + - {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} ImageProcessor - - - - - - + + + Images\Chrysanthemum.jpg + PreserveNewest + + + Images\Desert.jpg + PreserveNewest + + + Images\Hydrangeas.jpg + PreserveNewest + + + Images\Jellyfish.jpg + PreserveNewest + + + Images\Koala.jpg + PreserveNewest + + + Images\Lighthouse.jpg + PreserveNewest + + + Images\Penguins-200.jpg + PreserveNewest + + + Images\Penguins-8.png + PreserveNewest + + + Images\Penguins.bmp + PreserveNewest + + + Images\Penguins.gif + PreserveNewest + + + Images\Penguins.jpg + PreserveNewest + + + Images\Penguins.png + PreserveNewest + + + Images\Penguins.tif + PreserveNewest + + + Images\Tulips.jpg + PreserveNewest + + + Images\bus.jpg + PreserveNewest + + + Images\cmyk.jpg + PreserveNewest + + + Images\cmyk.png + PreserveNewest + + + Images\jrt.jpg + PreserveNewest + + + Images\meter.gif + PreserveNewest + + + Images\rocks.jpg + PreserveNewest + + + Images\rotate.jpg + PreserveNewest + + + Images\sample1.jpg + PreserveNewest + + + Images\srgb.jpg + PreserveNewest + + + Images\srgb.png + PreserveNewest + + + Images\text.png + PreserveNewest + + + Images\thor.jpg + PreserveNewest + + + Images\udendørs-374.jpg + PreserveNewest + + + Images\udendørs.jpg + PreserveNewest + - - - - - False - - - False - - - False - - - False - - - - - - + @@ -100,11 +179,4 @@ - \ No newline at end of file diff --git a/src/ImageProcessor_Mono.sln b/src/ImageProcessor_Mono.sln index 7d47a2ca6..8b1e0fb37 100644 --- a/src/ImageProcessor_Mono.sln +++ b/src/ImageProcessor_Mono.sln @@ -3,12 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 VisualStudioVersion = 12.0.30110.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C427A497-74DC-49B1-8420-D6E68354F29B}" - ProjectSection(SolutionItems) = preProject - ImageProcessor.vsmdi = ImageProcessor.vsmdi - Local.testsettings = Local.testsettings - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E656CDE-124D-4FAF-837C-0EF1E192D418}" ProjectSection(SolutionItems) = preProject .nuget\NuGet.Config = .nuget\NuGet.Config @@ -24,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET45", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessorConsole", "ImageProcessorConsole\ImageProcessorConsole.csproj", "{7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.UnitTests", "ImageProcessor.UnitTests\ImageProcessor.UnitTests.csproj", "{03CA9055-F997-428C-BF28-F50F991777C6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Any CPU = All|Any CPU @@ -37,6 +33,24 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {03CA9055-F997-428C-BF28-F50F991777C6}.All|Any CPU.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.All|Any CPU.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.All|Mixed Platforms.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.All|Mixed Platforms.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.All|x86.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.All|x86.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|x86.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|x86.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Any CPU.Build.0 = Release|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|x86.ActiveCfg = Release|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|x86.Build.0 = Release|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU From 7c37f5e89a6b624d75a07fc1ec12b485537228cc Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 18:03:26 +0200 Subject: [PATCH 049/155] Loads all the test images + tests a few filters as well (failing for gif images) Former-commit-id: 193b0354b1e8f9e227919084076d6fd1776425d1 --- .../ImageFactoryUnitTests.cs | 106 +++++++++++------- 1 file changed, 67 insertions(+), 39 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 1fc782073..7cd124b19 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -12,6 +12,7 @@ namespace ImageProcessor.UnitTests { using System; using System.IO; + using System.Collections.Generic; using NUnit.Framework; /// @@ -25,62 +26,89 @@ namespace ImageProcessor.UnitTests /// private readonly string localPath = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); + /// + /// Lists the input files in the Images folder + /// + /// The list of files. + private static IEnumerable ListInputFiles() + { + return Directory.GetFiles("./Images"); + } + /// /// Tests the loading of image from a file /// - /// - /// The file Name. - /// - /// - /// The expected mime type. - /// [Test] - [TestCase("Chrysanthemum.jpg", "image/jpeg")] - [TestCase("Desert.jpg", "image/jpeg")] - [TestCase("cmyk.png", "image/png")] - [TestCase("Penguins.bmp", "image/bmp")] - [TestCase("Penguins.gif", "image/gif")] - public void TestLoadImageFromFile(string fileName, string expectedMime) + public void TestLoadImageFromFile() { - string testPhoto = Path.Combine(this.localPath, string.Format("../../Images/{0}", fileName)); - using (ImageFactory imageFactory = new ImageFactory()) + foreach (var fileName in ListInputFiles()) { - imageFactory.Load(testPhoto); - Assert.AreEqual(testPhoto, imageFactory.ImagePath); - Assert.AreEqual(expectedMime, imageFactory.CurrentImageFormat.MimeType); - Assert.IsNotNull(imageFactory.Image); + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + Assert.AreEqual(fileName, imageFactory.ImagePath); + Assert.IsNotNull(imageFactory.Image); + } } + } /// > /// Tests the loading of image from a memory stream /// - /// - /// The file Name. - /// - /// - /// The expected mime type. - /// [Test] - [TestCase("Chrysanthemum.jpg", "image/jpeg")] - [TestCase("Desert.jpg", "image/jpeg")] - [TestCase("cmyk.png", "image/png")] - [TestCase("Penguins.bmp", "image/bmp")] - [TestCase("Penguins.gif", "image/gif")] - public void TestLoadImageFromMemory(string fileName, string expectedMime) + public void TestLoadImageFromMemory() { - string testPhoto = Path.Combine(this.localPath, string.Format("../../Images/{0}", fileName)); - byte[] photoBytes = File.ReadAllBytes(testPhoto); + foreach (var fileName in ListInputFiles()) + { + byte[] photoBytes = File.ReadAllBytes(fileName); - // ImageProcessor - using (MemoryStream inStream = new MemoryStream(photoBytes)) + using (var inStream = new MemoryStream(photoBytes)) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(inStream); + Assert.AreEqual(null, imageFactory.ImagePath); + Assert.IsNotNull(imageFactory.Image); + } + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void ApplyEffectAlpha() + { + foreach (var fileName in ListInputFiles()) { - using (ImageFactory imageFactory = new ImageFactory()) + using (var imageFactory = new ImageFactory()) { - imageFactory.Load(inStream); - Assert.AreEqual(null, imageFactory.ImagePath); - Assert.AreEqual(expectedMime, imageFactory.CurrentImageFormat.MimeType); - Assert.IsNotNull(imageFactory.Image); + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Alpha(50); + var modified = imageFactory.Image.Clone(); + Assert.AreNotEqual(original, modified); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void ApplyEffectBrightness() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Brightness(50); + var modified = imageFactory.Image.Clone(); + Assert.AreNotEqual(original, modified); } } } From 03c19e3ae249e90d165a21750084f19b680a4212 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 18:13:23 +0200 Subject: [PATCH 050/155] Adds test for constraints resize Former-commit-id: a30d4df7acc83a74eab1ed881a010fe14b42dd1f --- .../ImageFactoryUnitTests.cs | 24 +++++++++++++++---- .../ImageProcessor.UnitTests.csproj | 4 ---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 7cd124b19..b81cff068 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -21,11 +21,6 @@ namespace ImageProcessor.UnitTests [TestFixture] public class ImageFactoryUnitTests { - /// - /// The path to the binary's folder - /// - private readonly string localPath = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); - /// /// Lists the input files in the Images folder /// @@ -112,5 +107,24 @@ namespace ImageProcessor.UnitTests } } } + + /// + /// Tests that the image is well resized using constraints + /// + [Test] + public void ApplyConstraints() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Constrain(new System.Drawing.Size(200, 200)); + var modified = imageFactory.Image.Clone(); + Assert.AreNotEqual(original, modified); + } + } + } } } \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index d5841e6c2..4bb9bf77f 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -82,10 +82,6 @@ Images\Lighthouse.jpg PreserveNewest - - Images\Penguins-200.jpg - PreserveNewest - Images\Penguins-8.png PreserveNewest From 12e8fbca6c13821247bd02c423ba7c912e4815cd Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 18:16:34 +0200 Subject: [PATCH 051/155] Checks that the image is actually resized Former-commit-id: cf8a8931b6b28c4825283f3a6af4e8c4d087ca9e --- .../ImageFactoryUnitTests.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index b81cff068..936c32345 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -83,8 +83,7 @@ namespace ImageProcessor.UnitTests imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); imageFactory.Alpha(50); - var modified = imageFactory.Image.Clone(); - Assert.AreNotEqual(original, modified); + Assert.AreNotEqual(original, imageFactory.Image); } } } @@ -102,8 +101,7 @@ namespace ImageProcessor.UnitTests imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); imageFactory.Brightness(50); - var modified = imageFactory.Image.Clone(); - Assert.AreNotEqual(original, modified); + Assert.AreNotEqual(original, imageFactory.Image); } } } @@ -114,15 +112,17 @@ namespace ImageProcessor.UnitTests [Test] public void ApplyConstraints() { + const int maxSize = 200; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); - imageFactory.Constrain(new System.Drawing.Size(200, 200)); - var modified = imageFactory.Image.Clone(); - Assert.AreNotEqual(original, modified); + imageFactory.Constrain(new System.Drawing.Size(maxSize, maxSize)); + Assert.AreNotEqual(original, imageFactory.Image); + Assert.LessOrEqual(maxSize, imageFactory.Image.Width); + Assert.LessOrEqual(maxSize, imageFactory.Image.Height); } } } From ea1ac25f949153235c0a43d4fbf86cdec5a3b668 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 18:52:29 +0200 Subject: [PATCH 052/155] First fix of an animated gif problem on Mono Former-commit-id: 43eebfe02b5974def03fbf40962c787c2c6cdf0a --- src/ImageProcessor/Imaging/Formats/FormatUtilities.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs index 36d2e3c07..3c6e3b3e0 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs @@ -135,12 +135,14 @@ namespace ImageProcessor.Imaging.Formats int frameCount = image.GetFrameCount(frameDimension); int last = frameCount - 1; int delay = 0; - int index = 0; List gifFrames = new List(); for (int i = 0; i < frameCount; i++) { - int thisDelay = BitConverter.ToInt32(image.GetPropertyItem(20736).Value, index); + // GDI returns a single array with all delays, while Mono returns a different array for each frame + image.SelectActiveFrame(frameDimension, i); + var times = image.GetPropertyItem(20736).Value; + int thisDelay = BitConverter.ToInt32(times, 4*i % times.Length); int toAddDelay = thisDelay * 10 < 20 ? 20 : thisDelay * 10; // Minimum delay is 20 ms // Find the frame @@ -156,7 +158,6 @@ namespace ImageProcessor.Imaging.Formats } delay += toAddDelay; - index += 4; } info.GifFrames = gifFrames; From 77c0887972a10af797c57dc4fce11660d6f61ba4 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 20:48:03 +0200 Subject: [PATCH 053/155] Fixes a unit test (wrong parameters order) Former-commit-id: bcfb1caf15531d47653132153ad26cef59668c0e --- src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 936c32345..f81fd1c5b 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -121,8 +121,8 @@ namespace ImageProcessor.UnitTests var original = imageFactory.Image.Clone(); imageFactory.Constrain(new System.Drawing.Size(maxSize, maxSize)); Assert.AreNotEqual(original, imageFactory.Image); - Assert.LessOrEqual(maxSize, imageFactory.Image.Width); - Assert.LessOrEqual(maxSize, imageFactory.Image.Height); + Assert.LessOrEqual(imageFactory.Image.Width, maxSize); + Assert.LessOrEqual(imageFactory.Image.Height, maxSize); } } } From 91b5adbee502c8574a384fa345c59b50fd94879c Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 22:25:54 +0200 Subject: [PATCH 054/155] Re-fix of a Mono problem + modify some 'var' usage Former-commit-id: 1a96ba18689b8aa25607f3b699971f39c16132f9 --- src/ImageProcessor/ImageFactory.cs | 62 ++++++++++++++++-------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 540e34c9a..4a68a5e86 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -177,13 +177,13 @@ namespace ImageProcessor /// public ImageFactory Load(string imagePath) { - FileInfo fileInfo = new FileInfo(imagePath); + var fileInfo = new FileInfo(imagePath); if (fileInfo.Exists) { this.ImagePath = imagePath; // Open a file stream to prevent the need for lock. - using (FileStream fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) + using (var fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) { ISupportedImageFormat format = FormatUtilities.GetFormat(fileStream); @@ -192,7 +192,7 @@ namespace ImageProcessor throw new ImageFormatException("Input stream is not a supported format."); } - MemoryStream memoryStream = new MemoryStream(); + var memoryStream = new MemoryStream(); // Copy the stream. fileStream.CopyTo(memoryStream); @@ -240,7 +240,11 @@ namespace ImageProcessor if (this.ShouldProcess) { // Set our new image as the memory stream value. + #if !__MonoCS__ Image newImage = Image.FromStream(this.InputStream, true); + #else + Image newImage = Image.FromStream(this.InputStream); + #endif // Dispose and reassign the image. this.Image.Dispose(); @@ -275,7 +279,7 @@ namespace ImageProcessor percentage = 0; } - Alpha alpha = new Alpha { DynamicParameter = percentage }; + var alpha = new Alpha { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(alpha.ProcessImage, this); } @@ -293,7 +297,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - AutoRotate autoRotate = new AutoRotate(); + var autoRotate = new AutoRotate(); this.CurrentImageFormat.ApplyProcessor(autoRotate.ProcessImage, this); } @@ -320,7 +324,7 @@ namespace ImageProcessor percentage = 0; } - Brightness brightness = new Brightness { DynamicParameter = percentage }; + var brightness = new Brightness { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(brightness.ProcessImage, this); } @@ -340,7 +344,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - ResizeLayer layer = new ResizeLayer(size, ResizeMode.Max); + var layer = new ResizeLayer(size, ResizeMode.Max); return this.Resize(layer); } @@ -368,7 +372,7 @@ namespace ImageProcessor percentage = 0; } - Contrast contrast = new Contrast { DynamicParameter = percentage }; + var contrast = new Contrast { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(contrast.ProcessImage, this); } @@ -388,7 +392,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - CropLayer cropLayer = new CropLayer(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, CropMode.Pixels); + var cropLayer = new CropLayer(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, CropMode.Pixels); return this.Crop(cropLayer); } @@ -399,7 +403,7 @@ namespace ImageProcessor /// Crops the current image to the given location and size. /// /// - /// The containing the coordinates and mode to crop the image with. + /// The containing the coordinates and mode to crop the image with. /// /// /// The current instance of the class. @@ -408,7 +412,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - Crop crop = new Crop { DynamicParameter = cropLayer }; + var crop = new Crop { DynamicParameter = cropLayer }; this.CurrentImageFormat.ApplyProcessor(crop.ProcessImage, this); } @@ -429,7 +433,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - Filter filter = new Filter { DynamicParameter = matrixFilter }; + var filter = new Filter { DynamicParameter = matrixFilter }; this.CurrentImageFormat.ApplyProcessor(filter.ProcessImage, this); } @@ -449,11 +453,11 @@ namespace ImageProcessor { if (this.ShouldProcess) { - RotateFlipType rotateFlipType = flipVertically == false - ? RotateFlipType.RotateNoneFlipX - : RotateFlipType.RotateNoneFlipY; + RotateFlipType rotateFlipType = flipVertically + ? RotateFlipType.RotateNoneFlipY + : RotateFlipType.RotateNoneFlipX; - Flip flip = new Flip { DynamicParameter = rotateFlipType }; + var flip = new Flip { DynamicParameter = rotateFlipType }; this.CurrentImageFormat.ApplyProcessor(flip.ProcessImage, this); } @@ -496,7 +500,7 @@ namespace ImageProcessor { if (this.ShouldProcess && size > 0) { - GaussianLayer layer = new GaussianLayer(size); + var layer = new GaussianLayer(size); return this.GaussianBlur(layer); } @@ -517,7 +521,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - GaussianBlur gaussianBlur = new GaussianBlur { DynamicParameter = gaussianLayer }; + var gaussianBlur = new GaussianBlur { DynamicParameter = gaussianLayer }; this.CurrentImageFormat.ApplyProcessor(gaussianBlur.ProcessImage, this); } @@ -543,7 +547,7 @@ namespace ImageProcessor { if (this.ShouldProcess && size > 0) { - GaussianLayer layer = new GaussianLayer(size); + var layer = new GaussianLayer(size); return this.GaussianSharpen(layer); } @@ -564,7 +568,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - GaussianSharpen gaussianSharpen = new GaussianSharpen { DynamicParameter = gaussianLayer }; + var gaussianSharpen = new GaussianSharpen { DynamicParameter = gaussianLayer }; this.CurrentImageFormat.ApplyProcessor(gaussianSharpen.ProcessImage, this); } @@ -607,7 +611,7 @@ namespace ImageProcessor int width = size.Width; int height = size.Height; - ResizeLayer resizeLayer = new ResizeLayer(new Size(width, height)); + var resizeLayer = new ResizeLayer(new Size(width, height)); return this.Resize(resizeLayer); } @@ -629,7 +633,7 @@ namespace ImageProcessor { var resizeSettings = new Dictionary { { "MaxWidth", resizeLayer.Size.Width.ToString("G") }, { "MaxHeight", resizeLayer.Size.Height.ToString("G") } }; - Resize resize = new Resize { DynamicParameter = resizeLayer, Settings = resizeSettings }; + var resize = new Resize { DynamicParameter = resizeLayer, Settings = resizeSettings }; this.CurrentImageFormat.ApplyProcessor(resize.ProcessImage, this); } @@ -655,7 +659,7 @@ namespace ImageProcessor degrees = 0; } - Rotate rotate = new Rotate { DynamicParameter = degrees }; + var rotate = new Rotate { DynamicParameter = degrees }; this.CurrentImageFormat.ApplyProcessor(rotate.ProcessImage, this); } @@ -680,7 +684,7 @@ namespace ImageProcessor roundedCornerLayer.Radius = 0; } - RoundedCorners roundedCorners = new RoundedCorners { DynamicParameter = roundedCornerLayer }; + var roundedCorners = new RoundedCorners { DynamicParameter = roundedCornerLayer }; this.CurrentImageFormat.ApplyProcessor(roundedCorners.ProcessImage, this); } @@ -707,7 +711,7 @@ namespace ImageProcessor percentage = 0; } - Saturation saturate = new Saturation { DynamicParameter = percentage }; + var saturate = new Saturation { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(saturate.ProcessImage, this); } @@ -727,7 +731,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - Tint tint = new Tint { DynamicParameter = color }; + var tint = new Tint { DynamicParameter = color }; this.CurrentImageFormat.ApplyProcessor(tint.ProcessImage, this); } @@ -747,7 +751,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - Vignette vignette = new Vignette + var vignette = new Vignette { DynamicParameter = color.HasValue && !color.Equals(Color.Transparent) ? color.Value @@ -774,7 +778,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - Watermark watermark = new Watermark { DynamicParameter = textLayer }; + var watermark = new Watermark { DynamicParameter = textLayer }; this.CurrentImageFormat.ApplyProcessor(watermark.ProcessImage, this); } @@ -796,7 +800,7 @@ namespace ImageProcessor if (this.ShouldProcess) { // ReSharper disable once AssignNullToNotNullAttribute - DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(filePath)); + var directoryInfo = new DirectoryInfo(Path.GetDirectoryName(filePath)); if (!directoryInfo.Exists) { directoryInfo.Create(); From b28d2b94b0a6a47f42c021c80e6a8c4c7accb453 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 22:53:25 +0200 Subject: [PATCH 055/155] Adds a few more unit tests Former-commit-id: c782e8168d8b9b186cc0855e46bd0478019ec5d9 --- .../ImageFactoryUnitTests.cs | 122 +++++++++++++++++- 1 file changed, 119 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index f81fd1c5b..ac5de24a4 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -74,7 +74,7 @@ namespace ImageProcessor.UnitTests /// Tests that a filter is really applied by checking that the image is modified /// [Test] - public void ApplyEffectAlpha() + public void TestApplyEffectAlpha() { foreach (var fileName in ListInputFiles()) { @@ -92,7 +92,7 @@ namespace ImageProcessor.UnitTests /// Tests that a filter is really applied by checking that the image is modified /// [Test] - public void ApplyEffectBrightness() + public void TestApplyEffectBrightness() { foreach (var fileName in ListInputFiles()) { @@ -106,11 +106,85 @@ namespace ImageProcessor.UnitTests } } + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectContrast() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Contrast(50); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that all filters can be applied + /// + [Test] + public void TestApplyEffectFilter() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.BlackWhite); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Comic); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Gotham); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.GreyScale); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.HiSatch); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Invert); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Lomograph); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.LoSatch); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Polaroid); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Sepia); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + } + } + } + /// /// Tests that the image is well resized using constraints /// [Test] - public void ApplyConstraints() + public void TestResizeConstraints() { const int maxSize = 200; foreach (var fileName in ListInputFiles()) @@ -126,5 +200,47 @@ namespace ImageProcessor.UnitTests } } } + + /// + /// Tests that the image is well cropped + /// + [Test] + public void TestCrop() + { + const int maxSize = 20; + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Crop(new System.Drawing.Rectangle(0, 0, maxSize, maxSize)); + Assert.AreNotEqual(original, imageFactory.Image); + Assert.AreEqual(maxSize, imageFactory.Image.Width); + Assert.LessOrEqual(maxSize, imageFactory.Image.Height); + } + } + } + + /// + /// Tests that the image is well cropped + /// + [Test] + public void TestCropWithCropLayer() + { + const int maxSize = 20; + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Crop(new Imaging.CropLayer(0, 0, maxSize, maxSize, Imaging.CropMode.Pixels)); + Assert.AreNotEqual(original, imageFactory.Image); + Assert.AreEqual(maxSize, imageFactory.Image.Width); + Assert.LessOrEqual(maxSize, imageFactory.Image.Height); + } + } + } } } \ No newline at end of file From bfa25f7473c5c5ccad09f562fb3589aa3d0e18e4 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 23:11:58 +0200 Subject: [PATCH 056/155] Adds a few more unit tests Former-commit-id: bca6ad3548ecf57e56eb416dcfbfd002b725b733 --- .../ImageFactoryUnitTests.cs | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index ac5de24a4..7dd09e078 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -124,6 +124,42 @@ namespace ImageProcessor.UnitTests } } + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectBlur() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.GaussianBlur(5); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectBlurWithLayer() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.GaussianBlur(new Imaging.GaussianLayer() { Sigma = 10, Size = 5, Threshold = 2 }); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + /// /// Tests that all filters can be applied /// @@ -242,5 +278,31 @@ namespace ImageProcessor.UnitTests } } } + + /// + /// Tests that the image is flipped + /// + [Test] + public void TestFlip() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = (System.Drawing.Image)imageFactory.Image.Clone(); + imageFactory.Flip(true); + Assert.AreNotEqual(original, imageFactory.Image); + Assert.AreEqual(original.Width, imageFactory.Image.Width); + Assert.AreEqual(original.Height, imageFactory.Image.Height); + imageFactory.Reset(); + + imageFactory.Flip(false); + Assert.AreNotEqual(original, imageFactory.Image); + Assert.AreEqual(original.Width, imageFactory.Image.Width); + Assert.AreEqual(original.Height, imageFactory.Image.Height); + } + } + } } } \ No newline at end of file From f70dd8112fcfd8fb1cb8d2560c7af4045b48fe97 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 23:22:35 +0200 Subject: [PATCH 057/155] Adds a few more unit tests Former-commit-id: ccb39e91e174833342bf502d6f12dc75b149c0bf --- .../ImageFactoryUnitTests.cs | 82 ++++++++++++++++++- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 7dd09e078..60db9a8ee 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -154,7 +154,43 @@ namespace ImageProcessor.UnitTests { imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); - imageFactory.GaussianBlur(new Imaging.GaussianLayer() { Sigma = 10, Size = 5, Threshold = 2 }); + imageFactory.GaussianBlur(new Imaging.GaussianLayer { Sigma = 10, Size = 5, Threshold = 2 }); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectSharpen() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.GaussianSharpen(5); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectSharpenWithLayer() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.GaussianSharpen(new Imaging.GaussianLayer { Sigma = 10, Size = 5, Threshold = 2 }); Assert.AreNotEqual(original, imageFactory.Image); } } @@ -228,9 +264,7 @@ namespace ImageProcessor.UnitTests using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); imageFactory.Constrain(new System.Drawing.Size(maxSize, maxSize)); - Assert.AreNotEqual(original, imageFactory.Image); Assert.LessOrEqual(imageFactory.Image.Width, maxSize); Assert.LessOrEqual(imageFactory.Image.Height, maxSize); } @@ -304,5 +338,47 @@ namespace ImageProcessor.UnitTests } } } + + /// + /// Tests that the image is resized + /// + [Test] + public void TestResize() + { + const int newSize = 150; + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + imageFactory.Resize(new System.Drawing.Size(newSize, newSize)); + Assert.AreEqual(newSize, imageFactory.Image.Width); + Assert.AreEqual(newSize, imageFactory.Image.Height); + } + } + } + + /// + /// Tests that the image is resized + /// + [Test] + public void TestResizeWithLayer() + { + const int newSize = 150; + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + imageFactory.Resize(new Imaging.ResizeLayer( + new System.Drawing.Size(newSize, newSize), + Imaging.ResizeMode.Stretch, + Imaging.AnchorPosition.Left, + true)); + Assert.AreEqual(newSize, imageFactory.Image.Width); + Assert.AreEqual(newSize, imageFactory.Image.Height); + } + } + } } } \ No newline at end of file From 601c7b452196b192860f4b8d6ee42be5ea4e0d07 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 00:37:38 +0200 Subject: [PATCH 058/155] Yet a few other unit tests Former-commit-id: cfc586b9f02332ec65eaea1ba0c89b6b4be6b27e --- .../ImageFactoryUnitTests.cs | 182 ++++++++++++++---- 1 file changed, 146 insertions(+), 36 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 60db9a8ee..d868b2245 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -11,8 +11,8 @@ namespace ImageProcessor.UnitTests { using System; - using System.IO; using System.Collections.Generic; + using System.IO; using NUnit.Framework; /// @@ -21,15 +21,6 @@ namespace ImageProcessor.UnitTests [TestFixture] public class ImageFactoryUnitTests { - /// - /// Lists the input files in the Images folder - /// - /// The list of files. - private static IEnumerable ListInputFiles() - { - return Directory.GetFiles("./Images"); - } - /// /// Tests the loading of image from a file /// @@ -45,10 +36,9 @@ namespace ImageProcessor.UnitTests Assert.IsNotNull(imageFactory.Image); } } - } - /// > + /// /// Tests the loading of image from a memory stream /// [Test] @@ -124,6 +114,84 @@ namespace ImageProcessor.UnitTests } } + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectSaturation() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Saturation(50); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectTint() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Tint(System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.AliceBlue)); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectVignette() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Vignette(System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.AliceBlue)); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectWatermark() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Watermark(new Imaging.TextLayer + { + Font = "Arial", + FontSize = 10, + Position = new System.Drawing.Point(10, 10), + Text = "Lorem ipsum dolor" + }); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + /// /// Tests that a filter is really applied by checking that the image is modified /// @@ -252,21 +320,39 @@ namespace ImageProcessor.UnitTests } } + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestRoundedCorners() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.RoundedCorners(new Imaging.RoundedCornerLayer(5, true, true, true, true)); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + /// /// Tests that the image is well resized using constraints /// [Test] public void TestResizeConstraints() { - const int maxSize = 200; + const int MaxSize = 200; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); - imageFactory.Constrain(new System.Drawing.Size(maxSize, maxSize)); - Assert.LessOrEqual(imageFactory.Image.Width, maxSize); - Assert.LessOrEqual(imageFactory.Image.Height, maxSize); + imageFactory.Constrain(new System.Drawing.Size(MaxSize, MaxSize)); + Assert.LessOrEqual(imageFactory.Image.Width, MaxSize); + Assert.LessOrEqual(imageFactory.Image.Height, MaxSize); } } } @@ -277,17 +363,17 @@ namespace ImageProcessor.UnitTests [Test] public void TestCrop() { - const int maxSize = 20; + const int MaxSize = 20; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); - imageFactory.Crop(new System.Drawing.Rectangle(0, 0, maxSize, maxSize)); + imageFactory.Crop(new System.Drawing.Rectangle(0, 0, MaxSize, MaxSize)); Assert.AreNotEqual(original, imageFactory.Image); - Assert.AreEqual(maxSize, imageFactory.Image.Width); - Assert.LessOrEqual(maxSize, imageFactory.Image.Height); + Assert.AreEqual(MaxSize, imageFactory.Image.Width); + Assert.LessOrEqual(MaxSize, imageFactory.Image.Height); } } } @@ -298,17 +384,17 @@ namespace ImageProcessor.UnitTests [Test] public void TestCropWithCropLayer() { - const int maxSize = 20; + const int MaxSize = 20; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); - imageFactory.Crop(new Imaging.CropLayer(0, 0, maxSize, maxSize, Imaging.CropMode.Pixels)); + imageFactory.Crop(new Imaging.CropLayer(0, 0, MaxSize, MaxSize, Imaging.CropMode.Pixels)); Assert.AreNotEqual(original, imageFactory.Image); - Assert.AreEqual(maxSize, imageFactory.Image.Width); - Assert.LessOrEqual(maxSize, imageFactory.Image.Height); + Assert.AreEqual(MaxSize, imageFactory.Image.Width); + Assert.LessOrEqual(MaxSize, imageFactory.Image.Height); } } } @@ -345,15 +431,15 @@ namespace ImageProcessor.UnitTests [Test] public void TestResize() { - const int newSize = 150; + const int NewSize = 150; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); - imageFactory.Resize(new System.Drawing.Size(newSize, newSize)); - Assert.AreEqual(newSize, imageFactory.Image.Width); - Assert.AreEqual(newSize, imageFactory.Image.Height); + imageFactory.Resize(new System.Drawing.Size(NewSize, NewSize)); + Assert.AreEqual(NewSize, imageFactory.Image.Width); + Assert.AreEqual(NewSize, imageFactory.Image.Height); } } } @@ -364,21 +450,45 @@ namespace ImageProcessor.UnitTests [Test] public void TestResizeWithLayer() { - const int newSize = 150; + const int NewSize = 150; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); - imageFactory.Resize(new Imaging.ResizeLayer( - new System.Drawing.Size(newSize, newSize), - Imaging.ResizeMode.Stretch, - Imaging.AnchorPosition.Left, - true)); - Assert.AreEqual(newSize, imageFactory.Image.Width); - Assert.AreEqual(newSize, imageFactory.Image.Height); + imageFactory.Resize(new Imaging.ResizeLayer(new System.Drawing.Size(NewSize, NewSize), Imaging.ResizeMode.Stretch, Imaging.AnchorPosition.Left)); + Assert.AreEqual(NewSize, imageFactory.Image.Width); + Assert.AreEqual(NewSize, imageFactory.Image.Height); } } } + + /// + /// Tests that the image is resized + /// + [Test] + public void TestRotate() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = (System.Drawing.Image)imageFactory.Image.Clone(); + imageFactory.Rotate(90); + Assert.AreEqual(original.Height, imageFactory.Image.Width); + Assert.AreEqual(original.Width, imageFactory.Image.Height); + } + } + } + + /// + /// Lists the input files in the Images folder + /// + /// The list of files. + private static IEnumerable ListInputFiles() + { + return Directory.GetFiles("./Images"); + } } } \ No newline at end of file From ec4274928e42f648529c102d7550b80f502e2146 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 00:41:53 +0200 Subject: [PATCH 059/155] Adds tests for saving the files Former-commit-id: 7893eb70f8315cf13da030fde6a4a3c9884f59aa --- .../ImageFactoryUnitTests.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index d868b2245..880871cc7 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -60,6 +60,45 @@ namespace ImageProcessor.UnitTests } } + /// + /// Tests that the save method actually saves a file + /// + [Test] + public void TestSaveToDisk() + { + foreach (var fileName in ListInputFiles()) + { + var outputFileName = string.Format("./output/{0}", Path.GetFileName(fileName)); + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + imageFactory.Save(outputFileName); + Assert.AreEqual(true, File.Exists(outputFileName)); + } + } + } + + /// + /// Tests that the save method actually writes to memory + /// + [Test] + public void TestSaveToMemory() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + using (var s = new MemoryStream()) + { + imageFactory.Save(s); + s.Seek(0, SeekOrigin.Begin); + Assert.AreEqual(true, s.Capacity > 0); + } + } + } + } + /// /// Tests that a filter is really applied by checking that the image is modified /// From abdc216549afee230d47d28e91219d6a9d601421 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 11:09:25 +0200 Subject: [PATCH 060/155] Removes unnecessary images Former-commit-id: b7abba38c2ce512bdd6706af08fdabd25537f8b7 --- .../Images/Chrysanthemum.jpg.REMOVED.git-id | 1 - src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id | 1 - src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id | 1 - src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id | 1 - src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id | 1 - 5 files changed, 5 deletions(-) delete mode 100644 src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id delete mode 100644 src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id delete mode 100644 src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id delete mode 100644 src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id delete mode 100644 src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id diff --git a/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id deleted file mode 100644 index d067665c9..000000000 --- a/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -757c2a628dd03b1cbe4b3ef07c153897a702b57a \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id deleted file mode 100644 index 228aac3ab..000000000 --- a/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -0b88c91336ff8073f34d21ccd683a01f0e0995da \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id deleted file mode 100644 index 74f69293c..000000000 --- a/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -8150b46ab27c62ba51aaba551eef3f1a30f08de9 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id deleted file mode 100644 index ce873d473..000000000 --- a/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -6ad3b846d4697584ff601ac481b14a4d3bbb5736 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id deleted file mode 100644 index aeca7b93c..000000000 --- a/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -db4d55a332254cd6b41336c06f207682bf5a966f \ No newline at end of file From ee0317ddee99e9d6be7f5e9e478ca69dc79b3f0c Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 11:33:05 +0200 Subject: [PATCH 061/155] Filters the source images a bit, in order to speed up the unit tests + descriptive name Former-commit-id: eb53b2d6eef84df94cefa75642ac5be52af4e9e2 --- .../ImageProcessor.UnitTests.csproj | 132 ++++-------------- .../Images/autorotate.jpg.REMOVED.git-id | 1 + .../cmyk-profile-euroscale.jpg.REMOVED.git-id | 1 + .../Images/cmyk.jpg.REMOVED.git-id | 1 + .../color-vision-test.gif.REMOVED.git-id | 1 + .../Images/exif-Tulips.jpg.REMOVED.git-id | 1 + .../Images/exif-rocks.jpg.REMOVED.git-id | 1 + .../format-Penguins-8bit.png.REMOVED.git-id | 1 + .../Images/format-Penguins.bmp.REMOVED.git-id | 1 + .../Images/format-Penguins.gif.REMOVED.git-id | 1 + .../Images/format-Penguins.jpg.REMOVED.git-id | 1 + .../Images/format-Penguins.png.REMOVED.git-id | 1 + .../Images/format-Penguins.tif.REMOVED.git-id | 1 + .../Images/format-animated.gif | 3 + .../Images/hi-color.png | 3 + .../Images/hi-contrast.jpg | 3 + .../Images/hi-saturation.jpg | 3 + .../profile-adobe-rgb.jpg.REMOVED.git-id | 1 + .../Images/profile-srgb.jpg.REMOVED.git-id | 1 + .../Images/size-Penguins-200.jpg | 3 + .../Images/text-over-transparent.png | 3 + .../Images/udendørs.jpg.REMOVED.git-id | 1 + 22 files changed, 57 insertions(+), 108 deletions(-) create mode 100644 src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins.tif.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-animated.gif create mode 100644 src/ImageProcessor.UnitTests/Images/hi-color.png create mode 100644 src/ImageProcessor.UnitTests/Images/hi-contrast.jpg create mode 100644 src/ImageProcessor.UnitTests/Images/hi-saturation.jpg create mode 100644 src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg create mode 100644 src/ImageProcessor.UnitTests/Images/text-over-transparent.png create mode 100644 src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index 4bb9bf77f..726d0988e 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -58,114 +58,27 @@ - - Images\Chrysanthemum.jpg - PreserveNewest - - - Images\Desert.jpg - PreserveNewest - - - Images\Hydrangeas.jpg - PreserveNewest - - - Images\Jellyfish.jpg - PreserveNewest - - - Images\Koala.jpg - PreserveNewest - - - Images\Lighthouse.jpg - PreserveNewest - - - Images\Penguins-8.png - PreserveNewest - - - Images\Penguins.bmp - PreserveNewest - - - Images\Penguins.gif - PreserveNewest - - - Images\Penguins.jpg - PreserveNewest - - - Images\Penguins.png - PreserveNewest - - - Images\Penguins.tif - PreserveNewest - - - Images\Tulips.jpg - PreserveNewest - - - Images\bus.jpg - PreserveNewest - - - Images\cmyk.jpg - PreserveNewest - - - Images\cmyk.png - PreserveNewest - - - Images\jrt.jpg - PreserveNewest - - - Images\meter.gif - PreserveNewest - - - Images\rocks.jpg - PreserveNewest - - - Images\rotate.jpg - PreserveNewest - - - Images\sample1.jpg - PreserveNewest - - - Images\srgb.jpg - PreserveNewest - - - Images\srgb.png - PreserveNewest - - - Images\text.png - PreserveNewest - - - Images\thor.jpg - PreserveNewest - - - Images\udendørs-374.jpg - PreserveNewest - - - Images\udendørs.jpg - PreserveNewest - + + + + + + + + + + + + + + + + + + + + + @@ -175,4 +88,7 @@ + + + \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id new file mode 100644 index 000000000..19785c8e5 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id @@ -0,0 +1 @@ +85a8ae18f9955def2b42ba9240bce4de1bfe5781 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id new file mode 100644 index 000000000..7747bdaae --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id @@ -0,0 +1 @@ +13492524f9d984c12adfe6183a4c1d92fb11ec4e \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id new file mode 100644 index 000000000..30b05146b --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id @@ -0,0 +1 @@ +ed725726e4ac1ffeac821664af14865a66fa933f \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id new file mode 100644 index 000000000..5c4f4195d --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id @@ -0,0 +1 @@ +35a926115b13b61dc37308f8d903b42d14f92924 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id new file mode 100644 index 000000000..84b9aff85 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id @@ -0,0 +1 @@ +54c51eb6a86f31a42433b8167470fb18dad32c7d \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id new file mode 100644 index 000000000..41c6c25df --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id @@ -0,0 +1 @@ +33b6912af301bf216ee81d82b2c3ce6c49e03021 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id new file mode 100644 index 000000000..aa9a70e0f --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id @@ -0,0 +1 @@ +c3d556d9d486b8b8b49cdbcc9c12a9d3a2db4c1f \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id new file mode 100644 index 000000000..74f69293c --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id @@ -0,0 +1 @@ +8150b46ab27c62ba51aaba551eef3f1a30f08de9 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id new file mode 100644 index 000000000..ce873d473 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id @@ -0,0 +1 @@ +6ad3b846d4697584ff601ac481b14a4d3bbb5736 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id new file mode 100644 index 000000000..ad4371113 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id @@ -0,0 +1 @@ +030ab8a685bebb796c24cc710edd9e69859164f6 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id new file mode 100644 index 000000000..78062a0e7 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id @@ -0,0 +1 @@ +a2c796fbb7de948230a22982ab74892891dd5198 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.tif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.tif.REMOVED.git-id new file mode 100644 index 000000000..5f7b97e71 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.tif.REMOVED.git-id @@ -0,0 +1 @@ +c789aaec248568c24394b05c02db4233e0c5a4eb \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-animated.gif b/src/ImageProcessor.UnitTests/Images/format-animated.gif new file mode 100644 index 000000000..ac36f6f25 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-animated.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6212724b3e94908939823d0753b4307923b65d7a27f51823dd3ba7656543349c +size 22525 diff --git a/src/ImageProcessor.UnitTests/Images/hi-color.png b/src/ImageProcessor.UnitTests/Images/hi-color.png new file mode 100644 index 000000000..a9de4cc09 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/hi-color.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:977cc9071257655c9923d267ea5bd417b69754367c2f1aa8765247b68e2bb878 +size 1539 diff --git a/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg b/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg new file mode 100644 index 000000000..98ac863a2 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0ce9e02f2a4663a0a0ed433d5594be87b3fa0387bc8335e80f84d59c34aa424 +size 51058 diff --git a/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg b/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg new file mode 100644 index 000000000..b56f9a83c --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b2012b2eda13a531645c287c254ae5de0e9070368cb4bc806f48314e0464ccd +size 33850 diff --git a/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id new file mode 100644 index 000000000..4ffbf7a8a --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id @@ -0,0 +1 @@ +e29f32091aa13a5b047ccd960f3dc6da9656c84b \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id new file mode 100644 index 000000000..f409bc82b --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id @@ -0,0 +1 @@ +ab9deaa737f9db9bf0f563e7843ba9b7981cec86 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg b/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg new file mode 100644 index 000000000..07605996f --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:672de68017f17260126901065f1c6ade2b2981d33dea0dea1606bf7cfb6fdcf3 +size 10119 diff --git a/src/ImageProcessor.UnitTests/Images/text-over-transparent.png b/src/ImageProcessor.UnitTests/Images/text-over-transparent.png new file mode 100644 index 000000000..33d4962bc --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/text-over-transparent.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2322d8dd81df86b8135d399743ea758ad26d6b2ccdcc704e2687ae72d0c187e7 +size 7317 diff --git a/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id new file mode 100644 index 000000000..0db1445a2 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id @@ -0,0 +1 @@ +4d040d9aa3519b3d2303419d1f03eebebf88e956 \ No newline at end of file From 43ac2ffe50ef130398678621035bd57403c620ca Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 11:57:53 +0200 Subject: [PATCH 062/155] Fixes test image includes Former-commit-id: ece5f07535519335d8e992d5831440c9ed9600be --- .../ImageProcessor.UnitTests.csproj | 84 ++++++++++++++----- 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index 726d0988e..4fbcc99b6 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -43,7 +43,9 @@ - + + PreserveNewest + @@ -59,26 +61,66 @@ - - - - - - - - - - - - - - - - - - - - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + From 97a82afe84ef6a65dc8e9d712729779084e41a7b Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Wed, 25 Jun 2014 23:59:37 +0200 Subject: [PATCH 063/155] Creates a new Mono project so it can at least build (not yet run) on Xamarin/Mono Former-commit-id: 73972cac708c4e8958f0c40a99a86a0c9884eebb --- src/ImageProcessor_Mono.sln | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ImageProcessor_Mono.sln b/src/ImageProcessor_Mono.sln index 7d47a2ca6..d7e1410a8 100644 --- a/src/ImageProcessor_Mono.sln +++ b/src/ImageProcessor_Mono.sln @@ -18,6 +18,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E656C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor", "ImageProcessor\ImageProcessor.csproj", "{3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_MVC_NET4", "TestWebsites\NET4\Test_Website_MVC_NET4.csproj", "{30327C08-7574-4D7E-AC95-6A58753C6855}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET4", "ImageProcessor.Web\NET4\ImageProcessor.Web_NET4.csproj", "{4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET45", "ImageProcessor.Web\NET45\ImageProcessor.Web_NET45.csproj", "{D011A778-59C8-4BFA-A770-C350216BF161}" @@ -37,6 +39,24 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.ActiveCfg = All|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.Build.0 = All|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.ActiveCfg = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.Build.0 = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.ActiveCfg = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.Build.0 = All|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.ActiveCfg = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.Build.0 = Debug|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.Build.0 = Release|Any CPU + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.Build.0 = Release|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.ActiveCfg = Release|x86 + {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.Build.0 = Release|x86 {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU From ddd9be8d5daf2bf725c7980a006733e63b1d704f Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Thu, 26 Jun 2014 00:08:55 +0200 Subject: [PATCH 064/155] Removes MVC test project from Mono solution because of heavy dependencies Former-commit-id: c4a57569c8eec272ba8ea994022eb937ef6e4d8a --- src/ImageProcessor_Mono.sln | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/ImageProcessor_Mono.sln b/src/ImageProcessor_Mono.sln index d7e1410a8..7d47a2ca6 100644 --- a/src/ImageProcessor_Mono.sln +++ b/src/ImageProcessor_Mono.sln @@ -18,8 +18,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E656C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor", "ImageProcessor\ImageProcessor.csproj", "{3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_MVC_NET4", "TestWebsites\NET4\Test_Website_MVC_NET4.csproj", "{30327C08-7574-4D7E-AC95-6A58753C6855}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET4", "ImageProcessor.Web\NET4\ImageProcessor.Web_NET4.csproj", "{4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET45", "ImageProcessor.Web\NET45\ImageProcessor.Web_NET45.csproj", "{D011A778-59C8-4BFA-A770-C350216BF161}" @@ -39,24 +37,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.ActiveCfg = All|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.Build.0 = All|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.ActiveCfg = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.Build.0 = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.ActiveCfg = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.Build.0 = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.Build.0 = Debug|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.ActiveCfg = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.Build.0 = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.ActiveCfg = Release|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.Build.0 = Release|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.Build.0 = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.ActiveCfg = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.Build.0 = Release|x86 {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU From 049cd3cfc7711eef2223d48ad1bcd0b1dcaf183e Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 26 Jun 2014 22:30:08 +0100 Subject: [PATCH 065/155] Separating Unit Tests Hopefully rebuilding the projects will fix the AppVeyor issues. Former-commit-id: 61a12987b4f4c9324580f15b8f23b35c03876726 --- .../ImageProcessor.UnitTests.csproj | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index 81516b4b6..96dfb17a2 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -65,6 +65,9 @@ ImageProcessor + + + @@ -72,6 +75,136 @@ + + + Images\1182076_e8c402e938_z.jpg + + + Images\bus.jpg + + + Images\Chrysanthemum.jpg + + + Images\circle.png + + + Images\cmyk.jpg + + + Images\cmyk.png + + + Images\color-vision-test.gif + + + Images\Desert.jpg + + + Images\emma.jpg + + + Images\falahill_design__160p.jpg + + + Images\fid11246.jpg + + + Images\fid9141.jpg + + + Images\header_1.jpg + + + Images\Hydrangeas.jpg + + + Images\Jellyfish.jpg + + + Images\jrt.jpg + + + Images\Koala.jpg + + + Images\Lighthouse.jpg + + + Images\lomo.jpg + + + Images\meter.gif + + + Images\negative.png + + + Images\negative2.png + + + Images\Penguins-200.jpg + + + Images\Penguins-8.png + + + Images\Penguins.bmp + + + Images\Penguins.gif + + + Images\Penguins.jpg + + + Images\Penguins.png + + + Images\Penguins.tif + + + Images\rocks.jpg + + + Images\rotate.jpg + + + Images\sample1.jpg + + + Images\srgb.jpg + + + Images\srgb.png + + + Images\text.png + + + Images\thor.jpg + + + Images\Tulips.jpg + + + Images\udendørs-374.jpg + + + Images\udendørs.jpg + + + Images\war_horse_quad.jpg + + + Images\WP_000009.jpg + + + + + {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} + ImageProcessor + From 5c56a16eecf22a01894c156d02ef04cadd2f86c6 Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 26 Jun 2014 22:59:30 +0100 Subject: [PATCH 066/155] Moving Images in unit test Former-commit-id: 0448d1ccf9fad7e431636cbed45e6e7a3bf28cd2 --- .../ImageProcessor.UnitTests.csproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index 96dfb17a2..981d8ded5 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -206,6 +206,14 @@ ImageProcessor + + + + + + + + From 70251bea635c5629226f9d2442a9ebf1c91e3cde Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 15:42:31 +0200 Subject: [PATCH 067/155] Adds new test of factory for loading an image from a memory stream Former-commit-id: d97f8846fc92eaf59c5595b9af871b246bf71b9f --- .../ImageFactoryUnitTests.cs | 33 +++ .../ImageProcessor.UnitTests.csproj | 201 ++++++++++++------ src/ImageProcessor_Mono.sln | 26 ++- 3 files changed, 190 insertions(+), 70 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index a63f95ff2..1fc782073 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -51,5 +51,38 @@ namespace ImageProcessor.UnitTests Assert.IsNotNull(imageFactory.Image); } } + + /// > + /// Tests the loading of image from a memory stream + /// + /// + /// The file Name. + /// + /// + /// The expected mime type. + /// + [Test] + [TestCase("Chrysanthemum.jpg", "image/jpeg")] + [TestCase("Desert.jpg", "image/jpeg")] + [TestCase("cmyk.png", "image/png")] + [TestCase("Penguins.bmp", "image/bmp")] + [TestCase("Penguins.gif", "image/gif")] + public void TestLoadImageFromMemory(string fileName, string expectedMime) + { + string testPhoto = Path.Combine(this.localPath, string.Format("../../Images/{0}", fileName)); + byte[] photoBytes = File.ReadAllBytes(testPhoto); + + // ImageProcessor + using (MemoryStream inStream = new MemoryStream(photoBytes)) + { + using (ImageFactory imageFactory = new ImageFactory()) + { + imageFactory.Load(inStream); + Assert.AreEqual(null, imageFactory.ImagePath); + Assert.AreEqual(expectedMime, imageFactory.CurrentImageFormat.MimeType); + Assert.IsNotNull(imageFactory.Image); + } + } + } } } \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index 981d8ded5..111f5e03c 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -1,67 +1,58 @@  - + Debug AnyCPU - {633B1C4C-4823-47BE-9A01-A665F3118C8C} + {03CA9055-F997-428C-BF28-F50F991777C6} Library - Properties ImageProcessor.UnitTests ImageProcessor.UnitTests - v4.0 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest + + ..\ true - + v4.5 true full false - bin\Debug\ - DEBUG;TRACE + bin\Debug + DEBUG; prompt 4 + false + false - pdbonly + full true - bin\Release\ - TRACE + bin\Release prompt 4 + false + false + + ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - + + - - - - - - - - - - - - + + + {D011A778-59C8-4BFA-A770-C350216BF161} + ImageProcessor.Web_NET45 + - {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} + {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} ImageProcessor @@ -208,32 +199,121 @@ - - - - - + + + Images\Chrysanthemum.jpg + PreserveNewest + + + Images\Desert.jpg + PreserveNewest + + + Images\Hydrangeas.jpg + PreserveNewest + + + Images\Jellyfish.jpg + PreserveNewest + + + Images\Koala.jpg + PreserveNewest + + + Images\Lighthouse.jpg + PreserveNewest + + + Images\Penguins-200.jpg + PreserveNewest + + + Images\Penguins-8.png + PreserveNewest + + + Images\Penguins.bmp + PreserveNewest + + + Images\Penguins.gif + PreserveNewest + + + Images\Penguins.jpg + PreserveNewest + + + Images\Penguins.png + PreserveNewest + + + Images\Penguins.tif + PreserveNewest + + + Images\Tulips.jpg + PreserveNewest + + + Images\bus.jpg + PreserveNewest + + + Images\cmyk.jpg + PreserveNewest + + + Images\cmyk.png + PreserveNewest + + + Images\jrt.jpg + PreserveNewest + + + Images\meter.gif + PreserveNewest + + + Images\rocks.jpg + PreserveNewest + + + Images\rotate.jpg + PreserveNewest + + + Images\sample1.jpg + PreserveNewest + + + Images\srgb.jpg + PreserveNewest + + + Images\srgb.png + PreserveNewest + + + Images\text.png + PreserveNewest + + + Images\thor.jpg + PreserveNewest + + + Images\udendørs-374.jpg + PreserveNewest + + + Images\udendørs.jpg + PreserveNewest + - - - - - False - - - False - - - False - - - False - - - - - - + @@ -241,11 +321,4 @@ - \ No newline at end of file diff --git a/src/ImageProcessor_Mono.sln b/src/ImageProcessor_Mono.sln index 7d47a2ca6..8b1e0fb37 100644 --- a/src/ImageProcessor_Mono.sln +++ b/src/ImageProcessor_Mono.sln @@ -3,12 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 VisualStudioVersion = 12.0.30110.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C427A497-74DC-49B1-8420-D6E68354F29B}" - ProjectSection(SolutionItems) = preProject - ImageProcessor.vsmdi = ImageProcessor.vsmdi - Local.testsettings = Local.testsettings - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E656CDE-124D-4FAF-837C-0EF1E192D418}" ProjectSection(SolutionItems) = preProject .nuget\NuGet.Config = .nuget\NuGet.Config @@ -24,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET45", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessorConsole", "ImageProcessorConsole\ImageProcessorConsole.csproj", "{7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.UnitTests", "ImageProcessor.UnitTests\ImageProcessor.UnitTests.csproj", "{03CA9055-F997-428C-BF28-F50F991777C6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Any CPU = All|Any CPU @@ -37,6 +33,24 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {03CA9055-F997-428C-BF28-F50F991777C6}.All|Any CPU.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.All|Any CPU.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.All|Mixed Platforms.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.All|Mixed Platforms.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.All|x86.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.All|x86.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|x86.ActiveCfg = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Debug|x86.Build.0 = Debug|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Any CPU.Build.0 = Release|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|x86.ActiveCfg = Release|Any CPU + {03CA9055-F997-428C-BF28-F50F991777C6}.Release|x86.Build.0 = Release|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.ActiveCfg = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Any CPU.Build.0 = All|Any CPU {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}.All|Mixed Platforms.ActiveCfg = All|Any CPU From 96e8286c2ab2e5e84121c7383034b35efe2d31ce Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 18:03:26 +0200 Subject: [PATCH 068/155] Loads all the test images + tests a few filters as well (failing for gif images) Former-commit-id: a0aacc78aeb810580ff7c3e0979502c3f60c5cd3 --- .../ImageFactoryUnitTests.cs | 106 +++++++++++------- 1 file changed, 67 insertions(+), 39 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 1fc782073..7cd124b19 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -12,6 +12,7 @@ namespace ImageProcessor.UnitTests { using System; using System.IO; + using System.Collections.Generic; using NUnit.Framework; /// @@ -25,62 +26,89 @@ namespace ImageProcessor.UnitTests /// private readonly string localPath = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); + /// + /// Lists the input files in the Images folder + /// + /// The list of files. + private static IEnumerable ListInputFiles() + { + return Directory.GetFiles("./Images"); + } + /// /// Tests the loading of image from a file /// - /// - /// The file Name. - /// - /// - /// The expected mime type. - /// [Test] - [TestCase("Chrysanthemum.jpg", "image/jpeg")] - [TestCase("Desert.jpg", "image/jpeg")] - [TestCase("cmyk.png", "image/png")] - [TestCase("Penguins.bmp", "image/bmp")] - [TestCase("Penguins.gif", "image/gif")] - public void TestLoadImageFromFile(string fileName, string expectedMime) + public void TestLoadImageFromFile() { - string testPhoto = Path.Combine(this.localPath, string.Format("../../Images/{0}", fileName)); - using (ImageFactory imageFactory = new ImageFactory()) + foreach (var fileName in ListInputFiles()) { - imageFactory.Load(testPhoto); - Assert.AreEqual(testPhoto, imageFactory.ImagePath); - Assert.AreEqual(expectedMime, imageFactory.CurrentImageFormat.MimeType); - Assert.IsNotNull(imageFactory.Image); + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + Assert.AreEqual(fileName, imageFactory.ImagePath); + Assert.IsNotNull(imageFactory.Image); + } } + } /// > /// Tests the loading of image from a memory stream /// - /// - /// The file Name. - /// - /// - /// The expected mime type. - /// [Test] - [TestCase("Chrysanthemum.jpg", "image/jpeg")] - [TestCase("Desert.jpg", "image/jpeg")] - [TestCase("cmyk.png", "image/png")] - [TestCase("Penguins.bmp", "image/bmp")] - [TestCase("Penguins.gif", "image/gif")] - public void TestLoadImageFromMemory(string fileName, string expectedMime) + public void TestLoadImageFromMemory() { - string testPhoto = Path.Combine(this.localPath, string.Format("../../Images/{0}", fileName)); - byte[] photoBytes = File.ReadAllBytes(testPhoto); + foreach (var fileName in ListInputFiles()) + { + byte[] photoBytes = File.ReadAllBytes(fileName); - // ImageProcessor - using (MemoryStream inStream = new MemoryStream(photoBytes)) + using (var inStream = new MemoryStream(photoBytes)) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(inStream); + Assert.AreEqual(null, imageFactory.ImagePath); + Assert.IsNotNull(imageFactory.Image); + } + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void ApplyEffectAlpha() + { + foreach (var fileName in ListInputFiles()) { - using (ImageFactory imageFactory = new ImageFactory()) + using (var imageFactory = new ImageFactory()) { - imageFactory.Load(inStream); - Assert.AreEqual(null, imageFactory.ImagePath); - Assert.AreEqual(expectedMime, imageFactory.CurrentImageFormat.MimeType); - Assert.IsNotNull(imageFactory.Image); + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Alpha(50); + var modified = imageFactory.Image.Clone(); + Assert.AreNotEqual(original, modified); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void ApplyEffectBrightness() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Brightness(50); + var modified = imageFactory.Image.Clone(); + Assert.AreNotEqual(original, modified); } } } From 255184387557cd6a5fb301f267a750ed605d27d9 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 18:13:23 +0200 Subject: [PATCH 069/155] Adds test for constraints resize Former-commit-id: dca011a62587c43e6a59054c4949f09df14dbbf1 --- .../ImageFactoryUnitTests.cs | 24 +++++++++++++++---- .../ImageProcessor.UnitTests.csproj | 4 ---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 7cd124b19..b81cff068 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -21,11 +21,6 @@ namespace ImageProcessor.UnitTests [TestFixture] public class ImageFactoryUnitTests { - /// - /// The path to the binary's folder - /// - private readonly string localPath = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath); - /// /// Lists the input files in the Images folder /// @@ -112,5 +107,24 @@ namespace ImageProcessor.UnitTests } } } + + /// + /// Tests that the image is well resized using constraints + /// + [Test] + public void ApplyConstraints() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Constrain(new System.Drawing.Size(200, 200)); + var modified = imageFactory.Image.Clone(); + Assert.AreNotEqual(original, modified); + } + } + } } } \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index 111f5e03c..c0311d476 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -224,10 +224,6 @@ Images\Lighthouse.jpg PreserveNewest - - Images\Penguins-200.jpg - PreserveNewest - Images\Penguins-8.png PreserveNewest From 87daabb306517b4f2d572123cb71a0945443605c Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 18:16:34 +0200 Subject: [PATCH 070/155] Checks that the image is actually resized Former-commit-id: c13de5b788d5fbd4f2d2224ed575cd667c8af838 --- .../ImageFactoryUnitTests.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index b81cff068..936c32345 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -83,8 +83,7 @@ namespace ImageProcessor.UnitTests imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); imageFactory.Alpha(50); - var modified = imageFactory.Image.Clone(); - Assert.AreNotEqual(original, modified); + Assert.AreNotEqual(original, imageFactory.Image); } } } @@ -102,8 +101,7 @@ namespace ImageProcessor.UnitTests imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); imageFactory.Brightness(50); - var modified = imageFactory.Image.Clone(); - Assert.AreNotEqual(original, modified); + Assert.AreNotEqual(original, imageFactory.Image); } } } @@ -114,15 +112,17 @@ namespace ImageProcessor.UnitTests [Test] public void ApplyConstraints() { + const int maxSize = 200; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); - imageFactory.Constrain(new System.Drawing.Size(200, 200)); - var modified = imageFactory.Image.Clone(); - Assert.AreNotEqual(original, modified); + imageFactory.Constrain(new System.Drawing.Size(maxSize, maxSize)); + Assert.AreNotEqual(original, imageFactory.Image); + Assert.LessOrEqual(maxSize, imageFactory.Image.Width); + Assert.LessOrEqual(maxSize, imageFactory.Image.Height); } } } From f7261feed54d6fe558a1530d6ff94f886b6640f9 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 18:52:29 +0200 Subject: [PATCH 071/155] First fix of an animated gif problem on Mono Former-commit-id: 03c0f1246530ecead97e5346cebd197f77a72401 --- src/ImageProcessor/Imaging/Formats/FormatUtilities.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs index 36d2e3c07..3c6e3b3e0 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs @@ -135,12 +135,14 @@ namespace ImageProcessor.Imaging.Formats int frameCount = image.GetFrameCount(frameDimension); int last = frameCount - 1; int delay = 0; - int index = 0; List gifFrames = new List(); for (int i = 0; i < frameCount; i++) { - int thisDelay = BitConverter.ToInt32(image.GetPropertyItem(20736).Value, index); + // GDI returns a single array with all delays, while Mono returns a different array for each frame + image.SelectActiveFrame(frameDimension, i); + var times = image.GetPropertyItem(20736).Value; + int thisDelay = BitConverter.ToInt32(times, 4*i % times.Length); int toAddDelay = thisDelay * 10 < 20 ? 20 : thisDelay * 10; // Minimum delay is 20 ms // Find the frame @@ -156,7 +158,6 @@ namespace ImageProcessor.Imaging.Formats } delay += toAddDelay; - index += 4; } info.GifFrames = gifFrames; From be2cb5e7bbbeef2eefd7c408848793567e1c002e Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 20:48:03 +0200 Subject: [PATCH 072/155] Fixes a unit test (wrong parameters order) Former-commit-id: b691dc9582d00c8ef9b0160d69c59914a63ecb18 --- src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 936c32345..f81fd1c5b 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -121,8 +121,8 @@ namespace ImageProcessor.UnitTests var original = imageFactory.Image.Clone(); imageFactory.Constrain(new System.Drawing.Size(maxSize, maxSize)); Assert.AreNotEqual(original, imageFactory.Image); - Assert.LessOrEqual(maxSize, imageFactory.Image.Width); - Assert.LessOrEqual(maxSize, imageFactory.Image.Height); + Assert.LessOrEqual(imageFactory.Image.Width, maxSize); + Assert.LessOrEqual(imageFactory.Image.Height, maxSize); } } } From a019e0ffa5d3e06c20105043a9fa9b8b76963828 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 22:25:54 +0200 Subject: [PATCH 073/155] Re-fix of a Mono problem + modify some 'var' usage Former-commit-id: bbd7b29020665345032768961c448c64605620f9 --- src/ImageProcessor/ImageFactory.cs | 62 ++++++++++++++++-------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 540e34c9a..4a68a5e86 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -177,13 +177,13 @@ namespace ImageProcessor /// public ImageFactory Load(string imagePath) { - FileInfo fileInfo = new FileInfo(imagePath); + var fileInfo = new FileInfo(imagePath); if (fileInfo.Exists) { this.ImagePath = imagePath; // Open a file stream to prevent the need for lock. - using (FileStream fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) + using (var fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) { ISupportedImageFormat format = FormatUtilities.GetFormat(fileStream); @@ -192,7 +192,7 @@ namespace ImageProcessor throw new ImageFormatException("Input stream is not a supported format."); } - MemoryStream memoryStream = new MemoryStream(); + var memoryStream = new MemoryStream(); // Copy the stream. fileStream.CopyTo(memoryStream); @@ -240,7 +240,11 @@ namespace ImageProcessor if (this.ShouldProcess) { // Set our new image as the memory stream value. + #if !__MonoCS__ Image newImage = Image.FromStream(this.InputStream, true); + #else + Image newImage = Image.FromStream(this.InputStream); + #endif // Dispose and reassign the image. this.Image.Dispose(); @@ -275,7 +279,7 @@ namespace ImageProcessor percentage = 0; } - Alpha alpha = new Alpha { DynamicParameter = percentage }; + var alpha = new Alpha { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(alpha.ProcessImage, this); } @@ -293,7 +297,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - AutoRotate autoRotate = new AutoRotate(); + var autoRotate = new AutoRotate(); this.CurrentImageFormat.ApplyProcessor(autoRotate.ProcessImage, this); } @@ -320,7 +324,7 @@ namespace ImageProcessor percentage = 0; } - Brightness brightness = new Brightness { DynamicParameter = percentage }; + var brightness = new Brightness { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(brightness.ProcessImage, this); } @@ -340,7 +344,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - ResizeLayer layer = new ResizeLayer(size, ResizeMode.Max); + var layer = new ResizeLayer(size, ResizeMode.Max); return this.Resize(layer); } @@ -368,7 +372,7 @@ namespace ImageProcessor percentage = 0; } - Contrast contrast = new Contrast { DynamicParameter = percentage }; + var contrast = new Contrast { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(contrast.ProcessImage, this); } @@ -388,7 +392,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - CropLayer cropLayer = new CropLayer(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, CropMode.Pixels); + var cropLayer = new CropLayer(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, CropMode.Pixels); return this.Crop(cropLayer); } @@ -399,7 +403,7 @@ namespace ImageProcessor /// Crops the current image to the given location and size. /// /// - /// The containing the coordinates and mode to crop the image with. + /// The containing the coordinates and mode to crop the image with. /// /// /// The current instance of the class. @@ -408,7 +412,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - Crop crop = new Crop { DynamicParameter = cropLayer }; + var crop = new Crop { DynamicParameter = cropLayer }; this.CurrentImageFormat.ApplyProcessor(crop.ProcessImage, this); } @@ -429,7 +433,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - Filter filter = new Filter { DynamicParameter = matrixFilter }; + var filter = new Filter { DynamicParameter = matrixFilter }; this.CurrentImageFormat.ApplyProcessor(filter.ProcessImage, this); } @@ -449,11 +453,11 @@ namespace ImageProcessor { if (this.ShouldProcess) { - RotateFlipType rotateFlipType = flipVertically == false - ? RotateFlipType.RotateNoneFlipX - : RotateFlipType.RotateNoneFlipY; + RotateFlipType rotateFlipType = flipVertically + ? RotateFlipType.RotateNoneFlipY + : RotateFlipType.RotateNoneFlipX; - Flip flip = new Flip { DynamicParameter = rotateFlipType }; + var flip = new Flip { DynamicParameter = rotateFlipType }; this.CurrentImageFormat.ApplyProcessor(flip.ProcessImage, this); } @@ -496,7 +500,7 @@ namespace ImageProcessor { if (this.ShouldProcess && size > 0) { - GaussianLayer layer = new GaussianLayer(size); + var layer = new GaussianLayer(size); return this.GaussianBlur(layer); } @@ -517,7 +521,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - GaussianBlur gaussianBlur = new GaussianBlur { DynamicParameter = gaussianLayer }; + var gaussianBlur = new GaussianBlur { DynamicParameter = gaussianLayer }; this.CurrentImageFormat.ApplyProcessor(gaussianBlur.ProcessImage, this); } @@ -543,7 +547,7 @@ namespace ImageProcessor { if (this.ShouldProcess && size > 0) { - GaussianLayer layer = new GaussianLayer(size); + var layer = new GaussianLayer(size); return this.GaussianSharpen(layer); } @@ -564,7 +568,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - GaussianSharpen gaussianSharpen = new GaussianSharpen { DynamicParameter = gaussianLayer }; + var gaussianSharpen = new GaussianSharpen { DynamicParameter = gaussianLayer }; this.CurrentImageFormat.ApplyProcessor(gaussianSharpen.ProcessImage, this); } @@ -607,7 +611,7 @@ namespace ImageProcessor int width = size.Width; int height = size.Height; - ResizeLayer resizeLayer = new ResizeLayer(new Size(width, height)); + var resizeLayer = new ResizeLayer(new Size(width, height)); return this.Resize(resizeLayer); } @@ -629,7 +633,7 @@ namespace ImageProcessor { var resizeSettings = new Dictionary { { "MaxWidth", resizeLayer.Size.Width.ToString("G") }, { "MaxHeight", resizeLayer.Size.Height.ToString("G") } }; - Resize resize = new Resize { DynamicParameter = resizeLayer, Settings = resizeSettings }; + var resize = new Resize { DynamicParameter = resizeLayer, Settings = resizeSettings }; this.CurrentImageFormat.ApplyProcessor(resize.ProcessImage, this); } @@ -655,7 +659,7 @@ namespace ImageProcessor degrees = 0; } - Rotate rotate = new Rotate { DynamicParameter = degrees }; + var rotate = new Rotate { DynamicParameter = degrees }; this.CurrentImageFormat.ApplyProcessor(rotate.ProcessImage, this); } @@ -680,7 +684,7 @@ namespace ImageProcessor roundedCornerLayer.Radius = 0; } - RoundedCorners roundedCorners = new RoundedCorners { DynamicParameter = roundedCornerLayer }; + var roundedCorners = new RoundedCorners { DynamicParameter = roundedCornerLayer }; this.CurrentImageFormat.ApplyProcessor(roundedCorners.ProcessImage, this); } @@ -707,7 +711,7 @@ namespace ImageProcessor percentage = 0; } - Saturation saturate = new Saturation { DynamicParameter = percentage }; + var saturate = new Saturation { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(saturate.ProcessImage, this); } @@ -727,7 +731,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - Tint tint = new Tint { DynamicParameter = color }; + var tint = new Tint { DynamicParameter = color }; this.CurrentImageFormat.ApplyProcessor(tint.ProcessImage, this); } @@ -747,7 +751,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - Vignette vignette = new Vignette + var vignette = new Vignette { DynamicParameter = color.HasValue && !color.Equals(Color.Transparent) ? color.Value @@ -774,7 +778,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - Watermark watermark = new Watermark { DynamicParameter = textLayer }; + var watermark = new Watermark { DynamicParameter = textLayer }; this.CurrentImageFormat.ApplyProcessor(watermark.ProcessImage, this); } @@ -796,7 +800,7 @@ namespace ImageProcessor if (this.ShouldProcess) { // ReSharper disable once AssignNullToNotNullAttribute - DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(filePath)); + var directoryInfo = new DirectoryInfo(Path.GetDirectoryName(filePath)); if (!directoryInfo.Exists) { directoryInfo.Create(); From 7d18066d88a0588ddbf2ac9e79214e212235ff46 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 22:53:25 +0200 Subject: [PATCH 074/155] Adds a few more unit tests Former-commit-id: e7407d2bc753aac4bf9f3f0acf55d160149efb68 --- .../ImageFactoryUnitTests.cs | 122 +++++++++++++++++- 1 file changed, 119 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index f81fd1c5b..ac5de24a4 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -74,7 +74,7 @@ namespace ImageProcessor.UnitTests /// Tests that a filter is really applied by checking that the image is modified /// [Test] - public void ApplyEffectAlpha() + public void TestApplyEffectAlpha() { foreach (var fileName in ListInputFiles()) { @@ -92,7 +92,7 @@ namespace ImageProcessor.UnitTests /// Tests that a filter is really applied by checking that the image is modified /// [Test] - public void ApplyEffectBrightness() + public void TestApplyEffectBrightness() { foreach (var fileName in ListInputFiles()) { @@ -106,11 +106,85 @@ namespace ImageProcessor.UnitTests } } + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectContrast() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Contrast(50); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that all filters can be applied + /// + [Test] + public void TestApplyEffectFilter() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.BlackWhite); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Comic); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Gotham); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.GreyScale); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.HiSatch); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Invert); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Lomograph); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.LoSatch); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Polaroid); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + + imageFactory.Filter(Imaging.Filters.MatrixFilters.Sepia); + Assert.AreNotEqual(original, imageFactory.Image); + imageFactory.Reset(); + } + } + } + /// /// Tests that the image is well resized using constraints /// [Test] - public void ApplyConstraints() + public void TestResizeConstraints() { const int maxSize = 200; foreach (var fileName in ListInputFiles()) @@ -126,5 +200,47 @@ namespace ImageProcessor.UnitTests } } } + + /// + /// Tests that the image is well cropped + /// + [Test] + public void TestCrop() + { + const int maxSize = 20; + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Crop(new System.Drawing.Rectangle(0, 0, maxSize, maxSize)); + Assert.AreNotEqual(original, imageFactory.Image); + Assert.AreEqual(maxSize, imageFactory.Image.Width); + Assert.LessOrEqual(maxSize, imageFactory.Image.Height); + } + } + } + + /// + /// Tests that the image is well cropped + /// + [Test] + public void TestCropWithCropLayer() + { + const int maxSize = 20; + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Crop(new Imaging.CropLayer(0, 0, maxSize, maxSize, Imaging.CropMode.Pixels)); + Assert.AreNotEqual(original, imageFactory.Image); + Assert.AreEqual(maxSize, imageFactory.Image.Width); + Assert.LessOrEqual(maxSize, imageFactory.Image.Height); + } + } + } } } \ No newline at end of file From 6ef0c72eb81fb3711c01db02d2233d958112ccb6 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 23:11:58 +0200 Subject: [PATCH 075/155] Adds a few more unit tests Former-commit-id: dbb26885a48c55480ce771d885a46d7726af0576 --- .../ImageFactoryUnitTests.cs | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index ac5de24a4..7dd09e078 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -124,6 +124,42 @@ namespace ImageProcessor.UnitTests } } + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectBlur() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.GaussianBlur(5); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectBlurWithLayer() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.GaussianBlur(new Imaging.GaussianLayer() { Sigma = 10, Size = 5, Threshold = 2 }); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + /// /// Tests that all filters can be applied /// @@ -242,5 +278,31 @@ namespace ImageProcessor.UnitTests } } } + + /// + /// Tests that the image is flipped + /// + [Test] + public void TestFlip() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = (System.Drawing.Image)imageFactory.Image.Clone(); + imageFactory.Flip(true); + Assert.AreNotEqual(original, imageFactory.Image); + Assert.AreEqual(original.Width, imageFactory.Image.Width); + Assert.AreEqual(original.Height, imageFactory.Image.Height); + imageFactory.Reset(); + + imageFactory.Flip(false); + Assert.AreNotEqual(original, imageFactory.Image); + Assert.AreEqual(original.Width, imageFactory.Image.Width); + Assert.AreEqual(original.Height, imageFactory.Image.Height); + } + } + } } } \ No newline at end of file From 412ab93c47dc9afbf6cf2a93ca3c2adcdf84dadf Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 23:22:35 +0200 Subject: [PATCH 076/155] Adds a few more unit tests Former-commit-id: f0987ec15552263ee8b2915d25d51514b5db2c31 --- .../ImageFactoryUnitTests.cs | 82 ++++++++++++++++++- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 7dd09e078..60db9a8ee 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -154,7 +154,43 @@ namespace ImageProcessor.UnitTests { imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); - imageFactory.GaussianBlur(new Imaging.GaussianLayer() { Sigma = 10, Size = 5, Threshold = 2 }); + imageFactory.GaussianBlur(new Imaging.GaussianLayer { Sigma = 10, Size = 5, Threshold = 2 }); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectSharpen() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.GaussianSharpen(5); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectSharpenWithLayer() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.GaussianSharpen(new Imaging.GaussianLayer { Sigma = 10, Size = 5, Threshold = 2 }); Assert.AreNotEqual(original, imageFactory.Image); } } @@ -228,9 +264,7 @@ namespace ImageProcessor.UnitTests using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); imageFactory.Constrain(new System.Drawing.Size(maxSize, maxSize)); - Assert.AreNotEqual(original, imageFactory.Image); Assert.LessOrEqual(imageFactory.Image.Width, maxSize); Assert.LessOrEqual(imageFactory.Image.Height, maxSize); } @@ -304,5 +338,47 @@ namespace ImageProcessor.UnitTests } } } + + /// + /// Tests that the image is resized + /// + [Test] + public void TestResize() + { + const int newSize = 150; + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + imageFactory.Resize(new System.Drawing.Size(newSize, newSize)); + Assert.AreEqual(newSize, imageFactory.Image.Width); + Assert.AreEqual(newSize, imageFactory.Image.Height); + } + } + } + + /// + /// Tests that the image is resized + /// + [Test] + public void TestResizeWithLayer() + { + const int newSize = 150; + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + imageFactory.Resize(new Imaging.ResizeLayer( + new System.Drawing.Size(newSize, newSize), + Imaging.ResizeMode.Stretch, + Imaging.AnchorPosition.Left, + true)); + Assert.AreEqual(newSize, imageFactory.Image.Width); + Assert.AreEqual(newSize, imageFactory.Image.Height); + } + } + } } } \ No newline at end of file From 683d297dbf427b890063c1bd935794d70a496045 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 00:37:38 +0200 Subject: [PATCH 077/155] Yet a few other unit tests Former-commit-id: bd37755a47b8159d62b6eeb906fe8514ec51aad2 --- .../ImageFactoryUnitTests.cs | 182 ++++++++++++++---- 1 file changed, 146 insertions(+), 36 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 60db9a8ee..d868b2245 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -11,8 +11,8 @@ namespace ImageProcessor.UnitTests { using System; - using System.IO; using System.Collections.Generic; + using System.IO; using NUnit.Framework; /// @@ -21,15 +21,6 @@ namespace ImageProcessor.UnitTests [TestFixture] public class ImageFactoryUnitTests { - /// - /// Lists the input files in the Images folder - /// - /// The list of files. - private static IEnumerable ListInputFiles() - { - return Directory.GetFiles("./Images"); - } - /// /// Tests the loading of image from a file /// @@ -45,10 +36,9 @@ namespace ImageProcessor.UnitTests Assert.IsNotNull(imageFactory.Image); } } - } - /// > + /// /// Tests the loading of image from a memory stream /// [Test] @@ -124,6 +114,84 @@ namespace ImageProcessor.UnitTests } } + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectSaturation() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Saturation(50); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectTint() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Tint(System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.AliceBlue)); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectVignette() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Vignette(System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.AliceBlue)); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestApplyEffectWatermark() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.Watermark(new Imaging.TextLayer + { + Font = "Arial", + FontSize = 10, + Position = new System.Drawing.Point(10, 10), + Text = "Lorem ipsum dolor" + }); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + /// /// Tests that a filter is really applied by checking that the image is modified /// @@ -252,21 +320,39 @@ namespace ImageProcessor.UnitTests } } + /// + /// Tests that a filter is really applied by checking that the image is modified + /// + [Test] + public void TestRoundedCorners() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = imageFactory.Image.Clone(); + imageFactory.RoundedCorners(new Imaging.RoundedCornerLayer(5, true, true, true, true)); + Assert.AreNotEqual(original, imageFactory.Image); + } + } + } + /// /// Tests that the image is well resized using constraints /// [Test] public void TestResizeConstraints() { - const int maxSize = 200; + const int MaxSize = 200; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); - imageFactory.Constrain(new System.Drawing.Size(maxSize, maxSize)); - Assert.LessOrEqual(imageFactory.Image.Width, maxSize); - Assert.LessOrEqual(imageFactory.Image.Height, maxSize); + imageFactory.Constrain(new System.Drawing.Size(MaxSize, MaxSize)); + Assert.LessOrEqual(imageFactory.Image.Width, MaxSize); + Assert.LessOrEqual(imageFactory.Image.Height, MaxSize); } } } @@ -277,17 +363,17 @@ namespace ImageProcessor.UnitTests [Test] public void TestCrop() { - const int maxSize = 20; + const int MaxSize = 20; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); - imageFactory.Crop(new System.Drawing.Rectangle(0, 0, maxSize, maxSize)); + imageFactory.Crop(new System.Drawing.Rectangle(0, 0, MaxSize, MaxSize)); Assert.AreNotEqual(original, imageFactory.Image); - Assert.AreEqual(maxSize, imageFactory.Image.Width); - Assert.LessOrEqual(maxSize, imageFactory.Image.Height); + Assert.AreEqual(MaxSize, imageFactory.Image.Width); + Assert.LessOrEqual(MaxSize, imageFactory.Image.Height); } } } @@ -298,17 +384,17 @@ namespace ImageProcessor.UnitTests [Test] public void TestCropWithCropLayer() { - const int maxSize = 20; + const int MaxSize = 20; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); var original = imageFactory.Image.Clone(); - imageFactory.Crop(new Imaging.CropLayer(0, 0, maxSize, maxSize, Imaging.CropMode.Pixels)); + imageFactory.Crop(new Imaging.CropLayer(0, 0, MaxSize, MaxSize, Imaging.CropMode.Pixels)); Assert.AreNotEqual(original, imageFactory.Image); - Assert.AreEqual(maxSize, imageFactory.Image.Width); - Assert.LessOrEqual(maxSize, imageFactory.Image.Height); + Assert.AreEqual(MaxSize, imageFactory.Image.Width); + Assert.LessOrEqual(MaxSize, imageFactory.Image.Height); } } } @@ -345,15 +431,15 @@ namespace ImageProcessor.UnitTests [Test] public void TestResize() { - const int newSize = 150; + const int NewSize = 150; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); - imageFactory.Resize(new System.Drawing.Size(newSize, newSize)); - Assert.AreEqual(newSize, imageFactory.Image.Width); - Assert.AreEqual(newSize, imageFactory.Image.Height); + imageFactory.Resize(new System.Drawing.Size(NewSize, NewSize)); + Assert.AreEqual(NewSize, imageFactory.Image.Width); + Assert.AreEqual(NewSize, imageFactory.Image.Height); } } } @@ -364,21 +450,45 @@ namespace ImageProcessor.UnitTests [Test] public void TestResizeWithLayer() { - const int newSize = 150; + const int NewSize = 150; foreach (var fileName in ListInputFiles()) { using (var imageFactory = new ImageFactory()) { imageFactory.Load(fileName); - imageFactory.Resize(new Imaging.ResizeLayer( - new System.Drawing.Size(newSize, newSize), - Imaging.ResizeMode.Stretch, - Imaging.AnchorPosition.Left, - true)); - Assert.AreEqual(newSize, imageFactory.Image.Width); - Assert.AreEqual(newSize, imageFactory.Image.Height); + imageFactory.Resize(new Imaging.ResizeLayer(new System.Drawing.Size(NewSize, NewSize), Imaging.ResizeMode.Stretch, Imaging.AnchorPosition.Left)); + Assert.AreEqual(NewSize, imageFactory.Image.Width); + Assert.AreEqual(NewSize, imageFactory.Image.Height); } } } + + /// + /// Tests that the image is resized + /// + [Test] + public void TestRotate() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + var original = (System.Drawing.Image)imageFactory.Image.Clone(); + imageFactory.Rotate(90); + Assert.AreEqual(original.Height, imageFactory.Image.Width); + Assert.AreEqual(original.Width, imageFactory.Image.Height); + } + } + } + + /// + /// Lists the input files in the Images folder + /// + /// The list of files. + private static IEnumerable ListInputFiles() + { + return Directory.GetFiles("./Images"); + } } } \ No newline at end of file From 892818bcfc0caa850f9e4999c59e6c126d577d55 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 00:41:53 +0200 Subject: [PATCH 078/155] Adds tests for saving the files Former-commit-id: bab7f1273663d36a546e323f680cac1d7c622284 --- .../ImageFactoryUnitTests.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index d868b2245..880871cc7 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -60,6 +60,45 @@ namespace ImageProcessor.UnitTests } } + /// + /// Tests that the save method actually saves a file + /// + [Test] + public void TestSaveToDisk() + { + foreach (var fileName in ListInputFiles()) + { + var outputFileName = string.Format("./output/{0}", Path.GetFileName(fileName)); + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + imageFactory.Save(outputFileName); + Assert.AreEqual(true, File.Exists(outputFileName)); + } + } + } + + /// + /// Tests that the save method actually writes to memory + /// + [Test] + public void TestSaveToMemory() + { + foreach (var fileName in ListInputFiles()) + { + using (var imageFactory = new ImageFactory()) + { + imageFactory.Load(fileName); + using (var s = new MemoryStream()) + { + imageFactory.Save(s); + s.Seek(0, SeekOrigin.Begin); + Assert.AreEqual(true, s.Capacity > 0); + } + } + } + } + /// /// Tests that a filter is really applied by checking that the image is modified /// From c516908062ff743f4b4a2c9b6f820bb73ddc4283 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 11:09:25 +0200 Subject: [PATCH 079/155] Removes unnecessary images Former-commit-id: 2b75ccda89d49667260a2d21b0c5ea7754107f3a --- .../Images/Chrysanthemum.jpg.REMOVED.git-id | 1 - src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id | 1 - src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id | 1 - src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id | 1 - src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id | 1 - 5 files changed, 5 deletions(-) delete mode 100644 src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id delete mode 100644 src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id delete mode 100644 src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id delete mode 100644 src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id delete mode 100644 src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id diff --git a/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id deleted file mode 100644 index d067665c9..000000000 --- a/src/ImageProcessor.UnitTests/Images/Chrysanthemum.jpg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -757c2a628dd03b1cbe4b3ef07c153897a702b57a \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id deleted file mode 100644 index 228aac3ab..000000000 --- a/src/ImageProcessor.UnitTests/Images/Desert.jpg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -0b88c91336ff8073f34d21ccd683a01f0e0995da \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id deleted file mode 100644 index 74f69293c..000000000 --- a/src/ImageProcessor.UnitTests/Images/Penguins.bmp.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -8150b46ab27c62ba51aaba551eef3f1a30f08de9 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id deleted file mode 100644 index ce873d473..000000000 --- a/src/ImageProcessor.UnitTests/Images/Penguins.gif.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -6ad3b846d4697584ff601ac481b14a4d3bbb5736 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id deleted file mode 100644 index aeca7b93c..000000000 --- a/src/ImageProcessor.UnitTests/Images/cmyk.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -db4d55a332254cd6b41336c06f207682bf5a966f \ No newline at end of file From 3ff7de32ffd718496bdddc3cdb5b801ead3277ab Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 11:33:05 +0200 Subject: [PATCH 080/155] Filters the source images a bit, in order to speed up the unit tests + descriptive name Former-commit-id: bcdb5097fee49ef671a3150815e1a7b4f11721fd --- .../ImageProcessor.UnitTests.csproj | 24 +++++++++++++++++++ .../Images/autorotate.jpg.REMOVED.git-id | 1 + .../cmyk-profile-euroscale.jpg.REMOVED.git-id | 1 + .../Images/cmyk.jpg.REMOVED.git-id | 1 + .../color-vision-test.gif.REMOVED.git-id | 1 + .../Images/exif-Tulips.jpg.REMOVED.git-id | 1 + .../Images/exif-rocks.jpg.REMOVED.git-id | 1 + .../format-Penguins-8bit.png.REMOVED.git-id | 1 + .../Images/format-Penguins.bmp.REMOVED.git-id | 1 + .../Images/format-Penguins.gif.REMOVED.git-id | 1 + .../Images/format-Penguins.jpg.REMOVED.git-id | 1 + .../Images/format-Penguins.png.REMOVED.git-id | 1 + .../Images/format-Penguins.tif.REMOVED.git-id | 1 + .../Images/format-animated.gif | 3 +++ .../Images/hi-color.png | 3 +++ .../Images/hi-contrast.jpg | 3 +++ .../Images/hi-saturation.jpg | 3 +++ .../profile-adobe-rgb.jpg.REMOVED.git-id | 1 + .../Images/profile-srgb.jpg.REMOVED.git-id | 1 + .../Images/size-Penguins-200.jpg | 3 +++ .../Images/text-over-transparent.png | 3 +++ .../Images/udendørs.jpg.REMOVED.git-id | 1 + 22 files changed, 57 insertions(+) create mode 100644 src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-Penguins.tif.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/format-animated.gif create mode 100644 src/ImageProcessor.UnitTests/Images/hi-color.png create mode 100644 src/ImageProcessor.UnitTests/Images/hi-contrast.jpg create mode 100644 src/ImageProcessor.UnitTests/Images/hi-saturation.jpg create mode 100644 src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg create mode 100644 src/ImageProcessor.UnitTests/Images/text-over-transparent.png create mode 100644 src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index c0311d476..4d47bb062 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -308,6 +308,27 @@ Images\udendørs.jpg PreserveNewest + + + + + + + + + + + + + + + + + + + + + @@ -317,4 +338,7 @@ + + + \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id new file mode 100644 index 000000000..19785c8e5 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id @@ -0,0 +1 @@ +85a8ae18f9955def2b42ba9240bce4de1bfe5781 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id new file mode 100644 index 000000000..7747bdaae --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id @@ -0,0 +1 @@ +13492524f9d984c12adfe6183a4c1d92fb11ec4e \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id new file mode 100644 index 000000000..30b05146b --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id @@ -0,0 +1 @@ +ed725726e4ac1ffeac821664af14865a66fa933f \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id new file mode 100644 index 000000000..5c4f4195d --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id @@ -0,0 +1 @@ +35a926115b13b61dc37308f8d903b42d14f92924 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id new file mode 100644 index 000000000..84b9aff85 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id @@ -0,0 +1 @@ +54c51eb6a86f31a42433b8167470fb18dad32c7d \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id new file mode 100644 index 000000000..41c6c25df --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id @@ -0,0 +1 @@ +33b6912af301bf216ee81d82b2c3ce6c49e03021 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id new file mode 100644 index 000000000..aa9a70e0f --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id @@ -0,0 +1 @@ +c3d556d9d486b8b8b49cdbcc9c12a9d3a2db4c1f \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id new file mode 100644 index 000000000..74f69293c --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id @@ -0,0 +1 @@ +8150b46ab27c62ba51aaba551eef3f1a30f08de9 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id new file mode 100644 index 000000000..ce873d473 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id @@ -0,0 +1 @@ +6ad3b846d4697584ff601ac481b14a4d3bbb5736 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id new file mode 100644 index 000000000..ad4371113 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id @@ -0,0 +1 @@ +030ab8a685bebb796c24cc710edd9e69859164f6 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id new file mode 100644 index 000000000..78062a0e7 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id @@ -0,0 +1 @@ +a2c796fbb7de948230a22982ab74892891dd5198 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.tif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.tif.REMOVED.git-id new file mode 100644 index 000000000..5f7b97e71 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.tif.REMOVED.git-id @@ -0,0 +1 @@ +c789aaec248568c24394b05c02db4233e0c5a4eb \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-animated.gif b/src/ImageProcessor.UnitTests/Images/format-animated.gif new file mode 100644 index 000000000..ac36f6f25 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-animated.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6212724b3e94908939823d0753b4307923b65d7a27f51823dd3ba7656543349c +size 22525 diff --git a/src/ImageProcessor.UnitTests/Images/hi-color.png b/src/ImageProcessor.UnitTests/Images/hi-color.png new file mode 100644 index 000000000..a9de4cc09 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/hi-color.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:977cc9071257655c9923d267ea5bd417b69754367c2f1aa8765247b68e2bb878 +size 1539 diff --git a/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg b/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg new file mode 100644 index 000000000..98ac863a2 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0ce9e02f2a4663a0a0ed433d5594be87b3fa0387bc8335e80f84d59c34aa424 +size 51058 diff --git a/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg b/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg new file mode 100644 index 000000000..b56f9a83c --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b2012b2eda13a531645c287c254ae5de0e9070368cb4bc806f48314e0464ccd +size 33850 diff --git a/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id new file mode 100644 index 000000000..4ffbf7a8a --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id @@ -0,0 +1 @@ +e29f32091aa13a5b047ccd960f3dc6da9656c84b \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id new file mode 100644 index 000000000..f409bc82b --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id @@ -0,0 +1 @@ +ab9deaa737f9db9bf0f563e7843ba9b7981cec86 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg b/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg new file mode 100644 index 000000000..07605996f --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:672de68017f17260126901065f1c6ade2b2981d33dea0dea1606bf7cfb6fdcf3 +size 10119 diff --git a/src/ImageProcessor.UnitTests/Images/text-over-transparent.png b/src/ImageProcessor.UnitTests/Images/text-over-transparent.png new file mode 100644 index 000000000..33d4962bc --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/text-over-transparent.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2322d8dd81df86b8135d399743ea758ad26d6b2ccdcc704e2687ae72d0c187e7 +size 7317 diff --git a/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id new file mode 100644 index 000000000..0db1445a2 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id @@ -0,0 +1 @@ +4d040d9aa3519b3d2303419d1f03eebebf88e956 \ No newline at end of file From 3ff3807e15c539590b1f76de863805ec0826f393 Mon Sep 17 00:00:00 2001 From: James South Date: Sun, 29 Jun 2014 11:53:20 +0100 Subject: [PATCH 081/155] Fixing tests to work on Windows. Former-commit-id: 23664e1cac0916c0cc493769b7f9ebe0de78e981 --- build/Build.bat | 2 +- .../ImageFactoryUnitTests.cs | 248 ++++++++++-------- .../ImageProcessor.UnitTests.csproj | 6 +- src/ImageProcessor/ImageFactory.cs | 4 +- .../Imaging/Formats/FormatUtilities.cs | 2 +- 5 files changed, 147 insertions(+), 115 deletions(-) diff --git a/build/Build.bat b/build/Build.bat index 513d111e3..21c4eb0a4 100644 --- a/build/Build.bat +++ b/build/Build.bat @@ -20,7 +20,7 @@ ECHO Packing the NuGet release files ..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.nuspec -Version %version% ..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.Web.nuspec -Version %webversion% ..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.Web.Config.nuspec -Version %webconfigversion% - +PAUSE IF ERRORLEVEL 1 GOTO :showerror diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index 880871cc7..c5f569a39 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -12,7 +12,9 @@ namespace ImageProcessor.UnitTests { using System; using System.Collections.Generic; + using System.Drawing; using System.IO; + using System.Linq; using NUnit.Framework; /// @@ -21,18 +23,23 @@ namespace ImageProcessor.UnitTests [TestFixture] public class ImageFactoryUnitTests { + /// + /// The list of images. Designed to speed up the tests a little. + /// + private IEnumerable images; + /// /// Tests the loading of image from a file /// [Test] public void TestLoadImageFromFile() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - Assert.AreEqual(fileName, imageFactory.ImagePath); + imageFactory.Load(file.FullName); + Assert.AreEqual(file.FullName, imageFactory.ImagePath); Assert.IsNotNull(imageFactory.Image); } } @@ -44,13 +51,13 @@ namespace ImageProcessor.UnitTests [Test] public void TestLoadImageFromMemory() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - byte[] photoBytes = File.ReadAllBytes(fileName); + byte[] photoBytes = File.ReadAllBytes(file.FullName); - using (var inStream = new MemoryStream(photoBytes)) + using (MemoryStream inStream = new MemoryStream(photoBytes)) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { imageFactory.Load(inStream); Assert.AreEqual(null, imageFactory.ImagePath); @@ -66,12 +73,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestSaveToDisk() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - var outputFileName = string.Format("./output/{0}", Path.GetFileName(fileName)); - using (var imageFactory = new ImageFactory()) + string outputFileName = string.Format("./output/{0}", file.Name); + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); + imageFactory.Load(file.FullName); imageFactory.Save(outputFileName); Assert.AreEqual(true, File.Exists(outputFileName)); } @@ -84,12 +91,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestSaveToMemory() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - using (var s = new MemoryStream()) + imageFactory.Load(file.FullName); + using (MemoryStream s = new MemoryStream()) { imageFactory.Save(s); s.Seek(0, SeekOrigin.Begin); @@ -105,12 +112,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectAlpha() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.Alpha(50); Assert.AreNotEqual(original, imageFactory.Image); } @@ -123,12 +130,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectBrightness() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.Brightness(50); Assert.AreNotEqual(original, imageFactory.Image); } @@ -141,12 +148,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectContrast() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.Contrast(50); Assert.AreNotEqual(original, imageFactory.Image); } @@ -159,12 +166,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectSaturation() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.Saturation(50); Assert.AreNotEqual(original, imageFactory.Image); } @@ -177,13 +184,13 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectTint() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); - imageFactory.Tint(System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.AliceBlue)); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); + imageFactory.Tint(Color.FromKnownColor(KnownColor.AliceBlue)); Assert.AreNotEqual(original, imageFactory.Image); } } @@ -195,13 +202,13 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectVignette() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); - imageFactory.Vignette(System.Drawing.Color.FromKnownColor(System.Drawing.KnownColor.AliceBlue)); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); + imageFactory.Vignette(Color.FromKnownColor(KnownColor.AliceBlue)); Assert.AreNotEqual(original, imageFactory.Image); } } @@ -213,19 +220,19 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectWatermark() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.Watermark(new Imaging.TextLayer - { - Font = "Arial", - FontSize = 10, - Position = new System.Drawing.Point(10, 10), - Text = "Lorem ipsum dolor" - }); + { + Font = "Arial", + FontSize = 10, + Position = new Point(10, 10), + Text = "Lorem ipsum dolor" + }); Assert.AreNotEqual(original, imageFactory.Image); } } @@ -237,12 +244,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectBlur() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.GaussianBlur(5); Assert.AreNotEqual(original, imageFactory.Image); } @@ -255,12 +262,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectBlurWithLayer() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.GaussianBlur(new Imaging.GaussianLayer { Sigma = 10, Size = 5, Threshold = 2 }); Assert.AreNotEqual(original, imageFactory.Image); } @@ -273,12 +280,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectSharpen() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.GaussianSharpen(5); Assert.AreNotEqual(original, imageFactory.Image); } @@ -291,12 +298,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectSharpenWithLayer() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.GaussianSharpen(new Imaging.GaussianLayer { Sigma = 10, Size = 5, Threshold = 2 }); Assert.AreNotEqual(original, imageFactory.Image); } @@ -309,12 +316,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestApplyEffectFilter() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.Filter(Imaging.Filters.MatrixFilters.BlackWhite); Assert.AreNotEqual(original, imageFactory.Image); @@ -365,12 +372,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestRoundedCorners() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.RoundedCorners(new Imaging.RoundedCornerLayer(5, true, true, true, true)); Assert.AreNotEqual(original, imageFactory.Image); } @@ -384,12 +391,12 @@ namespace ImageProcessor.UnitTests public void TestResizeConstraints() { const int MaxSize = 200; - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - imageFactory.Constrain(new System.Drawing.Size(MaxSize, MaxSize)); + imageFactory.Load(file.FullName); + imageFactory.Constrain(new Size(MaxSize, MaxSize)); Assert.LessOrEqual(imageFactory.Image.Width, MaxSize); Assert.LessOrEqual(imageFactory.Image.Height, MaxSize); } @@ -403,13 +410,13 @@ namespace ImageProcessor.UnitTests public void TestCrop() { const int MaxSize = 20; - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); - imageFactory.Crop(new System.Drawing.Rectangle(0, 0, MaxSize, MaxSize)); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); + imageFactory.Crop(new Rectangle(0, 0, MaxSize, MaxSize)); Assert.AreNotEqual(original, imageFactory.Image); Assert.AreEqual(MaxSize, imageFactory.Image.Width); Assert.LessOrEqual(MaxSize, imageFactory.Image.Height); @@ -424,12 +431,12 @@ namespace ImageProcessor.UnitTests public void TestCropWithCropLayer() { const int MaxSize = 20; - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.Crop(new Imaging.CropLayer(0, 0, MaxSize, MaxSize, Imaging.CropMode.Pixels)); Assert.AreNotEqual(original, imageFactory.Image); Assert.AreEqual(MaxSize, imageFactory.Image.Width); @@ -444,12 +451,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestFlip() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = (System.Drawing.Image)imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.Flip(true); Assert.AreNotEqual(original, imageFactory.Image); Assert.AreEqual(original.Width, imageFactory.Image.Width); @@ -471,12 +478,12 @@ namespace ImageProcessor.UnitTests public void TestResize() { const int NewSize = 150; - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - imageFactory.Resize(new System.Drawing.Size(NewSize, NewSize)); + imageFactory.Load(file.FullName); + imageFactory.Resize(new Size(NewSize, NewSize)); Assert.AreEqual(NewSize, imageFactory.Image.Width); Assert.AreEqual(NewSize, imageFactory.Image.Height); } @@ -490,12 +497,12 @@ namespace ImageProcessor.UnitTests public void TestResizeWithLayer() { const int NewSize = 150; - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - imageFactory.Resize(new Imaging.ResizeLayer(new System.Drawing.Size(NewSize, NewSize), Imaging.ResizeMode.Stretch, Imaging.AnchorPosition.Left)); + imageFactory.Load(file.FullName); + imageFactory.Resize(new Imaging.ResizeLayer(new Size(NewSize, NewSize), Imaging.ResizeMode.Stretch, Imaging.AnchorPosition.Left)); Assert.AreEqual(NewSize, imageFactory.Image.Width); Assert.AreEqual(NewSize, imageFactory.Image.Height); } @@ -508,12 +515,12 @@ namespace ImageProcessor.UnitTests [Test] public void TestRotate() { - foreach (var fileName in ListInputFiles()) + foreach (FileInfo file in this.ListInputFiles()) { - using (var imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory()) { - imageFactory.Load(fileName); - var original = (System.Drawing.Image)imageFactory.Image.Clone(); + imageFactory.Load(file.FullName); + Image original = (Image)imageFactory.Image.Clone(); imageFactory.Rotate(90); Assert.AreEqual(original.Height, imageFactory.Image.Width); Assert.AreEqual(original.Width, imageFactory.Image.Height); @@ -521,13 +528,40 @@ namespace ImageProcessor.UnitTests } } + /// + /// Gets the files matching the given extensions. + /// + /// The . + /// The extensions. + /// A collection of + /// The extensions variable is null. + private static IEnumerable GetFilesByExtensions(DirectoryInfo dir, params string[] extensions) + { + if (extensions == null) + { + throw new ArgumentNullException("extensions"); + } + + IEnumerable files = dir.EnumerateFiles(); + return files.Where(f => extensions.Contains(f.Extension, StringComparer.OrdinalIgnoreCase)); + } + /// /// Lists the input files in the Images folder /// /// The list of files. - private static IEnumerable ListInputFiles() + private IEnumerable ListInputFiles() { - return Directory.GetFiles("./Images"); + if (this.images != null) + { + return this.images; + } + + DirectoryInfo directoryInfo = new DirectoryInfo("./Images"); + + this.images = GetFilesByExtensions(directoryInfo, new[] { ".jpg", ".jpeg", ".png", ".gif", ".tiff", ".bmp", ".webp" }); + + return this.images; } } } \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index 4d47bb062..b020e2858 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -3,7 +3,7 @@ Debug AnyCPU - {03CA9055-F997-428C-BF28-F50F991777C6} + {633B1C4C-4823-47BE-9A01-A665F3118C8C} Library ImageProcessor.UnitTests ImageProcessor.UnitTests @@ -338,7 +338,5 @@ - - - + \ No newline at end of file diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 4a68a5e86..03e92fdde 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -183,7 +183,7 @@ namespace ImageProcessor this.ImagePath = imagePath; // Open a file stream to prevent the need for lock. - using (var fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) + using (FileStream fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) { ISupportedImageFormat format = FormatUtilities.GetFormat(fileStream); @@ -192,7 +192,7 @@ namespace ImageProcessor throw new ImageFormatException("Input stream is not a supported format."); } - var memoryStream = new MemoryStream(); + MemoryStream memoryStream = new MemoryStream(); // Copy the stream. fileStream.CopyTo(memoryStream); diff --git a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs index 3c6e3b3e0..3ee8cf6cb 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs @@ -142,7 +142,7 @@ namespace ImageProcessor.Imaging.Formats // GDI returns a single array with all delays, while Mono returns a different array for each frame image.SelectActiveFrame(frameDimension, i); var times = image.GetPropertyItem(20736).Value; - int thisDelay = BitConverter.ToInt32(times, 4*i % times.Length); + int thisDelay = BitConverter.ToInt32(times, (4 * i) % times.Length); int toAddDelay = thisDelay * 10 < 20 ? 20 : thisDelay * 10; // Minimum delay is 20 ms // Find the frame From 4d2b42d66fcb9c153859abe6f52d7627efb11d5b Mon Sep 17 00:00:00 2001 From: James South Date: Sun, 29 Jun 2014 12:35:41 +0100 Subject: [PATCH 082/155] fixing unit test project file. Former-commit-id: b3947dcf2bd94e7f2b96dc4c5f952e072e7f46ff --- .../ImageProcessor.UnitTests.csproj | 349 +++--------------- 1 file changed, 57 insertions(+), 292 deletions(-) diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index b020e2858..4cc93cb0f 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -1,336 +1,95 @@  - + Debug AnyCPU {633B1C4C-4823-47BE-9A01-A665F3118C8C} Library + Properties ImageProcessor.UnitTests ImageProcessor.UnitTests - - + v4.0 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest ..\ true - v4.5 + true full false - bin\Debug - DEBUG; + bin\Debug\ + DEBUG;TRACE prompt 4 - false - false - full + pdbonly true - bin\Release + bin\Release\ + TRACE prompt 4 - false - false - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - + + + + + + + + + + - - - - - {D011A778-59C8-4BFA-A770-C350216BF161} - ImageProcessor.Web_NET45 - - - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} - ImageProcessor - + - - - - - - - - - - Images\1182076_e8c402e938_z.jpg - - - Images\bus.jpg - - - Images\Chrysanthemum.jpg - - - Images\circle.png - - - Images\cmyk.jpg - - - Images\cmyk.png - - - Images\color-vision-test.gif - - - Images\Desert.jpg - - - Images\emma.jpg - - - Images\falahill_design__160p.jpg - - - Images\fid11246.jpg - - - Images\fid9141.jpg - - - Images\header_1.jpg - - - Images\Hydrangeas.jpg - - - Images\Jellyfish.jpg - - - Images\jrt.jpg - - - Images\Koala.jpg - - - Images\Lighthouse.jpg - - - Images\lomo.jpg - - - Images\meter.gif - - - Images\negative.png - - - Images\negative2.png - - - Images\Penguins-200.jpg - - - Images\Penguins-8.png - - - Images\Penguins.bmp - - - Images\Penguins.gif - - - Images\Penguins.jpg - - - Images\Penguins.png - - - Images\Penguins.tif - - - Images\rocks.jpg - - - Images\rotate.jpg - - - Images\sample1.jpg - - - Images\srgb.jpg - - - Images\srgb.png - - - Images\text.png - - - Images\thor.jpg - - - Images\Tulips.jpg - - - Images\udendørs-374.jpg - - - Images\udendørs.jpg - - - Images\war_horse_quad.jpg - - - Images\WP_000009.jpg - - {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} ImageProcessor - - - - Images\Chrysanthemum.jpg - PreserveNewest - - - Images\Desert.jpg - PreserveNewest - - - Images\Hydrangeas.jpg - PreserveNewest - - - Images\Jellyfish.jpg - PreserveNewest - - - Images\Koala.jpg - PreserveNewest - - - Images\Lighthouse.jpg - PreserveNewest - - - Images\Penguins-8.png - PreserveNewest - - - Images\Penguins.bmp - PreserveNewest - - - Images\Penguins.gif - PreserveNewest - - - Images\Penguins.jpg - PreserveNewest - - - Images\Penguins.png - PreserveNewest - - - Images\Penguins.tif - PreserveNewest - - - Images\Tulips.jpg - PreserveNewest - - - Images\bus.jpg - PreserveNewest - - - Images\cmyk.jpg - PreserveNewest - - - Images\cmyk.png - PreserveNewest - - - Images\jrt.jpg - PreserveNewest - - - Images\meter.gif - PreserveNewest - - - Images\rocks.jpg - PreserveNewest - - - Images\rotate.jpg - PreserveNewest - - - Images\sample1.jpg - PreserveNewest - - - Images\srgb.jpg - PreserveNewest - - - Images\srgb.png - PreserveNewest - - - Images\text.png - PreserveNewest - - - Images\thor.jpg - PreserveNewest - - - Images\udendørs-374.jpg - PreserveNewest - - - Images\udendørs.jpg - PreserveNewest - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + + @@ -338,5 +97,11 @@ - + \ No newline at end of file From cc74b44f6d77140ca745b57ebc841b15070928d5 Mon Sep 17 00:00:00 2001 From: James South Date: Sun, 29 Jun 2014 18:58:07 +0100 Subject: [PATCH 083/155] Stylistic changes to help me sleep at night :) Former-commit-id: 0ce83dcee663eee4da75da749a43034a1435fb5c --- src/ImageProcessor/ImageFactory.cs | 62 +++++++++---------- .../Imaging/Formats/FormatUtilities.cs | 4 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 4a68a5e86..f2f573268 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -177,13 +177,13 @@ namespace ImageProcessor /// public ImageFactory Load(string imagePath) { - var fileInfo = new FileInfo(imagePath); + FileInfo fileInfo = new FileInfo(imagePath); if (fileInfo.Exists) { this.ImagePath = imagePath; // Open a file stream to prevent the need for lock. - using (var fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) + using (FileStream fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read)) { ISupportedImageFormat format = FormatUtilities.GetFormat(fileStream); @@ -192,7 +192,7 @@ namespace ImageProcessor throw new ImageFormatException("Input stream is not a supported format."); } - var memoryStream = new MemoryStream(); + MemoryStream memoryStream = new MemoryStream(); // Copy the stream. fileStream.CopyTo(memoryStream); @@ -279,7 +279,7 @@ namespace ImageProcessor percentage = 0; } - var alpha = new Alpha { DynamicParameter = percentage }; + Alpha alpha = new Alpha { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(alpha.ProcessImage, this); } @@ -297,7 +297,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - var autoRotate = new AutoRotate(); + AutoRotate autoRotate = new AutoRotate(); this.CurrentImageFormat.ApplyProcessor(autoRotate.ProcessImage, this); } @@ -324,7 +324,7 @@ namespace ImageProcessor percentage = 0; } - var brightness = new Brightness { DynamicParameter = percentage }; + Brightness brightness = new Brightness { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(brightness.ProcessImage, this); } @@ -344,7 +344,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - var layer = new ResizeLayer(size, ResizeMode.Max); + ResizeLayer layer = new ResizeLayer(size, ResizeMode.Max); return this.Resize(layer); } @@ -372,7 +372,7 @@ namespace ImageProcessor percentage = 0; } - var contrast = new Contrast { DynamicParameter = percentage }; + Contrast contrast = new Contrast { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(contrast.ProcessImage, this); } @@ -392,7 +392,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - var cropLayer = new CropLayer(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, CropMode.Pixels); + CropLayer cropLayer = new CropLayer(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, CropMode.Pixels); return this.Crop(cropLayer); } @@ -412,7 +412,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - var crop = new Crop { DynamicParameter = cropLayer }; + Crop crop = new Crop { DynamicParameter = cropLayer }; this.CurrentImageFormat.ApplyProcessor(crop.ProcessImage, this); } @@ -433,7 +433,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - var filter = new Filter { DynamicParameter = matrixFilter }; + Filter filter = new Filter { DynamicParameter = matrixFilter }; this.CurrentImageFormat.ApplyProcessor(filter.ProcessImage, this); } @@ -457,7 +457,7 @@ namespace ImageProcessor ? RotateFlipType.RotateNoneFlipY : RotateFlipType.RotateNoneFlipX; - var flip = new Flip { DynamicParameter = rotateFlipType }; + Flip flip = new Flip { DynamicParameter = rotateFlipType }; this.CurrentImageFormat.ApplyProcessor(flip.ProcessImage, this); } @@ -500,7 +500,7 @@ namespace ImageProcessor { if (this.ShouldProcess && size > 0) { - var layer = new GaussianLayer(size); + GaussianLayer layer = new GaussianLayer(size); return this.GaussianBlur(layer); } @@ -521,7 +521,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - var gaussianBlur = new GaussianBlur { DynamicParameter = gaussianLayer }; + GaussianBlur gaussianBlur = new GaussianBlur { DynamicParameter = gaussianLayer }; this.CurrentImageFormat.ApplyProcessor(gaussianBlur.ProcessImage, this); } @@ -547,7 +547,7 @@ namespace ImageProcessor { if (this.ShouldProcess && size > 0) { - var layer = new GaussianLayer(size); + GaussianLayer layer = new GaussianLayer(size); return this.GaussianSharpen(layer); } @@ -568,7 +568,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - var gaussianSharpen = new GaussianSharpen { DynamicParameter = gaussianLayer }; + GaussianSharpen gaussianSharpen = new GaussianSharpen { DynamicParameter = gaussianLayer }; this.CurrentImageFormat.ApplyProcessor(gaussianSharpen.ProcessImage, this); } @@ -611,7 +611,7 @@ namespace ImageProcessor int width = size.Width; int height = size.Height; - var resizeLayer = new ResizeLayer(new Size(width, height)); + ResizeLayer resizeLayer = new ResizeLayer(new Size(width, height)); return this.Resize(resizeLayer); } @@ -631,9 +631,9 @@ namespace ImageProcessor { if (this.ShouldProcess) { - var resizeSettings = new Dictionary { { "MaxWidth", resizeLayer.Size.Width.ToString("G") }, { "MaxHeight", resizeLayer.Size.Height.ToString("G") } }; + Dictionary resizeSettings = new Dictionary { { "MaxWidth", resizeLayer.Size.Width.ToString("G") }, { "MaxHeight", resizeLayer.Size.Height.ToString("G") } }; - var resize = new Resize { DynamicParameter = resizeLayer, Settings = resizeSettings }; + Resize resize = new Resize { DynamicParameter = resizeLayer, Settings = resizeSettings }; this.CurrentImageFormat.ApplyProcessor(resize.ProcessImage, this); } @@ -659,7 +659,7 @@ namespace ImageProcessor degrees = 0; } - var rotate = new Rotate { DynamicParameter = degrees }; + Rotate rotate = new Rotate { DynamicParameter = degrees }; this.CurrentImageFormat.ApplyProcessor(rotate.ProcessImage, this); } @@ -684,7 +684,7 @@ namespace ImageProcessor roundedCornerLayer.Radius = 0; } - var roundedCorners = new RoundedCorners { DynamicParameter = roundedCornerLayer }; + RoundedCorners roundedCorners = new RoundedCorners { DynamicParameter = roundedCornerLayer }; this.CurrentImageFormat.ApplyProcessor(roundedCorners.ProcessImage, this); } @@ -711,7 +711,7 @@ namespace ImageProcessor percentage = 0; } - var saturate = new Saturation { DynamicParameter = percentage }; + Saturation saturate = new Saturation { DynamicParameter = percentage }; this.CurrentImageFormat.ApplyProcessor(saturate.ProcessImage, this); } @@ -731,7 +731,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - var tint = new Tint { DynamicParameter = color }; + Tint tint = new Tint { DynamicParameter = color }; this.CurrentImageFormat.ApplyProcessor(tint.ProcessImage, this); } @@ -751,12 +751,12 @@ namespace ImageProcessor { if (this.ShouldProcess) { - var vignette = new Vignette - { - DynamicParameter = color.HasValue && !color.Equals(Color.Transparent) - ? color.Value - : Color.Black - }; + Vignette vignette = new Vignette + { + DynamicParameter = color.HasValue && !color.Equals(Color.Transparent) + ? color.Value + : Color.Black + }; this.CurrentImageFormat.ApplyProcessor(vignette.ProcessImage, this); } @@ -778,7 +778,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - var watermark = new Watermark { DynamicParameter = textLayer }; + Watermark watermark = new Watermark { DynamicParameter = textLayer }; this.CurrentImageFormat.ApplyProcessor(watermark.ProcessImage, this); } @@ -800,7 +800,7 @@ namespace ImageProcessor if (this.ShouldProcess) { // ReSharper disable once AssignNullToNotNullAttribute - var directoryInfo = new DirectoryInfo(Path.GetDirectoryName(filePath)); + DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(filePath)); if (!directoryInfo.Exists) { directoryInfo.Create(); diff --git a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs index 3ee8cf6cb..a72485a19 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs @@ -139,9 +139,9 @@ namespace ImageProcessor.Imaging.Formats for (int i = 0; i < frameCount; i++) { - // GDI returns a single array with all delays, while Mono returns a different array for each frame + // GDI returns a single array with all delays, while Mono returns a different array for each frame. image.SelectActiveFrame(frameDimension, i); - var times = image.GetPropertyItem(20736).Value; + byte[] times = image.GetPropertyItem(20736).Value; int thisDelay = BitConverter.ToInt32(times, (4 * i) % times.Length); int toAddDelay = thisDelay * 10 < 20 ? 20 : thisDelay * 10; // Minimum delay is 20 ms From 03b21f51f73923abc282cc557a03a38448ea5377 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 22:54:11 +0200 Subject: [PATCH 084/155] Adds unit tests for double extension methods + Fixes a build problem on Mono Former-commit-id: 599a7c107767d137d1d6ff38085bc42bf4c11015 --- .../Extensions/DoubleExtensionsUnitTests.cs | 55 +++++++++++++++++++ .../ImageProcessor.UnitTests.csproj | 4 ++ src/ImageProcessor/ImageProcessor.csproj | 6 +- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs new file mode 100644 index 000000000..108a9a246 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs @@ -0,0 +1,55 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Runs unit tests on the extension methods +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.UnitTests +{ + using System; + using System.Collections.Generic; + using Common.Extensions; + using NUnit.Framework; + + /// + /// Test harness for the DoubleExtensions extension methods + /// + [TestFixture] + public class DoubleExtensionsUnitTests + { + /// + /// Stores the values to test for the ToByte() extension method + /// + private Dictionary doubleToByteTests; + + /// + /// Sets up the values for the tests + /// + [TestFixtureSetUp] + public void Init() + { + this.doubleToByteTests = new Dictionary(); + this.doubleToByteTests.Add(-10, 0x0); + this.doubleToByteTests.Add(1.5, 0x1); + this.doubleToByteTests.Add(25.7, 0x19); + this.doubleToByteTests.Add(1289047, 0xFF); + } + + /// + /// Tests the double to byte conversion + /// + [Test] + public void TestDoubleToByte() + { + foreach (var item in this.doubleToByteTests) + { + var result = item.Key.ToByte(); + Assert.AreEqual(item.Value, result); + } + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index c872dbbb8..e715df657 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -46,6 +46,7 @@ PreserveNewest + @@ -127,4 +128,7 @@ + + + \ No newline at end of file diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 4521b06eb..331690773 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -3,8 +3,6 @@ Debug AnyCPU - 8.0.30703 - 2.0 {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} Library Properties @@ -25,7 +23,6 @@ prompt 4 bin\Debug\ImageProcessor.XML - false pdbonly @@ -46,6 +43,8 @@ prompt false true + 4 + false @@ -57,6 +56,7 @@ + From b6de6e8505217b2c0767ae738502d9e94e036766 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 23:41:33 +0200 Subject: [PATCH 085/155] Adds a few unit tests for integer extension methods Former-commit-id: c587d0b1373ced2470459836d5814afe0e7e31e8 --- .../Extensions/IntegerExtensionsUnitTests.cs | 38 +++++++++++++++++++ .../ImageProcessor.UnitTests.csproj | 1 + 2 files changed, 39 insertions(+) create mode 100644 src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs new file mode 100644 index 000000000..1e85e633b --- /dev/null +++ b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs @@ -0,0 +1,38 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Runs unit tests on the extension methods +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.UnitTests +{ + using System; + using Common.Extensions; + using NUnit.Framework; + + /// + /// Provides a test harness for the integer extension class + /// + [TestFixture] + public class IntegerExtensionsUnitTests + { + /// + /// Tests the "ToByte" extension + /// + /// Integer input + /// Expected result + [Test] + [TestCase(21, 0x15)] + [TestCase(190, 0xBE)] + [TestCase(3156, 0xFF)] + public void ToByteTest(int input, byte expected) + { + var result = input.ToByte(); + Assert.AreEqual(expected, result); + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index e715df657..b545a11d9 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -47,6 +47,7 @@ PreserveNewest + From f5b23d81316403e7b7dbbf19a9542508e672cf83 Mon Sep 17 00:00:00 2001 From: James South Date: Mon, 30 Jun 2014 00:25:26 +0100 Subject: [PATCH 086/155] Fixing asp native binary loading Former-commit-id: b50aa19ade3d337a0b258c9165ba06c95be52ea0 --- build/NuSpecs/ImageProcessor.nuspec | 4 +- .../ImageProcessor/imageprocessor.targets | 2 +- .../ImageProcessorConfiguration.cs | 43 ++++++++++++++++++ .../NET45/Helpers/NativeMethods.cs | 44 +++++++++++++++++++ .../NET45/ImageProcessor.Web_NET45.csproj | 1 + .../NET45/Settings.StyleCop | 7 +++ .../ImageProcessorBootstrapper.cs | 3 ++ src/ImageProcessor/ImageProcessor.csproj | 4 +- .../Imaging/Formats/NativeMethods.cs | 16 +++---- .../Imaging/Formats/WebPFormat.cs | 7 +-- ...ED.git-id => libwebp32.dll.REMOVED.git-id} | 0 ...ED.git-id => libwebp64.dll.REMOVED.git-id} | 0 src/ImageProcessorConsole/Program.cs | 12 ++--- .../images/output/rotate.webp | 3 -- 14 files changed, 118 insertions(+), 28 deletions(-) create mode 100644 src/ImageProcessor.Web/NET45/Helpers/NativeMethods.cs create mode 100644 src/ImageProcessor.Web/NET45/Settings.StyleCop rename src/ImageProcessor/{x86/libwebp.dll.REMOVED.git-id => libwebp32.dll.REMOVED.git-id} (100%) rename src/ImageProcessor/{x64/libwebp.dll.REMOVED.git-id => libwebp64.dll.REMOVED.git-id} (100%) delete mode 100644 src/ImageProcessorConsole/images/output/rotate.webp diff --git a/build/NuSpecs/ImageProcessor.nuspec b/build/NuSpecs/ImageProcessor.nuspec index 8041f5dfc..557d85150 100644 --- a/build/NuSpecs/ImageProcessor.nuspec +++ b/build/NuSpecs/ImageProcessor.nuspec @@ -25,8 +25,8 @@ Feedback is always welcome. - - + + \ No newline at end of file diff --git a/build/content/ImageProcessor/imageprocessor.targets b/build/content/ImageProcessor/imageprocessor.targets index 0b161e3c5..f8de1a74b 100644 --- a/build/content/ImageProcessor/imageprocessor.targets +++ b/build/content/ImageProcessor/imageprocessor.targets @@ -14,7 +14,7 @@ + DestinationFiles="@(NativeBinaries->'$(OutDir)\%(RecursiveDir)\%(Filename)%(Extension)')"> diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs index 89bcf39d7..9d3ea6be9 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs @@ -13,12 +13,16 @@ namespace ImageProcessor.Web.Configuration using System; using System.Collections.Concurrent; using System.Collections.Generic; + using System.Diagnostics; + using System.IO; using System.Linq; using System.Reflection; + using System.Web; using System.Web.Compilation; using ImageProcessor.Common.Extensions; using ImageProcessor.Processors; + using ImageProcessor.Web.Helpers; using ImageProcessor.Web.Processors; /// @@ -28,6 +32,12 @@ namespace ImageProcessor.Web.Configuration public sealed class ImageProcessorConfiguration { #region Fields + /// + /// Whether the process is running in 64bit mode. Used for calling the correct dllimport method. + /// Clunky I know but I couldn't get dynamic methods to work. + /// + private static readonly bool Is64Bit = Environment.Is64BitProcess; + /// /// A new instance Initializes a new instance of the class. /// with lazy initialization. @@ -71,6 +81,7 @@ namespace ImageProcessor.Web.Configuration /// private ImageProcessorConfiguration() { + this.EnsureNativeBinariesLoaded(); this.LoadGraphicsProcessors(); } #endregion @@ -353,6 +364,38 @@ namespace ImageProcessor.Web.Configuration webProcessor.Processor.Settings = this.GetPluginSettings(webProcessor.GetType().Name); } } + + /// + /// Ensures that the native binaries are loaded. + /// + private void EnsureNativeBinariesLoaded() + { + string binary = Is64Bit ? "libwebp64.dll" : "libwebp32.dll"; + string sourcePath = HttpContext.Current.Server.MapPath("~/bin"); + string targetPath = new Uri(Assembly.GetExecutingAssembly().Location).LocalPath; + IntPtr pointer = IntPtr.Zero; + + // Shadow copy the native binaries. + sourcePath = Path.Combine(sourcePath, binary); + targetPath = Path.GetFullPath(Path.Combine(targetPath, "..\\" + binary)); + + File.Copy(sourcePath, targetPath, true); + + try + { + // Load the binary into memory. + pointer = NativeMethods.LoadLibrary(targetPath); + } + catch (Exception ex) + { + Debug.WriteLine(ex.Message); + } + + if (pointer == IntPtr.Zero) + { + throw new ApplicationException("Cannot open " + binary); + } + } #endregion } } diff --git a/src/ImageProcessor.Web/NET45/Helpers/NativeMethods.cs b/src/ImageProcessor.Web/NET45/Helpers/NativeMethods.cs new file mode 100644 index 000000000..9e983438c --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Helpers/NativeMethods.cs @@ -0,0 +1,44 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Provides access to unmanaged native methods. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Helpers +{ + using System; + using System.Runtime.InteropServices; + + /// + /// Provides access to unmanaged native methods. + /// + internal class NativeMethods + { + /// + /// Loads the specified module into the address space of the calling process. + /// The specified module may cause other modules to be loaded. + /// + /// + /// The name of the module. This can be either a library module or + /// an executable module. + /// + /// If the function succeeds, the return value is a handle to the module; otherwise null. + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + public static extern IntPtr LoadLibrary(string libname); + + /// + /// Frees the loaded dynamic-link library (DLL) module and, if necessary, decrements its reference count. + /// When the reference count reaches zero, the module is unloaded from the address space of the calling + /// process and the handle is no longer valid. + /// + /// A handle to the loaded library module. + /// The LoadLibrary, LoadLibraryEx, GetModuleHandle, or GetModuleHandleEx function returns this handle. + /// If the function succeeds, the return value is nonzero; otherwise zero. + [DllImport("kernel32.dll", CharSet = CharSet.Auto)] + public static extern bool FreeLibrary(IntPtr hModule); + } +} diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj index 7ca861264..ac434afe5 100644 --- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj +++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj @@ -54,6 +54,7 @@ + diff --git a/src/ImageProcessor.Web/NET45/Settings.StyleCop b/src/ImageProcessor.Web/NET45/Settings.StyleCop new file mode 100644 index 000000000..09dd1de03 --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Settings.StyleCop @@ -0,0 +1,7 @@ + + + + dllimport + + + \ No newline at end of file diff --git a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs index e6a7f1962..a9d9c5542 100644 --- a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs +++ b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs @@ -12,7 +12,10 @@ namespace ImageProcessor.Configuration { using System; using System.Collections.Generic; + using System.IO; using System.Linq; + using System.Reflection; + using ImageProcessor.Common.Exceptions; using ImageProcessor.Common.Extensions; using ImageProcessor.Imaging.Formats; diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 4521b06eb..1c5b26e80 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -130,10 +130,10 @@ - + PreserveNewest - + PreserveNewest diff --git a/src/ImageProcessor/Imaging/Formats/NativeMethods.cs b/src/ImageProcessor/Imaging/Formats/NativeMethods.cs index 059c5259a..8aaff3432 100644 --- a/src/ImageProcessor/Imaging/Formats/NativeMethods.cs +++ b/src/ImageProcessor/Imaging/Formats/NativeMethods.cs @@ -37,7 +37,7 @@ namespace ImageProcessor.Imaging.Formats /// /// 1 if success, otherwise error code returned in the case of (a) formatting error(s). /// - [DllImport("x86\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPGetInfo")] + [DllImport("libwebp32.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPGetInfo")] public static extern int WebPGetInfo86(IntPtr data, uint dataSize, out int width, out int height); /// @@ -58,7 +58,7 @@ namespace ImageProcessor.Imaging.Formats /// /// 1 if success, otherwise error code returned in the case of (a) formatting error(s). /// - [DllImport("x64\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPGetInfo")] + [DllImport("libwebp64.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPGetInfo")] public static extern int WebPGetInfo64(IntPtr data, uint dataSize, out int width, out int height); /// @@ -82,7 +82,7 @@ namespace ImageProcessor.Imaging.Formats /// /// output_buffer if function succeeds; NULL otherwise /// - [DllImport("x86\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPDecodeBGRAInto")] + [DllImport("libwebp32.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPDecodeBGRAInto")] public static extern IntPtr WebPDecodeBGRAInto86(IntPtr data, uint dataSize, IntPtr outputBuffer, int outputBufferSize, int outputStride); /// @@ -106,7 +106,7 @@ namespace ImageProcessor.Imaging.Formats /// /// output_buffer if function succeeds; NULL otherwise /// - [DllImport("x64\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPDecodeBGRAInto")] + [DllImport("libwebp64.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPDecodeBGRAInto")] public static extern IntPtr WebPDecodeBGRAInto64(IntPtr data, uint dataSize, IntPtr outputBuffer, int outputBufferSize, int outputStride); /// @@ -133,7 +133,7 @@ namespace ImageProcessor.Imaging.Formats /// /// Size of WebP Image /// - [DllImport("x86\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPEncodeBGRA")] + [DllImport("libwebp32.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPEncodeBGRA")] public static extern int WebPEncodeBGRA86(IntPtr rgb, int width, int height, int stride, float qualityFactor, out IntPtr output); /// @@ -160,7 +160,7 @@ namespace ImageProcessor.Imaging.Formats /// /// Size of WebP Image /// - [DllImport("x64\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPEncodeBGRA")] + [DllImport("libwebp64.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPEncodeBGRA")] public static extern int WebPEncodeBGRA64(IntPtr rgb, int width, int height, int stride, float qualityFactor, out IntPtr output); /// @@ -172,7 +172,7 @@ namespace ImageProcessor.Imaging.Formats /// /// 1 if success, otherwise error code returned in the case of (a) error(s). /// - [DllImport("x86\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPFree")] + [DllImport("libwebp32.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPFree")] public static extern int WebPFree86(IntPtr pointer); /// @@ -184,7 +184,7 @@ namespace ImageProcessor.Imaging.Formats /// /// 1 if success, otherwise error code returned in the case of (a) error(s). /// - [DllImport("x64\\libwebp.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPFree")] + [DllImport("libwebp64.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "WebPFree")] public static extern int WebPFree64(IntPtr pointer); #endregion } diff --git a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs index 25b0205e3..03f195122 100644 --- a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/WebPFormat.cs @@ -32,7 +32,7 @@ namespace ImageProcessor.Imaging.Formats public class WebPFormat : FormatBase { /// - /// Whether the process is running in 63bit mode. Used for calling the correct dllimport method. + /// Whether the process is running in 64bit mode. Used for calling the correct dllimport method. /// Clunky I know but I couldn't get dynamic methods to work. /// private static readonly bool Is64Bit = Environment.Is64BitProcess; @@ -227,11 +227,6 @@ namespace ImageProcessor.Imaging.Formats outputBuffer = NativeMethods.WebPDecodeBGRAInto86(ptrData, dataSize, outputBuffer, outputBufferSize, bitmapData.Stride); } - if (bitmapData.Scan0 != outputBuffer) - { - throw new ImageFormatException("Failed to decode WebP image with error " + (long)outputBuffer); - } - // Write image to bitmap using Marshal byte[] buffer = new byte[outputBufferSize]; Marshal.Copy(outputBuffer, buffer, 0, outputBufferSize); diff --git a/src/ImageProcessor/x86/libwebp.dll.REMOVED.git-id b/src/ImageProcessor/libwebp32.dll.REMOVED.git-id similarity index 100% rename from src/ImageProcessor/x86/libwebp.dll.REMOVED.git-id rename to src/ImageProcessor/libwebp32.dll.REMOVED.git-id diff --git a/src/ImageProcessor/x64/libwebp.dll.REMOVED.git-id b/src/ImageProcessor/libwebp64.dll.REMOVED.git-id similarity index 100% rename from src/ImageProcessor/x64/libwebp.dll.REMOVED.git-id rename to src/ImageProcessor/libwebp64.dll.REMOVED.git-id diff --git a/src/ImageProcessorConsole/Program.cs b/src/ImageProcessorConsole/Program.cs index 64053c5ed..b08b9440b 100644 --- a/src/ImageProcessorConsole/Program.cs +++ b/src/ImageProcessorConsole/Program.cs @@ -40,9 +40,9 @@ namespace ImageProcessorConsole di.Create(); } - FileInfo[] files = di.GetFiles("*.jpg"); + //FileInfo[] files = di.GetFiles("*.jpg"); //FileInfo[] files = di.GetFiles(); - //var files = GetFilesByExtensions(di, ".gif", ".webp"); + IEnumerable files = GetFilesByExtensions(di, ".gif", ".webp"); foreach (FileInfo fileInfo in files) @@ -60,11 +60,11 @@ namespace ImageProcessorConsole imageFactory.Load(inStream) .AutoRotate() .Constrain(size) - .Format(new WebPFormat()) - .Quality(5) + //.Format(new WebPFormat()) + //.Quality(5) // ReSharper disable once AssignNullToNotNullAttribute - .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".webp"))); - //.Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name))); + // .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".webp"))); + .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name))); } } } diff --git a/src/ImageProcessorConsole/images/output/rotate.webp b/src/ImageProcessorConsole/images/output/rotate.webp deleted file mode 100644 index 8bc9002cd..000000000 --- a/src/ImageProcessorConsole/images/output/rotate.webp +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:37d346c1cc3fe9635397d508ee332740f1043f942d940871e4cfc3b616cf5279 -size 1792 From d6913d7ad329b9014c2e81e5be6312559da54f31 Mon Sep 17 00:00:00 2001 From: James South Date: Mon, 30 Jun 2014 00:40:15 +0100 Subject: [PATCH 087/155] Fixing missing reference Former-commit-id: f058eb260906ca174aacb18b525974734de40548 --- src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj | 3 +++ .../NET45/Configuration/ImageProcessorConfiguration.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj index ccda9415f..2a149236a 100644 --- a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj +++ b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj @@ -101,6 +101,9 @@ ImageHelpers.cs + + NativeMethods.cs + ResourceHelpers.cs diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs index 9d3ea6be9..b0977a962 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs @@ -22,8 +22,8 @@ namespace ImageProcessor.Web.Configuration using ImageProcessor.Common.Extensions; using ImageProcessor.Processors; - using ImageProcessor.Web.Helpers; using ImageProcessor.Web.Processors; + using ImageProcessor.Web.Helpers; /// /// Encapsulates methods to allow the retrieval of ImageProcessor settings. From ab386b08fc509f6787c35b81b80497c582940224 Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 1 Jul 2014 17:54:37 +0100 Subject: [PATCH 088/155] Tweaking gif frame creation and fixing unc folder access issue Former-commit-id: badfd2f22a0f209cd9f913804260dce56b0037e4 --- .../NET4/ImageProcessor.Web_NET4.csproj | 3 + .../NET45/Caching/DiskCache.cs | 56 +++++++++++-------- .../ImageProcessorConfiguration.cs | 2 +- .../HttpModules/ImageProcessingModule.cs | 2 +- .../NET45/ImageProcessor.Web_NET45.csproj | 1 + .../Imaging/Formats/FormatUtilities.cs | 28 +++++----- .../Imaging/Formats/GifEncoder.cs | 18 +++--- src/ImageProcessorConsole/Program.cs | 5 +- 8 files changed, 65 insertions(+), 50 deletions(-) diff --git a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj index 2a149236a..d830257ae 100644 --- a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj +++ b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj @@ -95,6 +95,9 @@ ImageSecuritySection.cs + + DirectoryInfoExtensions.cs + CommonParameterParserUtility.cs diff --git a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs index f1cefc657..6a23d48ad 100644 --- a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs +++ b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs @@ -22,6 +22,7 @@ namespace ImageProcessor.Web.Caching using ImageProcessor.Common.Extensions; using ImageProcessor.Web.Configuration; + using ImageProcessor.Web.Extensions; using ImageProcessor.Web.Helpers; #endregion @@ -212,37 +213,44 @@ namespace ImageProcessor.Web.Caching /// private void TrimCachedFolders(string path) { - // ReSharper disable once AssignNullToNotNullAttribute - DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(path)); - DirectoryInfo parentDirectoryInfo = directoryInfo.Parent; + string directory = Path.GetDirectoryName(path); - // ReSharper disable once PossibleNullReferenceException - foreach (DirectoryInfo enumerateDirectory in parentDirectoryInfo.EnumerateDirectories()) + if (directory != null) { - IEnumerable files = enumerateDirectory.EnumerateFiles().OrderBy(f => f.CreationTimeUtc); - int count = files.Count(); + DirectoryInfo directoryInfo = new DirectoryInfo(directory); + DirectoryInfo parentDirectoryInfo = directoryInfo.Parent; - foreach (FileInfo fileInfo in files) + if (parentDirectoryInfo != null) { - try + // UNC folders can throw exceptions if the file doesn't exist. + foreach (DirectoryInfo enumerateDirectory in parentDirectoryInfo.SafeEnumerateDirectories()) { - // If the group count is equal to the max count minus 1 then we know we - // have reduced the number of items below the maximum allowed. - // We'll cleanup any orphaned expired files though. - if (!this.IsExpired(fileInfo.CreationTimeUtc) && count <= MaxFilesCount - 1) + IEnumerable files = enumerateDirectory.EnumerateFiles().OrderBy(f => f.CreationTimeUtc); + int count = files.Count(); + + foreach (FileInfo fileInfo in files) { - break; + try + { + // If the group count is equal to the max count minus 1 then we know we + // have reduced the number of items below the maximum allowed. + // We'll cleanup any orphaned expired files though. + if (!this.IsExpired(fileInfo.CreationTimeUtc) && count <= MaxFilesCount - 1) + { + break; + } + + // Remove from the cache and delete each CachedImage. + CacheIndexer.Remove(fileInfo.Name); + fileInfo.Delete(); + count -= 1; + } + // ReSharper disable once EmptyGeneralCatchClause + catch + { + // Do nothing; skip to the next file. + } } - - // Remove from the cache and delete each CachedImage. - CacheIndexer.Remove(fileInfo.Name); - fileInfo.Delete(); - count -= 1; - } - // ReSharper disable once EmptyGeneralCatchClause - catch - { - // Do nothing; skip to the next file. } } } diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs index b0977a962..9d3ea6be9 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs @@ -22,8 +22,8 @@ namespace ImageProcessor.Web.Configuration using ImageProcessor.Common.Extensions; using ImageProcessor.Processors; - using ImageProcessor.Web.Processors; using ImageProcessor.Web.Helpers; + using ImageProcessor.Web.Processors; /// /// Encapsulates methods to allow the retrieval of ImageProcessor settings. diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index 33877e15b..d70e71867 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -359,7 +359,7 @@ namespace ImageProcessor.Web.HttpModules IPrincipal user = context.User ?? new GenericPrincipal(new GenericIdentity(string.Empty, string.Empty), new string[0]); // Do we have permission to call UrlAuthorizationModule.CheckUrlAccessForPrincipal? - PermissionSet permission = new PermissionSet(PermissionState.Unrestricted); + PermissionSet permission = new PermissionSet(PermissionState.None); permission.AddPermission(new AspNetHostingPermission(AspNetHostingPermissionLevel.Unrestricted)); bool hasPermission = permission.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet); diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj index ac434afe5..2f5e77f23 100644 --- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj +++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj @@ -53,6 +53,7 @@ + diff --git a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs index a72485a19..53025bf42 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs @@ -131,40 +131,42 @@ namespace ImageProcessor.Imaging.Formats if (fetchFrames) { - FrameDimension frameDimension = new FrameDimension(image.FrameDimensionsList[0]); - int frameCount = image.GetFrameCount(frameDimension); + int frameCount = image.GetFrameCount(FrameDimension.Time); int last = frameCount - 1; - int delay = 0; + int length = 0; + List gifFrames = new List(); + // Get the times stored in the gif. + byte[] times = image.GetPropertyItem((int)ExifPropertyTag.FrameDelay).Value; + for (int i = 0; i < frameCount; i++) { + // Convert each 4-byte chunk into an integer. // GDI returns a single array with all delays, while Mono returns a different array for each frame. - image.SelectActiveFrame(frameDimension, i); - byte[] times = image.GetPropertyItem(20736).Value; - int thisDelay = BitConverter.ToInt32(times, (4 * i) % times.Length); - int toAddDelay = thisDelay * 10 < 20 ? 20 : thisDelay * 10; // Minimum delay is 20 ms + int delay = BitConverter.ToInt32(times, (4 * i) % times.Length); + delay = delay * 10 < 20 ? 20 : delay * 10; // Minimum delay is 20 ms // Find the frame - image.SelectActiveFrame(frameDimension, i); + image.SelectActiveFrame(FrameDimension.Time, i); // TODO: Get positions. - gifFrames.Add(new GifFrame { Delay = toAddDelay, Image = (Image)image.Clone() }); + gifFrames.Add(new GifFrame { Delay = delay, Image = (Image)image.Clone() }); // Reset the position. if (i == last) { - image.SelectActiveFrame(frameDimension, 0); + image.SelectActiveFrame(FrameDimension.Time, 0); } - delay += toAddDelay; + length += delay; } info.GifFrames = gifFrames; - info.AnimationLength = delay; + info.AnimationLength = length; // Loop info is stored at byte 20737. - info.LoopCount = BitConverter.ToInt16(image.GetPropertyItem(20737).Value, 0); + info.LoopCount = BitConverter.ToInt16(image.GetPropertyItem((int)ExifPropertyTag.LoopCount).Value, 0); info.IsLooped = info.LoopCount != 1; } } diff --git a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs index 612a453bf..662ad314c 100644 --- a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs +++ b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs @@ -193,13 +193,6 @@ namespace ImageProcessor.Imaging.Formats } #endregion - #region Properties - /// - /// Gets or sets the frame delay. - /// - public TimeSpan FrameDelay { get; set; } - #endregion - #region Public Methods and Operators /// /// Adds a frame to the gif. @@ -289,13 +282,18 @@ namespace ImageProcessor.Imaging.Formats { int count = this.repeatCount.GetValueOrDefault(0); - // File Header + // File Header sinature and version. this.WriteString(FileType); this.WriteString(FileVersion); + + // Write the logical screen descriptor. this.WriteShort(this.width.GetValueOrDefault(w)); // Initial Logical Width this.WriteShort(this.height.GetValueOrDefault(h)); // Initial Logical Height + + // Read the global color table info. sourceGif.Position = SourceGlobalColorInfoPosition; - this.WriteByte(sourceGif.ReadByte()); // Global Color Table Info + this.WriteByte(sourceGif.ReadByte()); + this.WriteByte(0); // Background Color Index this.WriteByte(0); // Pixel aspect ratio this.WriteColorTable(sourceGif); @@ -387,6 +385,7 @@ namespace ImageProcessor.Imaging.Formats /// private void WriteImageBlock(Stream sourceGif, bool includeColorTable, int x, int y, int h, int w) { + // Local Image Descriptor sourceGif.Position = SourceImageBlockPosition; // Locating the image block byte[] header = new byte[SourceImageBlockHeaderLength]; sourceGif.Read(header, 0, header.Length); @@ -435,6 +434,7 @@ namespace ImageProcessor.Imaging.Formats /// private void WriteShort(int value) { + // Leave only one significant byte. this.inputStream.WriteByte(Convert.ToByte(value & 0xff)); this.inputStream.WriteByte(Convert.ToByte((value >> 8) & 0xff)); } diff --git a/src/ImageProcessorConsole/Program.cs b/src/ImageProcessorConsole/Program.cs index b08b9440b..248fe1d7f 100644 --- a/src/ImageProcessorConsole/Program.cs +++ b/src/ImageProcessorConsole/Program.cs @@ -1,6 +1,7 @@ // -------------------------------------------------------------------------------------------------------------------- // -// Copyright James South +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. // // // The program. @@ -58,7 +59,7 @@ namespace ImageProcessorConsole // Load, resize, set the format and quality and save an image. imageFactory.Load(inStream) - .AutoRotate() + //.AutoRotate() .Constrain(size) //.Format(new WebPFormat()) //.Quality(5) From eaa7c6ec4038678df103dff6f4afb20735b03541 Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 1 Jul 2014 17:55:06 +0100 Subject: [PATCH 089/155] Adding missed files Former-commit-id: b0d6ff1d22691f4944b6408816c14ecbe8d16856 --- .../Extensions/DirectoryInfoExtensions.cs | 56 +++++++++++++++++++ .../images/output/120430.gif.REMOVED.git-id | 1 + .../images/output/4.sm.webp | 3 + .../images/output/Tl4Yb.gif.REMOVED.git-id | 1 + .../images/output/nLpfllv.gif.REMOVED.git-id | 1 + .../images/output/test.webp | 3 + 6 files changed, 65 insertions(+) create mode 100644 src/ImageProcessor.Web/NET45/Extensions/DirectoryInfoExtensions.cs create mode 100644 src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id create mode 100644 src/ImageProcessorConsole/images/output/4.sm.webp create mode 100644 src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id create mode 100644 src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id create mode 100644 src/ImageProcessorConsole/images/output/test.webp diff --git a/src/ImageProcessor.Web/NET45/Extensions/DirectoryInfoExtensions.cs b/src/ImageProcessor.Web/NET45/Extensions/DirectoryInfoExtensions.cs new file mode 100644 index 000000000..2ec477257 --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Extensions/DirectoryInfoExtensions.cs @@ -0,0 +1,56 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Provides extension methods to the type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Extensions +{ + using System.Collections.Generic; + using System.IO; + using System.Linq; + + /// + /// Provides extension methods to the type. + /// + public static class DirectoryInfoExtensions + { + /// + /// Returns an enumerable collection of directory information that matches a specified search pattern and search subdirectory option. + /// Will return an empty enumerable on exception. Quick and dirty but does what I need just now. + /// + /// + /// The that this method extends. + /// + /// + /// The search string to match against the names of directories. This parameter can contain a combination of valid literal path + /// and wildcard (* and ?) characters (see Remarks), but doesn't support regular expressions. The default pattern is "*", which returns all files. + /// + /// + /// One of the enumeration values that specifies whether the search operation should include only + /// the current directory or all subdirectories. The default value is TopDirectoryOnly. + /// + /// + /// An enumerable collection of directories that matches searchPattern and searchOption. + /// + public static IEnumerable SafeEnumerateDirectories(this DirectoryInfo directoryInfo, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly) + { + IEnumerable directories; + + try + { + directories = directoryInfo.EnumerateDirectories(searchPattern, searchOption); + } + catch + { + return Enumerable.Empty(); + } + + return directories; + } + } +} diff --git a/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id new file mode 100644 index 000000000..71ce555c1 --- /dev/null +++ b/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id @@ -0,0 +1 @@ +30ec5c05548fd350f9b7c699715848b9fbfb8ca9 \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/4.sm.webp b/src/ImageProcessorConsole/images/output/4.sm.webp new file mode 100644 index 000000000..1cce96a6c --- /dev/null +++ b/src/ImageProcessorConsole/images/output/4.sm.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc9ccd29734ed06d2916389cc363955924f4bbb200fea91c113ae2b9334eca1f +size 12162 diff --git a/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id new file mode 100644 index 000000000..6515d65a0 --- /dev/null +++ b/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id @@ -0,0 +1 @@ +fdc62fc2d056ab885eb9e8fd12b9155ee86d7c43 \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id new file mode 100644 index 000000000..c07be0b0f --- /dev/null +++ b/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id @@ -0,0 +1 @@ +77cce70db3722920d60f4b17a45a5e390a09838a \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/test.webp b/src/ImageProcessorConsole/images/output/test.webp new file mode 100644 index 000000000..4534523db --- /dev/null +++ b/src/ImageProcessorConsole/images/output/test.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b41b4fe144f9d3eaee706b516021efc7abc598f17655d9592866963bfa62f3ad +size 5590 From 2c3fbedde2a1f8cadd0e2cdfb21b1f531f1b56f2 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 22:54:11 +0200 Subject: [PATCH 090/155] Adds unit tests for double extension methods + Fixes a build problem on Mono Former-commit-id: 0173a90054d91a5e80b0eb8765e10ddcb8a28085 --- .../Extensions/DoubleExtensionsUnitTests.cs | 55 +++++++++++++++++++ .../ImageProcessor.UnitTests.csproj | 4 ++ src/ImageProcessor/ImageProcessor.csproj | 6 +- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs new file mode 100644 index 000000000..108a9a246 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs @@ -0,0 +1,55 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Runs unit tests on the extension methods +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.UnitTests +{ + using System; + using System.Collections.Generic; + using Common.Extensions; + using NUnit.Framework; + + /// + /// Test harness for the DoubleExtensions extension methods + /// + [TestFixture] + public class DoubleExtensionsUnitTests + { + /// + /// Stores the values to test for the ToByte() extension method + /// + private Dictionary doubleToByteTests; + + /// + /// Sets up the values for the tests + /// + [TestFixtureSetUp] + public void Init() + { + this.doubleToByteTests = new Dictionary(); + this.doubleToByteTests.Add(-10, 0x0); + this.doubleToByteTests.Add(1.5, 0x1); + this.doubleToByteTests.Add(25.7, 0x19); + this.doubleToByteTests.Add(1289047, 0xFF); + } + + /// + /// Tests the double to byte conversion + /// + [Test] + public void TestDoubleToByte() + { + foreach (var item in this.doubleToByteTests) + { + var result = item.Key.ToByte(); + Assert.AreEqual(item.Value, result); + } + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index c872dbbb8..e715df657 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -46,6 +46,7 @@ PreserveNewest + @@ -127,4 +128,7 @@ + + + \ No newline at end of file diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 1c5b26e80..c21b78194 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -3,8 +3,6 @@ Debug AnyCPU - 8.0.30703 - 2.0 {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} Library Properties @@ -25,7 +23,6 @@ prompt 4 bin\Debug\ImageProcessor.XML - false pdbonly @@ -46,6 +43,8 @@ prompt false true + 4 + false @@ -57,6 +56,7 @@ + From 5f3483ca26b878bdcdcff77523201076031357ab Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 23:41:33 +0200 Subject: [PATCH 091/155] Adds a few unit tests for integer extension methods Former-commit-id: 456bf78a23c676691a90f7bfe1149673e5e0d79d --- .../Extensions/IntegerExtensionsUnitTests.cs | 38 +++++++++++++++++++ .../ImageProcessor.UnitTests.csproj | 1 + 2 files changed, 39 insertions(+) create mode 100644 src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs new file mode 100644 index 000000000..1e85e633b --- /dev/null +++ b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs @@ -0,0 +1,38 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Runs unit tests on the extension methods +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.UnitTests +{ + using System; + using Common.Extensions; + using NUnit.Framework; + + /// + /// Provides a test harness for the integer extension class + /// + [TestFixture] + public class IntegerExtensionsUnitTests + { + /// + /// Tests the "ToByte" extension + /// + /// Integer input + /// Expected result + [Test] + [TestCase(21, 0x15)] + [TestCase(190, 0xBE)] + [TestCase(3156, 0xFF)] + public void ToByteTest(int input, byte expected) + { + var result = input.ToByte(); + Assert.AreEqual(expected, result); + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index e715df657..b545a11d9 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -47,6 +47,7 @@ PreserveNewest + From 8421dcdda2b25ad7b263cb878734da47d6e8ab13 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 22:54:11 +0200 Subject: [PATCH 092/155] Adds unit tests for double extension methods + Fixes a build problem on Mono Former-commit-id: e8f60511fcccad4fd1f9e38d4d33cfdcb8a7020d --- .../Extensions/DoubleExtensionsUnitTests.cs | 55 +++++++++++++++++++ .../ImageProcessor.UnitTests.csproj | 4 ++ src/ImageProcessor/ImageProcessor.csproj | 6 +- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs new file mode 100644 index 000000000..108a9a246 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs @@ -0,0 +1,55 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Runs unit tests on the extension methods +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.UnitTests +{ + using System; + using System.Collections.Generic; + using Common.Extensions; + using NUnit.Framework; + + /// + /// Test harness for the DoubleExtensions extension methods + /// + [TestFixture] + public class DoubleExtensionsUnitTests + { + /// + /// Stores the values to test for the ToByte() extension method + /// + private Dictionary doubleToByteTests; + + /// + /// Sets up the values for the tests + /// + [TestFixtureSetUp] + public void Init() + { + this.doubleToByteTests = new Dictionary(); + this.doubleToByteTests.Add(-10, 0x0); + this.doubleToByteTests.Add(1.5, 0x1); + this.doubleToByteTests.Add(25.7, 0x19); + this.doubleToByteTests.Add(1289047, 0xFF); + } + + /// + /// Tests the double to byte conversion + /// + [Test] + public void TestDoubleToByte() + { + foreach (var item in this.doubleToByteTests) + { + var result = item.Key.ToByte(); + Assert.AreEqual(item.Value, result); + } + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index c872dbbb8..e715df657 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -46,6 +46,7 @@ PreserveNewest + @@ -127,4 +128,7 @@ + + + \ No newline at end of file diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 1c5b26e80..c21b78194 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -3,8 +3,6 @@ Debug AnyCPU - 8.0.30703 - 2.0 {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} Library Properties @@ -25,7 +23,6 @@ prompt 4 bin\Debug\ImageProcessor.XML - false pdbonly @@ -46,6 +43,8 @@ prompt false true + 4 + false @@ -57,6 +56,7 @@ + From d683c7c160f4741104c303d98f901cc83abdca13 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 23:41:33 +0200 Subject: [PATCH 093/155] Adds a few unit tests for integer extension methods Former-commit-id: e90275cd32600a9a68010f0fb1aeebbb6d092598 --- .../Extensions/IntegerExtensionsUnitTests.cs | 38 +++++++++++++++++++ .../ImageProcessor.UnitTests.csproj | 1 + 2 files changed, 39 insertions(+) create mode 100644 src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs new file mode 100644 index 000000000..1e85e633b --- /dev/null +++ b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs @@ -0,0 +1,38 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Runs unit tests on the extension methods +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.UnitTests +{ + using System; + using Common.Extensions; + using NUnit.Framework; + + /// + /// Provides a test harness for the integer extension class + /// + [TestFixture] + public class IntegerExtensionsUnitTests + { + /// + /// Tests the "ToByte" extension + /// + /// Integer input + /// Expected result + [Test] + [TestCase(21, 0x15)] + [TestCase(190, 0xBE)] + [TestCase(3156, 0xFF)] + public void ToByteTest(int input, byte expected) + { + var result = input.ToByte(); + Assert.AreEqual(expected, result); + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index e715df657..b545a11d9 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -47,6 +47,7 @@ PreserveNewest + From 5c19c1f18df2c06163232b74bafde1eb891af706 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Fri, 4 Jul 2014 22:01:17 +0200 Subject: [PATCH 094/155] Unit tests some string extensions Former-commit-id: 86a9c83b1ecc00e2f966372a77c6956676b1d7fb --- .../Extensions/StringExtensionsUnitTests.cs | 91 +++++++++++++++++++ .../ImageProcessor.UnitTests.csproj | 1 + 2 files changed, 92 insertions(+) create mode 100644 src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs new file mode 100644 index 000000000..d1fefa395 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -0,0 +1,91 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Provides a test harness for the string extensions +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.UnitTests +{ + using System; + using Common.Extensions; + using NUnit.Framework; + + /// + /// Test harness for the string extensions + /// + [TestFixture] + public class StringExtensionsUnitTests + { + /// + /// Tests the MD5 fingerprint + /// + /// The input value + /// The expexted output of the hash + [Test] + [TestCase("test input", "2e7f7a62eabf0993239ca17c78c464d9")] + [TestCase("lorem ipsum dolor", "96ee002fee25e8b675a477c9750fa360")] + [TestCase("LoReM IpSuM DoLoR", "41e201da794c7fbdb8ce5526a71c8c83")] + [TestCase("1234567890", "e15e31c3d8898c92ab172a4311be9e84")] + public void TestToMd5Fingerprint(string input, string expected) + { + var result = input.ToMD5Fingerprint(); + var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + Assert.True(comparison); + } + + /// + /// Tests the SHA-1 fingerprint + /// + /// The input value + /// The expexted output of the hash + [Test] + [TestCase("test input", "49883b34e5a0f48224dd6230f471e9dc1bdbeaf5")] + [TestCase("lorem ipsum dolor", "75899ad8827a32493928903aecd6e931bf36f967")] + [TestCase("LoReM IpSuM DoLoR", "2f44519afae72fc0837b72c6b53cb11338a1f916")] + [TestCase("1234567890", "01b307acba4f54f55aafc33bb06bbbf6ca803e9a")] + public void TestToSHA1Fingerprint(string input, string expected) + { + var result = input.ToSHA1Fingerprint(); + var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + Assert.True(comparison); + } + + /// + /// Tests the SHA-256 fingerprint + /// + /// The input value + /// The expexted output of the hash + [Test] + [TestCase("test input", "9dfe6f15d1ab73af898739394fd22fd72a03db01834582f24bb2e1c66c7aaeae")] + [TestCase("lorem ipsum dolor", "ed03353266c993ea9afb9900a3ca688ddec1656941b1ca15ee1650a022616dfa")] + [TestCase("LoReM IpSuM DoLoR", "55f6cb90ba5cd8eeb6f5f16f083ebcd48ea06c34cc5aed8e33246fc3153d3898")] + [TestCase("1234567890", "c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646")] + public void TestToSHA256Fingerprint(string input, string expected) + { + var result = input.ToSHA256Fingerprint(); + var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + Assert.True(comparison); + } + + /// + /// Tests the SHA-512 fingerprint + /// + /// The input value + /// The expexted output of the hash + [Test] + [TestCase("test input", "40aa1b203c9d8ee150b21c3c7cda8261492e5420c5f2b9f7380700e094c303b48e62f319c1da0e32eb40d113c5f1749cc61aeb499167890ab82f2cc9bb706971")] + [TestCase("lorem ipsum dolor", "cd813e13d1d3919cdccc31c19d8f8b70bd25e9819f8770a011c8c7a6228536e6c9427b338cd732f2da3c0444dfebef838b745cdaf3fd5dcba8db24fc83a3f6ef")] + [TestCase("LoReM IpSuM DoLoR", "3e4704d31f838456c0a5f0892afd392fbc79649a029d017b8104ebd00e2816d94ab4629f731765bf655088b130c51f6f47ca2f8b047749dbd992cf45e89ff431")] + [TestCase("1234567890", "12b03226a6d8be9c6e8cd5e55dc6c7920caaa39df14aab92d5e3ea9340d1c8a4d3d0b8e4314f1f6ef131ba4bf1ceb9186ab87c801af0d5c95b1befb8cedae2b9")] + public void TestToSHA512Fingerprint(string input, string expected) + { + var result = input.ToSHA512Fingerprint(); + var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + Assert.True(comparison); + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index b545a11d9..5b6bc12d1 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -48,6 +48,7 @@ + From 7b369dc51a3d4f0c29cff62ac8d8f2d320a261a0 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Fri, 4 Jul 2014 22:31:53 +0200 Subject: [PATCH 095/155] Adds unit tests for some more string extensions Former-commit-id: 1af9789d4c15050ae0c9234e1101083c0884bb25 --- .../Extensions/StringExtensionsUnitTests.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs index d1fefa395..17cc4c753 100644 --- a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -11,6 +11,7 @@ namespace ImageProcessor.UnitTests { using System; + using System.Collections.Generic; using Common.Extensions; using NUnit.Framework; @@ -87,5 +88,41 @@ namespace ImageProcessor.UnitTests var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } + + /// + /// Tests the pasing to an integer array + /// + [Test] + public void TestToIntegerArray() + { + Dictionary data = new Dictionary(); + data.Add("123-456,78-90", new int[] { 123, 456, 78, 90 }); + data.Add("87390174,741897498,74816,748297,57355", new int[] { 87390174, 741897498, 74816, 748297, 57355 }); + data.Add("1-2-3", new int[] { 1, 2, 3 }); + + foreach (var item in data) + { + var result = item.Key.ToPositiveIntegerArray(); + Assert.AreEqual(item.Value, result); + } + } + + /// + /// Tests the pasing to an float array + /// + [Test] + public void TestToFloatArray() + { + Dictionary data = new Dictionary(); + data.Add("12.3-4.56,78-9.0", new float[] { 12.3F, 4.56F, 78, 9 }); + data.Add("87390.174,7.41897498,748.16,748297,5.7355", new float[] { 87390.174F, 7.41897498F, 748.16F, 748297, 5.7355F }); + data.Add("1-2-3", new float[] { 1, 2, 3 }); + + foreach (var item in data) + { + var result = item.Key.ToPositiveFloatArray(); + Assert.AreEqual(item.Value, result); + } + } } } \ No newline at end of file From 8a6b8849d360b80e9730a1d95768b485c867bb85 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Fri, 4 Jul 2014 22:49:13 +0200 Subject: [PATCH 096/155] Tests a few more string extensions Former-commit-id: c442263a29c5247ec0c9cb568f64e4a85eb9c0f1 --- .../Extensions/StringExtensionsUnitTests.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs index 17cc4c753..70f3e83db 100644 --- a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -124,5 +124,45 @@ namespace ImageProcessor.UnitTests Assert.AreEqual(item.Value, result); } } + + /// + /// Tests if the value is a valid URI + /// + /// The value to test + /// Whether the value is correct + /// + /// The full RFC3986 does not seem to pass the test with the square brackets + /// + [Test] + [TestCase("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", true)] + [TestCase("-", true)] + [TestCase(".", true)] + [TestCase("_", true)] + [TestCase("~", true)] + [TestCase(":", true)] + [TestCase("/", true)] + [TestCase("?", true)] + [TestCase("#", true)] + [TestCase("[", false)] + [TestCase("]", false)] + [TestCase("@", true)] + [TestCase("!", true)] + [TestCase("$", true)] + [TestCase("&", true)] + [TestCase("'", true)] + [TestCase("(", true)] + [TestCase(")", true)] + [TestCase("*", true)] + [TestCase("+", true)] + [TestCase(",", true)] + [TestCase(";", true)] + [TestCase("=", true)] + [TestCase("lorem ipsum", false)] + [TestCase("é", false)] + public void TestIsValidUri(string input, bool expected) + { + var result = input.IsValidVirtualPathName(); + Assert.AreEqual(expected, result); + } } } \ No newline at end of file From 4263386605ccd1e89dab44f7d50e2766a6937f14 Mon Sep 17 00:00:00 2001 From: James South Date: Sat, 5 Jul 2014 10:24:13 +0100 Subject: [PATCH 097/155] Making project build on Mono Former-commit-id: b42a4bfe055f7e9c19adc27d347302da372ecb83 --- src/ImageProcessor/ImageProcessor.csproj | 6 +++--- src/ImageProcessor/Imaging/Formats/FormatBase.cs | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 1c5b26e80..b28b102e3 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -3,8 +3,6 @@ Debug AnyCPU - 8.0.30703 - 2.0 {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} Library Properties @@ -15,6 +13,7 @@ ..\ true Client + False true @@ -25,7 +24,6 @@ prompt 4 bin\Debug\ImageProcessor.XML - false pdbonly @@ -46,6 +44,8 @@ prompt false true + 4 + false diff --git a/src/ImageProcessor/Imaging/Formats/FormatBase.cs b/src/ImageProcessor/Imaging/Formats/FormatBase.cs index ea00e82a2..189bad8c3 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatBase.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatBase.cs @@ -90,7 +90,11 @@ namespace ImageProcessor.Imaging.Formats /// public virtual Image Load(Stream stream) { +#if !__MonoCS__ return Image.FromStream(stream, true); +#else + return Image.FromStream(stream); +#endif } /// From be7b5b356aaad02b97bfc15a4a8946762ca62653 Mon Sep 17 00:00:00 2001 From: James South Date: Sat, 5 Jul 2014 13:31:06 +0100 Subject: [PATCH 098/155] Adding updated tests and reducing image sizes. Former-commit-id: a218abcd82c75f27d13c7662d5585d850158cd6f --- .../Extensions/DoubleExtensionsUnitTests.cs | 15 ++-- .../Extensions/IntegerExtensionsUnitTests.cs | 5 +- .../Extensions/StringExtensionsUnitTests.cs | 90 ++++++++++++------- .../Images/autorotate.jpg.REMOVED.git-id | 2 +- .../cmyk-profile-euroscale.jpg.REMOVED.git-id | 2 +- .../Images/cmyk.jpg.REMOVED.git-id | 2 +- .../color-vision-test.gif.REMOVED.git-id | 2 +- .../Images/exif-Tulips.jpg.REMOVED.git-id | 2 +- .../Images/exif-rocks.jpg.REMOVED.git-id | 2 +- .../format-Penguins-8bit.png.REMOVED.git-id | 2 +- .../Images/format-Penguins.bmp.REMOVED.git-id | 2 +- .../Images/format-Penguins.gif.REMOVED.git-id | 2 +- .../Images/format-Penguins.jpg.REMOVED.git-id | 2 +- .../Images/format-Penguins.png.REMOVED.git-id | 2 +- .../Images/format-animated.gif | 3 - .../Images/format-animated.gif.REMOVED.git-id | 1 + .../Images/hi-color.png | 4 +- .../Images/hi-contrast.jpg | 4 +- .../Images/hi-saturation.jpg | 4 +- .../profile-adobe-rgb.jpg.REMOVED.git-id | 2 +- .../Images/profile-srgb.jpg.REMOVED.git-id | 2 +- .../Images/size-Penguins-200.jpg | 4 +- .../Images/text-over-transparent.png | 4 +- .../Images/udendørs.jpg | 3 + .../Images/udendørs.jpg.REMOVED.git-id | 1 - src/ImageProcessor/ImageFactory.cs | 5 +- .../Imaging/Formats/GifEncoder.cs | 10 +-- .../Imaging/Formats/JpegFormat.cs | 2 +- src/ImageProcessorConsole/Program.cs | 19 ++-- .../images/output/120430.gif.REMOVED.git-id | 2 +- .../images/output/Tl4Yb.gif.REMOVED.git-id | 2 +- .../images/output/circle.png | 3 + .../images/output/nLpfllv.gif.REMOVED.git-id | 2 +- 33 files changed, 116 insertions(+), 93 deletions(-) delete mode 100644 src/ImageProcessor.UnitTests/Images/format-animated.gif create mode 100644 src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/udendørs.jpg delete mode 100644 src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id create mode 100644 src/ImageProcessorConsole/images/output/circle.png diff --git a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs index 108a9a246..cba1c07bc 100644 --- a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs @@ -8,9 +8,8 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.UnitTests +namespace ImageProcessor.UnitTests.Extensions { - using System; using System.Collections.Generic; using Common.Extensions; using NUnit.Framework; @@ -32,11 +31,13 @@ namespace ImageProcessor.UnitTests [TestFixtureSetUp] public void Init() { - this.doubleToByteTests = new Dictionary(); - this.doubleToByteTests.Add(-10, 0x0); - this.doubleToByteTests.Add(1.5, 0x1); - this.doubleToByteTests.Add(25.7, 0x19); - this.doubleToByteTests.Add(1289047, 0xFF); + this.doubleToByteTests = new Dictionary + { + { -10, 0x0 }, + { 1.5, 0x1 }, + { 25.7, 0x19 }, + { 1289047, 0xFF } + }; } /// diff --git a/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs index 1e85e633b..2adbe3b17 100644 --- a/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs @@ -8,9 +8,8 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.UnitTests +namespace ImageProcessor.UnitTests.Extensions { - using System; using Common.Extensions; using NUnit.Framework; @@ -31,7 +30,7 @@ namespace ImageProcessor.UnitTests [TestCase(3156, 0xFF)] public void ToByteTest(int input, byte expected) { - var result = input.ToByte(); + byte result = input.ToByte(); Assert.AreEqual(expected, result); } } diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs index 70f3e83db..c89c09dcd 100644 --- a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -8,11 +8,11 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.UnitTests +namespace ImageProcessor.UnitTests.Extensions { using System; using System.Collections.Generic; - using Common.Extensions; + using ImageProcessor.Common.Extensions; using NUnit.Framework; /// @@ -25,7 +25,7 @@ namespace ImageProcessor.UnitTests /// Tests the MD5 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "2e7f7a62eabf0993239ca17c78c464d9")] [TestCase("lorem ipsum dolor", "96ee002fee25e8b675a477c9750fa360")] @@ -33,8 +33,8 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "e15e31c3d8898c92ab172a4311be9e84")] public void TestToMd5Fingerprint(string input, string expected) { - var result = input.ToMD5Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToMD5Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } @@ -42,7 +42,7 @@ namespace ImageProcessor.UnitTests /// Tests the SHA-1 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "49883b34e5a0f48224dd6230f471e9dc1bdbeaf5")] [TestCase("lorem ipsum dolor", "75899ad8827a32493928903aecd6e931bf36f967")] @@ -50,8 +50,8 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "01b307acba4f54f55aafc33bb06bbbf6ca803e9a")] public void TestToSHA1Fingerprint(string input, string expected) { - var result = input.ToSHA1Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToSHA1Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } @@ -59,7 +59,7 @@ namespace ImageProcessor.UnitTests /// Tests the SHA-256 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "9dfe6f15d1ab73af898739394fd22fd72a03db01834582f24bb2e1c66c7aaeae")] [TestCase("lorem ipsum dolor", "ed03353266c993ea9afb9900a3ca688ddec1656941b1ca15ee1650a022616dfa")] @@ -67,8 +67,8 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646")] public void TestToSHA256Fingerprint(string input, string expected) { - var result = input.ToSHA256Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToSHA256Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } @@ -76,7 +76,7 @@ namespace ImageProcessor.UnitTests /// Tests the SHA-512 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "40aa1b203c9d8ee150b21c3c7cda8261492e5420c5f2b9f7380700e094c303b48e62f319c1da0e32eb40d113c5f1749cc61aeb499167890ab82f2cc9bb706971")] [TestCase("lorem ipsum dolor", "cd813e13d1d3919cdccc31c19d8f8b70bd25e9819f8770a011c8c7a6228536e6c9427b338cd732f2da3c0444dfebef838b745cdaf3fd5dcba8db24fc83a3f6ef")] @@ -84,49 +84,73 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "12b03226a6d8be9c6e8cd5e55dc6c7920caaa39df14aab92d5e3ea9340d1c8a4d3d0b8e4314f1f6ef131ba4bf1ceb9186ab87c801af0d5c95b1befb8cedae2b9")] public void TestToSHA512Fingerprint(string input, string expected) { - var result = input.ToSHA512Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToSHA512Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } /// - /// Tests the pasing to an integer array + /// Tests the passing to an integer array /// [Test] public void TestToIntegerArray() { - Dictionary data = new Dictionary(); - data.Add("123-456,78-90", new int[] { 123, 456, 78, 90 }); - data.Add("87390174,741897498,74816,748297,57355", new int[] { 87390174, 741897498, 74816, 748297, 57355 }); - data.Add("1-2-3", new int[] { 1, 2, 3 }); + Dictionary data = new Dictionary + { + { + "123-456,78-90", + new[] { 123, 456, 78, 90 } + }, + { + "87390174,741897498,74816,748297,57355", + new[] + { + 87390174, 741897498, 74816, + 748297, 57355 + } + }, + { "1-2-3", new[] { 1, 2, 3 } } + }; - foreach (var item in data) + foreach (KeyValuePair item in data) { - var result = item.Key.ToPositiveIntegerArray(); + int[] result = item.Key.ToPositiveIntegerArray(); Assert.AreEqual(item.Value, result); } } /// - /// Tests the pasing to an float array + /// Tests the passing to an float array /// [Test] public void TestToFloatArray() { - Dictionary data = new Dictionary(); - data.Add("12.3-4.56,78-9.0", new float[] { 12.3F, 4.56F, 78, 9 }); - data.Add("87390.174,7.41897498,748.16,748297,5.7355", new float[] { 87390.174F, 7.41897498F, 748.16F, 748297, 5.7355F }); - data.Add("1-2-3", new float[] { 1, 2, 3 }); + Dictionary data = new Dictionary + { + { + "12.3-4.56,78-9.0", + new[] { 12.3F, 4.56F, 78, 9 } + }, + { + "87390.174,7.41897498,748.16,748297,5.7355", + new[] + { + 87390.174F, 7.41897498F, + 748.16F, 748297, 5.7355F + } + }, + { "1-2-3", new float[] { 1, 2, 3 } } + }; - foreach (var item in data) + foreach (KeyValuePair item in data) { - var result = item.Key.ToPositiveFloatArray(); + float[] result = item.Key.ToPositiveFloatArray(); Assert.AreEqual(item.Value, result); } } /// - /// Tests if the value is a valid URI + /// Tests if the value is a valid URI path name. I.E the path part of a uri. /// /// The value to test /// Whether the value is correct @@ -139,10 +163,10 @@ namespace ImageProcessor.UnitTests [TestCase(".", true)] [TestCase("_", true)] [TestCase("~", true)] - [TestCase(":", true)] + [TestCase(":", false)] [TestCase("/", true)] [TestCase("?", true)] - [TestCase("#", true)] + [TestCase("#", false)] [TestCase("[", false)] [TestCase("]", false)] [TestCase("@", true)] @@ -159,9 +183,9 @@ namespace ImageProcessor.UnitTests [TestCase("=", true)] [TestCase("lorem ipsum", false)] [TestCase("é", false)] - public void TestIsValidUri(string input, bool expected) + public void TestIsValidUriPathName(string input, bool expected) { - var result = input.IsValidVirtualPathName(); + bool result = input.IsValidVirtualPathName(); Assert.AreEqual(expected, result); } } diff --git a/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id index 19785c8e5..1b5e335ff 100644 --- a/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id @@ -1 +1 @@ -85a8ae18f9955def2b42ba9240bce4de1bfe5781 \ No newline at end of file +75b37593bb2e505bf4fbe874eaf30debd6161c2e \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id index 7747bdaae..11eb19931 100644 --- a/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id @@ -1 +1 @@ -13492524f9d984c12adfe6183a4c1d92fb11ec4e \ No newline at end of file +d0a1a39a6729e826098ae5e987c22c34c989b7e3 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id index 30b05146b..9ba0b9f39 100644 --- a/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id @@ -1 +1 @@ -ed725726e4ac1ffeac821664af14865a66fa933f \ No newline at end of file +9160894da31fedebb1fcd64eb57ca173187c63a6 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id index 5c4f4195d..ed1d0b80b 100644 --- a/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id @@ -1 +1 @@ -35a926115b13b61dc37308f8d903b42d14f92924 \ No newline at end of file +b169fac4f1591e81e91c0bb6fed6dcf62a34c80e \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id index 84b9aff85..20704f4a9 100644 --- a/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id @@ -1 +1 @@ -54c51eb6a86f31a42433b8167470fb18dad32c7d \ No newline at end of file +9d7e7964a2285363171929315b15ec69f14831ef \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id index 41c6c25df..2e03e238f 100644 --- a/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id @@ -1 +1 @@ -33b6912af301bf216ee81d82b2c3ce6c49e03021 \ No newline at end of file +be31c9c0dea90586e2965208611fad024f6a5b08 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id index aa9a70e0f..c48cdc177 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id @@ -1 +1 @@ -c3d556d9d486b8b8b49cdbcc9c12a9d3a2db4c1f \ No newline at end of file +51ccec74a0351599de104f166b32d2860acaf089 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id index 74f69293c..9ba53bc67 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id @@ -1 +1 @@ -8150b46ab27c62ba51aaba551eef3f1a30f08de9 \ No newline at end of file +d7adbea2db4e3388541e31a229e5741677aaa7fd \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id index ce873d473..225d59af3 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id @@ -1 +1 @@ -6ad3b846d4697584ff601ac481b14a4d3bbb5736 \ No newline at end of file +b301e58d431a78d3f17be53be1cdc94c86286389 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id index ad4371113..06482dbd9 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id @@ -1 +1 @@ -030ab8a685bebb796c24cc710edd9e69859164f6 \ No newline at end of file +ee5a15e7f8fc2655d5c1fc736a05857ab3d885bd \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id index 78062a0e7..4ab6b372b 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id @@ -1 +1 @@ -a2c796fbb7de948230a22982ab74892891dd5198 \ No newline at end of file +b6434b5a35e989d4fa71ede1a8316fedeee7ae5f \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-animated.gif b/src/ImageProcessor.UnitTests/Images/format-animated.gif deleted file mode 100644 index ac36f6f25..000000000 --- a/src/ImageProcessor.UnitTests/Images/format-animated.gif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6212724b3e94908939823d0753b4307923b65d7a27f51823dd3ba7656543349c -size 22525 diff --git a/src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id new file mode 100644 index 000000000..ac3664d5f --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id @@ -0,0 +1 @@ +a41fb1117e1d730a4a488dcb67e0b867aa3c614e \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/hi-color.png b/src/ImageProcessor.UnitTests/Images/hi-color.png index a9de4cc09..cc8677aa8 100644 --- a/src/ImageProcessor.UnitTests/Images/hi-color.png +++ b/src/ImageProcessor.UnitTests/Images/hi-color.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:977cc9071257655c9923d267ea5bd417b69754367c2f1aa8765247b68e2bb878 -size 1539 +oid sha256:2f1263641d5e6ed29e96f211f4d78870496c29912245ac7d3c48716ee0ede313 +size 23922 diff --git a/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg b/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg index 98ac863a2..94581b505 100644 --- a/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg +++ b/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c0ce9e02f2a4663a0a0ed433d5594be87b3fa0387bc8335e80f84d59c34aa424 -size 51058 +oid sha256:1d6fb72b9710edcfba0f75dcd349712d5e940ec87650a08380f8180e6c9a62b2 +size 34996 diff --git a/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg b/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg index b56f9a83c..3405e88a5 100644 --- a/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg +++ b/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6b2012b2eda13a531645c287c254ae5de0e9070368cb4bc806f48314e0464ccd -size 33850 +oid sha256:fa947c3b5904e0138c359d7ccd81ad3209330880d412f1b09dfe32a355ee6d3b +size 51300 diff --git a/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id index 4ffbf7a8a..8064ffb21 100644 --- a/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id @@ -1 +1 @@ -e29f32091aa13a5b047ccd960f3dc6da9656c84b \ No newline at end of file +189f79f9b9604c5413aba928662d84edd426142d \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id index f409bc82b..101151778 100644 --- a/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id @@ -1 +1 @@ -ab9deaa737f9db9bf0f563e7843ba9b7981cec86 \ No newline at end of file +f731bdf700d2718f528317263264e5466374c5e5 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg b/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg index 07605996f..4520c9c95 100644 --- a/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg +++ b/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:672de68017f17260126901065f1c6ade2b2981d33dea0dea1606bf7cfb6fdcf3 -size 10119 +oid sha256:f0b24fb4937a0416bf62f7a743d2679c7eb2014bceb1a898826fb08e6231bad7 +size 37476 diff --git a/src/ImageProcessor.UnitTests/Images/text-over-transparent.png b/src/ImageProcessor.UnitTests/Images/text-over-transparent.png index 33d4962bc..1ae73c91f 100644 --- a/src/ImageProcessor.UnitTests/Images/text-over-transparent.png +++ b/src/ImageProcessor.UnitTests/Images/text-over-transparent.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2322d8dd81df86b8135d399743ea758ad26d6b2ccdcc704e2687ae72d0c187e7 -size 7317 +oid sha256:ba300af935752628b37a7f892369e7229f4f6ae701522cdedeefcf5c2b251afa +size 7680 diff --git a/src/ImageProcessor.UnitTests/Images/udendørs.jpg b/src/ImageProcessor.UnitTests/Images/udendørs.jpg new file mode 100644 index 000000000..84fb0cc3a --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/udendørs.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65434ff6c6d5f502308e627fcfbe1d26402b83fb5efba15749ffbb5e8795995e +size 55987 diff --git a/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id deleted file mode 100644 index 0db1445a2..000000000 --- a/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -4d040d9aa3519b3d2303419d1f03eebebf88e956 \ No newline at end of file diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index f2f573268..7e37983c3 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -158,9 +158,10 @@ namespace ImageProcessor this.CurrentImageFormat = format; // Always load the data. - foreach (PropertyItem propertyItem in this.Image.PropertyItems) + // TODO. Some custom data doesn't seem to get copied by default methods. + foreach (int id in this.Image.PropertyIdList) { - this.ExifPropertyItems[propertyItem.Id] = propertyItem; + this.ExifPropertyItems[id] = this.Image.GetPropertyItem(id); } this.ShouldProcess = true; diff --git a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs index 662ad314c..b7650d099 100644 --- a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs +++ b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs @@ -282,17 +282,17 @@ namespace ImageProcessor.Imaging.Formats { int count = this.repeatCount.GetValueOrDefault(0); - // File Header sinature and version. + // File Header signature and version. this.WriteString(FileType); this.WriteString(FileVersion); // Write the logical screen descriptor. this.WriteShort(this.width.GetValueOrDefault(w)); // Initial Logical Width this.WriteShort(this.height.GetValueOrDefault(h)); // Initial Logical Height - + // Read the global color table info. sourceGif.Position = SourceGlobalColorInfoPosition; - this.WriteByte(sourceGif.ReadByte()); + this.WriteByte(sourceGif.ReadByte()); this.WriteByte(0); // Background Color Index this.WriteByte(0); // Pixel aspect ratio @@ -301,7 +301,7 @@ namespace ImageProcessor.Imaging.Formats // The different browsers interpret the spec differently when adding a loop. // If the loop count is one IE and FF < 3 (incorrectly) loop an extra number of times. // Removing the Netscape header should fix this. - if (count != 1) + if (count > -1 && count != 1) { // Application Extension Header this.WriteShort(ApplicationExtensionBlockIdentifier); @@ -357,7 +357,7 @@ namespace ImageProcessor.Imaging.Formats this.WriteShort(GraphicControlExtensionBlockIdentifier); // Identifier this.WriteByte(GraphicControlExtensionBlockSize); // Block Size this.WriteByte(blockhead[3] & 0xf7 | 0x08); // Setting disposal flag - this.WriteShort(Convert.ToInt32(frameDelay / 10)); // Setting frame delay + this.WriteShort(Convert.ToInt32(frameDelay / 10.0f)); // Setting frame delay this.WriteByte(blockhead[6]); // Transparent color index this.WriteByte(0); // Terminator } diff --git a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs index ae5fd05c3..f7ff73c66 100644 --- a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs @@ -75,7 +75,7 @@ namespace ImageProcessor.Imaging.Formats { base.ApplyProcessor(processor, factory); - // Set the property item information from any Exif metadata. + // Set the property item information from any Exif metadata. // We do this here so that they can be changed between processor methods. if (factory.PreserveExifData) { diff --git a/src/ImageProcessorConsole/Program.cs b/src/ImageProcessorConsole/Program.cs index 248fe1d7f..5bacb50dd 100644 --- a/src/ImageProcessorConsole/Program.cs +++ b/src/ImageProcessorConsole/Program.cs @@ -15,9 +15,7 @@ namespace ImageProcessorConsole using System.Drawing; using System.IO; using System.Linq; - using ImageProcessor; - using ImageProcessor.Imaging.Formats; /// /// The program. @@ -33,6 +31,7 @@ namespace ImageProcessorConsole public static void Main(string[] args) { string path = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath; + // ReSharper disable once AssignNullToNotNullAttribute string resolvedPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\input")); DirectoryInfo di = new DirectoryInfo(resolvedPath); @@ -41,10 +40,8 @@ namespace ImageProcessorConsole di.Create(); } - //FileInfo[] files = di.GetFiles("*.jpg"); - //FileInfo[] files = di.GetFiles(); - IEnumerable files = GetFilesByExtensions(di, ".gif", ".webp"); - + IEnumerable files = GetFilesByExtensions(di, ".gif"); + //IEnumerable files = GetFilesByExtensions(di, ".gif", ".webp", ".bmp", ".jpg", ".png"); foreach (FileInfo fileInfo in files) { @@ -53,18 +50,13 @@ namespace ImageProcessorConsole // ImageProcessor using (MemoryStream inStream = new MemoryStream(photoBytes)) { - using (ImageFactory imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory(true)) { Size size = new Size(200, 200); // Load, resize, set the format and quality and save an image. imageFactory.Load(inStream) - //.AutoRotate() .Constrain(size) - //.Format(new WebPFormat()) - //.Quality(5) - // ReSharper disable once AssignNullToNotNullAttribute - // .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".webp"))); .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name))); } } @@ -74,7 +66,10 @@ namespace ImageProcessorConsole public static IEnumerable GetFilesByExtensions(DirectoryInfo dir, params string[] extensions) { if (extensions == null) + { throw new ArgumentNullException("extensions"); + } + IEnumerable files = dir.EnumerateFiles(); return files.Where(f => extensions.Contains(f.Extension, StringComparer.OrdinalIgnoreCase)); } diff --git a/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id index 71ce555c1..4767fd13d 100644 --- a/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id +++ b/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id @@ -1 +1 @@ -30ec5c05548fd350f9b7c699715848b9fbfb8ca9 \ No newline at end of file +6f3f997e323adb1fce142930d86338efacffc3fd \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id index 6515d65a0..f0f194a2b 100644 --- a/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id +++ b/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id @@ -1 +1 @@ -fdc62fc2d056ab885eb9e8fd12b9155ee86d7c43 \ No newline at end of file +3ab082661fc5d88f88643c47409e196d66e26d4b \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/circle.png b/src/ImageProcessorConsole/images/output/circle.png new file mode 100644 index 000000000..a96f1ecf3 --- /dev/null +++ b/src/ImageProcessorConsole/images/output/circle.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f31110b7933864eff3b149371c962174a8855a1c65f4fee7cb3bc63a79b71467 +size 2905 diff --git a/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id index c07be0b0f..b8684cd60 100644 --- a/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id +++ b/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id @@ -1 +1 @@ -77cce70db3722920d60f4b17a45a5e390a09838a \ No newline at end of file +e2c2fbac64987ad26e19f5d2721fcaa60fee843d \ No newline at end of file From 3b07002e3a9443654bd27ef93f4ba708d2b3c899 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 22:54:11 +0200 Subject: [PATCH 099/155] Adds unit tests for double extension methods + Fixes a build problem on Mono Former-commit-id: 8207e6dc22d5d71288274a2ca58e3346c59224b8 --- .../Extensions/DoubleExtensionsUnitTests.cs | 55 +++++++++++++++++++ .../ImageProcessor.UnitTests.csproj | 4 ++ src/ImageProcessor/ImageProcessor.csproj | 6 +- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs new file mode 100644 index 000000000..108a9a246 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs @@ -0,0 +1,55 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Runs unit tests on the extension methods +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.UnitTests +{ + using System; + using System.Collections.Generic; + using Common.Extensions; + using NUnit.Framework; + + /// + /// Test harness for the DoubleExtensions extension methods + /// + [TestFixture] + public class DoubleExtensionsUnitTests + { + /// + /// Stores the values to test for the ToByte() extension method + /// + private Dictionary doubleToByteTests; + + /// + /// Sets up the values for the tests + /// + [TestFixtureSetUp] + public void Init() + { + this.doubleToByteTests = new Dictionary(); + this.doubleToByteTests.Add(-10, 0x0); + this.doubleToByteTests.Add(1.5, 0x1); + this.doubleToByteTests.Add(25.7, 0x19); + this.doubleToByteTests.Add(1289047, 0xFF); + } + + /// + /// Tests the double to byte conversion + /// + [Test] + public void TestDoubleToByte() + { + foreach (var item in this.doubleToByteTests) + { + var result = item.Key.ToByte(); + Assert.AreEqual(item.Value, result); + } + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index c872dbbb8..e715df657 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -46,6 +46,7 @@ PreserveNewest + @@ -127,4 +128,7 @@ + + + \ No newline at end of file diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 1c5b26e80..c21b78194 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -3,8 +3,6 @@ Debug AnyCPU - 8.0.30703 - 2.0 {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} Library Properties @@ -25,7 +23,6 @@ prompt 4 bin\Debug\ImageProcessor.XML - false pdbonly @@ -46,6 +43,8 @@ prompt false true + 4 + false @@ -57,6 +56,7 @@ + From bd81aec87506b44279bce49026b35444341d51fa Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sun, 29 Jun 2014 23:41:33 +0200 Subject: [PATCH 100/155] Adds a few unit tests for integer extension methods Former-commit-id: a188cb5d3f7458ed0c76a01c774fab95f19d3871 --- .../Extensions/IntegerExtensionsUnitTests.cs | 38 +++++++++++++++++++ .../ImageProcessor.UnitTests.csproj | 1 + 2 files changed, 39 insertions(+) create mode 100644 src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs new file mode 100644 index 000000000..1e85e633b --- /dev/null +++ b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs @@ -0,0 +1,38 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Runs unit tests on the extension methods +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.UnitTests +{ + using System; + using Common.Extensions; + using NUnit.Framework; + + /// + /// Provides a test harness for the integer extension class + /// + [TestFixture] + public class IntegerExtensionsUnitTests + { + /// + /// Tests the "ToByte" extension + /// + /// Integer input + /// Expected result + [Test] + [TestCase(21, 0x15)] + [TestCase(190, 0xBE)] + [TestCase(3156, 0xFF)] + public void ToByteTest(int input, byte expected) + { + var result = input.ToByte(); + Assert.AreEqual(expected, result); + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index e715df657..b545a11d9 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -47,6 +47,7 @@ PreserveNewest + From d4ecc319de0b13687913d4a328699b53b5bd7d22 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Fri, 4 Jul 2014 22:01:17 +0200 Subject: [PATCH 101/155] Unit tests some string extensions Former-commit-id: 86f7663ed5656b3241f9a7ea8b1e532140399e7b --- .../Extensions/StringExtensionsUnitTests.cs | 91 +++++++++++++++++++ .../ImageProcessor.UnitTests.csproj | 1 + 2 files changed, 92 insertions(+) create mode 100644 src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs new file mode 100644 index 000000000..d1fefa395 --- /dev/null +++ b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -0,0 +1,91 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Provides a test harness for the string extensions +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.UnitTests +{ + using System; + using Common.Extensions; + using NUnit.Framework; + + /// + /// Test harness for the string extensions + /// + [TestFixture] + public class StringExtensionsUnitTests + { + /// + /// Tests the MD5 fingerprint + /// + /// The input value + /// The expexted output of the hash + [Test] + [TestCase("test input", "2e7f7a62eabf0993239ca17c78c464d9")] + [TestCase("lorem ipsum dolor", "96ee002fee25e8b675a477c9750fa360")] + [TestCase("LoReM IpSuM DoLoR", "41e201da794c7fbdb8ce5526a71c8c83")] + [TestCase("1234567890", "e15e31c3d8898c92ab172a4311be9e84")] + public void TestToMd5Fingerprint(string input, string expected) + { + var result = input.ToMD5Fingerprint(); + var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + Assert.True(comparison); + } + + /// + /// Tests the SHA-1 fingerprint + /// + /// The input value + /// The expexted output of the hash + [Test] + [TestCase("test input", "49883b34e5a0f48224dd6230f471e9dc1bdbeaf5")] + [TestCase("lorem ipsum dolor", "75899ad8827a32493928903aecd6e931bf36f967")] + [TestCase("LoReM IpSuM DoLoR", "2f44519afae72fc0837b72c6b53cb11338a1f916")] + [TestCase("1234567890", "01b307acba4f54f55aafc33bb06bbbf6ca803e9a")] + public void TestToSHA1Fingerprint(string input, string expected) + { + var result = input.ToSHA1Fingerprint(); + var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + Assert.True(comparison); + } + + /// + /// Tests the SHA-256 fingerprint + /// + /// The input value + /// The expexted output of the hash + [Test] + [TestCase("test input", "9dfe6f15d1ab73af898739394fd22fd72a03db01834582f24bb2e1c66c7aaeae")] + [TestCase("lorem ipsum dolor", "ed03353266c993ea9afb9900a3ca688ddec1656941b1ca15ee1650a022616dfa")] + [TestCase("LoReM IpSuM DoLoR", "55f6cb90ba5cd8eeb6f5f16f083ebcd48ea06c34cc5aed8e33246fc3153d3898")] + [TestCase("1234567890", "c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646")] + public void TestToSHA256Fingerprint(string input, string expected) + { + var result = input.ToSHA256Fingerprint(); + var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + Assert.True(comparison); + } + + /// + /// Tests the SHA-512 fingerprint + /// + /// The input value + /// The expexted output of the hash + [Test] + [TestCase("test input", "40aa1b203c9d8ee150b21c3c7cda8261492e5420c5f2b9f7380700e094c303b48e62f319c1da0e32eb40d113c5f1749cc61aeb499167890ab82f2cc9bb706971")] + [TestCase("lorem ipsum dolor", "cd813e13d1d3919cdccc31c19d8f8b70bd25e9819f8770a011c8c7a6228536e6c9427b338cd732f2da3c0444dfebef838b745cdaf3fd5dcba8db24fc83a3f6ef")] + [TestCase("LoReM IpSuM DoLoR", "3e4704d31f838456c0a5f0892afd392fbc79649a029d017b8104ebd00e2816d94ab4629f731765bf655088b130c51f6f47ca2f8b047749dbd992cf45e89ff431")] + [TestCase("1234567890", "12b03226a6d8be9c6e8cd5e55dc6c7920caaa39df14aab92d5e3ea9340d1c8a4d3d0b8e4314f1f6ef131ba4bf1ceb9186ab87c801af0d5c95b1befb8cedae2b9")] + public void TestToSHA512Fingerprint(string input, string expected) + { + var result = input.ToSHA512Fingerprint(); + var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + Assert.True(comparison); + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index b545a11d9..5b6bc12d1 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -48,6 +48,7 @@ + From 71ef82145c324bbf7e2e986965cd4d3c5c80da05 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Fri, 4 Jul 2014 22:31:53 +0200 Subject: [PATCH 102/155] Adds unit tests for some more string extensions Former-commit-id: fe3875fa22e329b54839fd95ef8bcd245fb50e2e --- .../Extensions/StringExtensionsUnitTests.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs index d1fefa395..17cc4c753 100644 --- a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -11,6 +11,7 @@ namespace ImageProcessor.UnitTests { using System; + using System.Collections.Generic; using Common.Extensions; using NUnit.Framework; @@ -87,5 +88,41 @@ namespace ImageProcessor.UnitTests var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } + + /// + /// Tests the pasing to an integer array + /// + [Test] + public void TestToIntegerArray() + { + Dictionary data = new Dictionary(); + data.Add("123-456,78-90", new int[] { 123, 456, 78, 90 }); + data.Add("87390174,741897498,74816,748297,57355", new int[] { 87390174, 741897498, 74816, 748297, 57355 }); + data.Add("1-2-3", new int[] { 1, 2, 3 }); + + foreach (var item in data) + { + var result = item.Key.ToPositiveIntegerArray(); + Assert.AreEqual(item.Value, result); + } + } + + /// + /// Tests the pasing to an float array + /// + [Test] + public void TestToFloatArray() + { + Dictionary data = new Dictionary(); + data.Add("12.3-4.56,78-9.0", new float[] { 12.3F, 4.56F, 78, 9 }); + data.Add("87390.174,7.41897498,748.16,748297,5.7355", new float[] { 87390.174F, 7.41897498F, 748.16F, 748297, 5.7355F }); + data.Add("1-2-3", new float[] { 1, 2, 3 }); + + foreach (var item in data) + { + var result = item.Key.ToPositiveFloatArray(); + Assert.AreEqual(item.Value, result); + } + } } } \ No newline at end of file From 7a3dc8e9603673b604d2c325076b7f27cd563d8b Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Fri, 4 Jul 2014 22:49:13 +0200 Subject: [PATCH 103/155] Tests a few more string extensions Former-commit-id: df69ccf584bf3b30433e2ee51808aeaf471d2fb3 --- .../Extensions/StringExtensionsUnitTests.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs index 17cc4c753..70f3e83db 100644 --- a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -124,5 +124,45 @@ namespace ImageProcessor.UnitTests Assert.AreEqual(item.Value, result); } } + + /// + /// Tests if the value is a valid URI + /// + /// The value to test + /// Whether the value is correct + /// + /// The full RFC3986 does not seem to pass the test with the square brackets + /// + [Test] + [TestCase("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", true)] + [TestCase("-", true)] + [TestCase(".", true)] + [TestCase("_", true)] + [TestCase("~", true)] + [TestCase(":", true)] + [TestCase("/", true)] + [TestCase("?", true)] + [TestCase("#", true)] + [TestCase("[", false)] + [TestCase("]", false)] + [TestCase("@", true)] + [TestCase("!", true)] + [TestCase("$", true)] + [TestCase("&", true)] + [TestCase("'", true)] + [TestCase("(", true)] + [TestCase(")", true)] + [TestCase("*", true)] + [TestCase("+", true)] + [TestCase(",", true)] + [TestCase(";", true)] + [TestCase("=", true)] + [TestCase("lorem ipsum", false)] + [TestCase("é", false)] + public void TestIsValidUri(string input, bool expected) + { + var result = input.IsValidVirtualPathName(); + Assert.AreEqual(expected, result); + } } } \ No newline at end of file From 44677a101280ba97f92b49676743f67236afc082 Mon Sep 17 00:00:00 2001 From: James South Date: Sat, 5 Jul 2014 10:24:13 +0100 Subject: [PATCH 104/155] Making project build on Mono Former-commit-id: 78fbbc22918ba951d74ac2b16a1c996b0ca21661 --- src/ImageProcessor/ImageProcessor.csproj | 1 + src/ImageProcessor/Imaging/Formats/FormatBase.cs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index c21b78194..274b3e76d 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -13,6 +13,7 @@ ..\ true Client + False true diff --git a/src/ImageProcessor/Imaging/Formats/FormatBase.cs b/src/ImageProcessor/Imaging/Formats/FormatBase.cs index ea00e82a2..189bad8c3 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatBase.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatBase.cs @@ -90,7 +90,11 @@ namespace ImageProcessor.Imaging.Formats /// public virtual Image Load(Stream stream) { +#if !__MonoCS__ return Image.FromStream(stream, true); +#else + return Image.FromStream(stream); +#endif } /// From 0fb451cb89c8fe7a63bb2e0391e5b861afbe321d Mon Sep 17 00:00:00 2001 From: James South Date: Sat, 5 Jul 2014 13:31:06 +0100 Subject: [PATCH 105/155] Adding updated tests and reducing image sizes. Former-commit-id: 03d98f7b9239cc7c688f6ec07f4b39375ce52d85 --- .../Extensions/DoubleExtensionsUnitTests.cs | 15 ++-- .../Extensions/IntegerExtensionsUnitTests.cs | 5 +- .../Extensions/StringExtensionsUnitTests.cs | 90 ++++++++++++------- .../Images/autorotate.jpg.REMOVED.git-id | 2 +- .../cmyk-profile-euroscale.jpg.REMOVED.git-id | 2 +- .../Images/cmyk.jpg.REMOVED.git-id | 2 +- .../color-vision-test.gif.REMOVED.git-id | 2 +- .../Images/exif-Tulips.jpg.REMOVED.git-id | 2 +- .../Images/exif-rocks.jpg.REMOVED.git-id | 2 +- .../format-Penguins-8bit.png.REMOVED.git-id | 2 +- .../Images/format-Penguins.bmp.REMOVED.git-id | 2 +- .../Images/format-Penguins.gif.REMOVED.git-id | 2 +- .../Images/format-Penguins.jpg.REMOVED.git-id | 2 +- .../Images/format-Penguins.png.REMOVED.git-id | 2 +- .../Images/format-animated.gif | 3 - .../Images/format-animated.gif.REMOVED.git-id | 1 + .../Images/hi-color.png | 4 +- .../Images/hi-contrast.jpg | 4 +- .../Images/hi-saturation.jpg | 4 +- .../profile-adobe-rgb.jpg.REMOVED.git-id | 2 +- .../Images/profile-srgb.jpg.REMOVED.git-id | 2 +- .../Images/size-Penguins-200.jpg | 4 +- .../Images/text-over-transparent.png | 4 +- .../Images/udendørs.jpg | 3 + .../Images/udendørs.jpg.REMOVED.git-id | 1 - src/ImageProcessor/ImageFactory.cs | 5 +- .../Imaging/Formats/GifEncoder.cs | 10 +-- .../Imaging/Formats/JpegFormat.cs | 2 +- src/ImageProcessorConsole/Program.cs | 19 ++-- .../images/output/120430.gif.REMOVED.git-id | 2 +- .../images/output/Tl4Yb.gif.REMOVED.git-id | 2 +- .../images/output/circle.png | 3 + .../images/output/nLpfllv.gif.REMOVED.git-id | 2 +- 33 files changed, 116 insertions(+), 93 deletions(-) delete mode 100644 src/ImageProcessor.UnitTests/Images/format-animated.gif create mode 100644 src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/udendørs.jpg delete mode 100644 src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id create mode 100644 src/ImageProcessorConsole/images/output/circle.png diff --git a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs index 108a9a246..cba1c07bc 100644 --- a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs @@ -8,9 +8,8 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.UnitTests +namespace ImageProcessor.UnitTests.Extensions { - using System; using System.Collections.Generic; using Common.Extensions; using NUnit.Framework; @@ -32,11 +31,13 @@ namespace ImageProcessor.UnitTests [TestFixtureSetUp] public void Init() { - this.doubleToByteTests = new Dictionary(); - this.doubleToByteTests.Add(-10, 0x0); - this.doubleToByteTests.Add(1.5, 0x1); - this.doubleToByteTests.Add(25.7, 0x19); - this.doubleToByteTests.Add(1289047, 0xFF); + this.doubleToByteTests = new Dictionary + { + { -10, 0x0 }, + { 1.5, 0x1 }, + { 25.7, 0x19 }, + { 1289047, 0xFF } + }; } /// diff --git a/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs index 1e85e633b..2adbe3b17 100644 --- a/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs @@ -8,9 +8,8 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.UnitTests +namespace ImageProcessor.UnitTests.Extensions { - using System; using Common.Extensions; using NUnit.Framework; @@ -31,7 +30,7 @@ namespace ImageProcessor.UnitTests [TestCase(3156, 0xFF)] public void ToByteTest(int input, byte expected) { - var result = input.ToByte(); + byte result = input.ToByte(); Assert.AreEqual(expected, result); } } diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs index 70f3e83db..c89c09dcd 100644 --- a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -8,11 +8,11 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.UnitTests +namespace ImageProcessor.UnitTests.Extensions { using System; using System.Collections.Generic; - using Common.Extensions; + using ImageProcessor.Common.Extensions; using NUnit.Framework; /// @@ -25,7 +25,7 @@ namespace ImageProcessor.UnitTests /// Tests the MD5 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "2e7f7a62eabf0993239ca17c78c464d9")] [TestCase("lorem ipsum dolor", "96ee002fee25e8b675a477c9750fa360")] @@ -33,8 +33,8 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "e15e31c3d8898c92ab172a4311be9e84")] public void TestToMd5Fingerprint(string input, string expected) { - var result = input.ToMD5Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToMD5Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } @@ -42,7 +42,7 @@ namespace ImageProcessor.UnitTests /// Tests the SHA-1 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "49883b34e5a0f48224dd6230f471e9dc1bdbeaf5")] [TestCase("lorem ipsum dolor", "75899ad8827a32493928903aecd6e931bf36f967")] @@ -50,8 +50,8 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "01b307acba4f54f55aafc33bb06bbbf6ca803e9a")] public void TestToSHA1Fingerprint(string input, string expected) { - var result = input.ToSHA1Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToSHA1Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } @@ -59,7 +59,7 @@ namespace ImageProcessor.UnitTests /// Tests the SHA-256 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "9dfe6f15d1ab73af898739394fd22fd72a03db01834582f24bb2e1c66c7aaeae")] [TestCase("lorem ipsum dolor", "ed03353266c993ea9afb9900a3ca688ddec1656941b1ca15ee1650a022616dfa")] @@ -67,8 +67,8 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646")] public void TestToSHA256Fingerprint(string input, string expected) { - var result = input.ToSHA256Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToSHA256Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } @@ -76,7 +76,7 @@ namespace ImageProcessor.UnitTests /// Tests the SHA-512 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "40aa1b203c9d8ee150b21c3c7cda8261492e5420c5f2b9f7380700e094c303b48e62f319c1da0e32eb40d113c5f1749cc61aeb499167890ab82f2cc9bb706971")] [TestCase("lorem ipsum dolor", "cd813e13d1d3919cdccc31c19d8f8b70bd25e9819f8770a011c8c7a6228536e6c9427b338cd732f2da3c0444dfebef838b745cdaf3fd5dcba8db24fc83a3f6ef")] @@ -84,49 +84,73 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "12b03226a6d8be9c6e8cd5e55dc6c7920caaa39df14aab92d5e3ea9340d1c8a4d3d0b8e4314f1f6ef131ba4bf1ceb9186ab87c801af0d5c95b1befb8cedae2b9")] public void TestToSHA512Fingerprint(string input, string expected) { - var result = input.ToSHA512Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToSHA512Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } /// - /// Tests the pasing to an integer array + /// Tests the passing to an integer array /// [Test] public void TestToIntegerArray() { - Dictionary data = new Dictionary(); - data.Add("123-456,78-90", new int[] { 123, 456, 78, 90 }); - data.Add("87390174,741897498,74816,748297,57355", new int[] { 87390174, 741897498, 74816, 748297, 57355 }); - data.Add("1-2-3", new int[] { 1, 2, 3 }); + Dictionary data = new Dictionary + { + { + "123-456,78-90", + new[] { 123, 456, 78, 90 } + }, + { + "87390174,741897498,74816,748297,57355", + new[] + { + 87390174, 741897498, 74816, + 748297, 57355 + } + }, + { "1-2-3", new[] { 1, 2, 3 } } + }; - foreach (var item in data) + foreach (KeyValuePair item in data) { - var result = item.Key.ToPositiveIntegerArray(); + int[] result = item.Key.ToPositiveIntegerArray(); Assert.AreEqual(item.Value, result); } } /// - /// Tests the pasing to an float array + /// Tests the passing to an float array /// [Test] public void TestToFloatArray() { - Dictionary data = new Dictionary(); - data.Add("12.3-4.56,78-9.0", new float[] { 12.3F, 4.56F, 78, 9 }); - data.Add("87390.174,7.41897498,748.16,748297,5.7355", new float[] { 87390.174F, 7.41897498F, 748.16F, 748297, 5.7355F }); - data.Add("1-2-3", new float[] { 1, 2, 3 }); + Dictionary data = new Dictionary + { + { + "12.3-4.56,78-9.0", + new[] { 12.3F, 4.56F, 78, 9 } + }, + { + "87390.174,7.41897498,748.16,748297,5.7355", + new[] + { + 87390.174F, 7.41897498F, + 748.16F, 748297, 5.7355F + } + }, + { "1-2-3", new float[] { 1, 2, 3 } } + }; - foreach (var item in data) + foreach (KeyValuePair item in data) { - var result = item.Key.ToPositiveFloatArray(); + float[] result = item.Key.ToPositiveFloatArray(); Assert.AreEqual(item.Value, result); } } /// - /// Tests if the value is a valid URI + /// Tests if the value is a valid URI path name. I.E the path part of a uri. /// /// The value to test /// Whether the value is correct @@ -139,10 +163,10 @@ namespace ImageProcessor.UnitTests [TestCase(".", true)] [TestCase("_", true)] [TestCase("~", true)] - [TestCase(":", true)] + [TestCase(":", false)] [TestCase("/", true)] [TestCase("?", true)] - [TestCase("#", true)] + [TestCase("#", false)] [TestCase("[", false)] [TestCase("]", false)] [TestCase("@", true)] @@ -159,9 +183,9 @@ namespace ImageProcessor.UnitTests [TestCase("=", true)] [TestCase("lorem ipsum", false)] [TestCase("é", false)] - public void TestIsValidUri(string input, bool expected) + public void TestIsValidUriPathName(string input, bool expected) { - var result = input.IsValidVirtualPathName(); + bool result = input.IsValidVirtualPathName(); Assert.AreEqual(expected, result); } } diff --git a/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id index 19785c8e5..1b5e335ff 100644 --- a/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id @@ -1 +1 @@ -85a8ae18f9955def2b42ba9240bce4de1bfe5781 \ No newline at end of file +75b37593bb2e505bf4fbe874eaf30debd6161c2e \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id index 7747bdaae..11eb19931 100644 --- a/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id @@ -1 +1 @@ -13492524f9d984c12adfe6183a4c1d92fb11ec4e \ No newline at end of file +d0a1a39a6729e826098ae5e987c22c34c989b7e3 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id index 30b05146b..9ba0b9f39 100644 --- a/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id @@ -1 +1 @@ -ed725726e4ac1ffeac821664af14865a66fa933f \ No newline at end of file +9160894da31fedebb1fcd64eb57ca173187c63a6 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id index 5c4f4195d..ed1d0b80b 100644 --- a/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id @@ -1 +1 @@ -35a926115b13b61dc37308f8d903b42d14f92924 \ No newline at end of file +b169fac4f1591e81e91c0bb6fed6dcf62a34c80e \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id index 84b9aff85..20704f4a9 100644 --- a/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id @@ -1 +1 @@ -54c51eb6a86f31a42433b8167470fb18dad32c7d \ No newline at end of file +9d7e7964a2285363171929315b15ec69f14831ef \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id index 41c6c25df..2e03e238f 100644 --- a/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id @@ -1 +1 @@ -33b6912af301bf216ee81d82b2c3ce6c49e03021 \ No newline at end of file +be31c9c0dea90586e2965208611fad024f6a5b08 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id index aa9a70e0f..c48cdc177 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id @@ -1 +1 @@ -c3d556d9d486b8b8b49cdbcc9c12a9d3a2db4c1f \ No newline at end of file +51ccec74a0351599de104f166b32d2860acaf089 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id index 74f69293c..9ba53bc67 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id @@ -1 +1 @@ -8150b46ab27c62ba51aaba551eef3f1a30f08de9 \ No newline at end of file +d7adbea2db4e3388541e31a229e5741677aaa7fd \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id index ce873d473..225d59af3 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id @@ -1 +1 @@ -6ad3b846d4697584ff601ac481b14a4d3bbb5736 \ No newline at end of file +b301e58d431a78d3f17be53be1cdc94c86286389 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id index ad4371113..06482dbd9 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id @@ -1 +1 @@ -030ab8a685bebb796c24cc710edd9e69859164f6 \ No newline at end of file +ee5a15e7f8fc2655d5c1fc736a05857ab3d885bd \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id index 78062a0e7..4ab6b372b 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id @@ -1 +1 @@ -a2c796fbb7de948230a22982ab74892891dd5198 \ No newline at end of file +b6434b5a35e989d4fa71ede1a8316fedeee7ae5f \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-animated.gif b/src/ImageProcessor.UnitTests/Images/format-animated.gif deleted file mode 100644 index ac36f6f25..000000000 --- a/src/ImageProcessor.UnitTests/Images/format-animated.gif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6212724b3e94908939823d0753b4307923b65d7a27f51823dd3ba7656543349c -size 22525 diff --git a/src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id new file mode 100644 index 000000000..ac3664d5f --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id @@ -0,0 +1 @@ +a41fb1117e1d730a4a488dcb67e0b867aa3c614e \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/hi-color.png b/src/ImageProcessor.UnitTests/Images/hi-color.png index a9de4cc09..cc8677aa8 100644 --- a/src/ImageProcessor.UnitTests/Images/hi-color.png +++ b/src/ImageProcessor.UnitTests/Images/hi-color.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:977cc9071257655c9923d267ea5bd417b69754367c2f1aa8765247b68e2bb878 -size 1539 +oid sha256:2f1263641d5e6ed29e96f211f4d78870496c29912245ac7d3c48716ee0ede313 +size 23922 diff --git a/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg b/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg index 98ac863a2..94581b505 100644 --- a/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg +++ b/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c0ce9e02f2a4663a0a0ed433d5594be87b3fa0387bc8335e80f84d59c34aa424 -size 51058 +oid sha256:1d6fb72b9710edcfba0f75dcd349712d5e940ec87650a08380f8180e6c9a62b2 +size 34996 diff --git a/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg b/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg index b56f9a83c..3405e88a5 100644 --- a/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg +++ b/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6b2012b2eda13a531645c287c254ae5de0e9070368cb4bc806f48314e0464ccd -size 33850 +oid sha256:fa947c3b5904e0138c359d7ccd81ad3209330880d412f1b09dfe32a355ee6d3b +size 51300 diff --git a/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id index 4ffbf7a8a..8064ffb21 100644 --- a/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id @@ -1 +1 @@ -e29f32091aa13a5b047ccd960f3dc6da9656c84b \ No newline at end of file +189f79f9b9604c5413aba928662d84edd426142d \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id index f409bc82b..101151778 100644 --- a/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id @@ -1 +1 @@ -ab9deaa737f9db9bf0f563e7843ba9b7981cec86 \ No newline at end of file +f731bdf700d2718f528317263264e5466374c5e5 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg b/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg index 07605996f..4520c9c95 100644 --- a/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg +++ b/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:672de68017f17260126901065f1c6ade2b2981d33dea0dea1606bf7cfb6fdcf3 -size 10119 +oid sha256:f0b24fb4937a0416bf62f7a743d2679c7eb2014bceb1a898826fb08e6231bad7 +size 37476 diff --git a/src/ImageProcessor.UnitTests/Images/text-over-transparent.png b/src/ImageProcessor.UnitTests/Images/text-over-transparent.png index 33d4962bc..1ae73c91f 100644 --- a/src/ImageProcessor.UnitTests/Images/text-over-transparent.png +++ b/src/ImageProcessor.UnitTests/Images/text-over-transparent.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2322d8dd81df86b8135d399743ea758ad26d6b2ccdcc704e2687ae72d0c187e7 -size 7317 +oid sha256:ba300af935752628b37a7f892369e7229f4f6ae701522cdedeefcf5c2b251afa +size 7680 diff --git a/src/ImageProcessor.UnitTests/Images/udendørs.jpg b/src/ImageProcessor.UnitTests/Images/udendørs.jpg new file mode 100644 index 000000000..84fb0cc3a --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/udendørs.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65434ff6c6d5f502308e627fcfbe1d26402b83fb5efba15749ffbb5e8795995e +size 55987 diff --git a/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id deleted file mode 100644 index 0db1445a2..000000000 --- a/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -4d040d9aa3519b3d2303419d1f03eebebf88e956 \ No newline at end of file diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index f2f573268..7e37983c3 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -158,9 +158,10 @@ namespace ImageProcessor this.CurrentImageFormat = format; // Always load the data. - foreach (PropertyItem propertyItem in this.Image.PropertyItems) + // TODO. Some custom data doesn't seem to get copied by default methods. + foreach (int id in this.Image.PropertyIdList) { - this.ExifPropertyItems[propertyItem.Id] = propertyItem; + this.ExifPropertyItems[id] = this.Image.GetPropertyItem(id); } this.ShouldProcess = true; diff --git a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs index 662ad314c..b7650d099 100644 --- a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs +++ b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs @@ -282,17 +282,17 @@ namespace ImageProcessor.Imaging.Formats { int count = this.repeatCount.GetValueOrDefault(0); - // File Header sinature and version. + // File Header signature and version. this.WriteString(FileType); this.WriteString(FileVersion); // Write the logical screen descriptor. this.WriteShort(this.width.GetValueOrDefault(w)); // Initial Logical Width this.WriteShort(this.height.GetValueOrDefault(h)); // Initial Logical Height - + // Read the global color table info. sourceGif.Position = SourceGlobalColorInfoPosition; - this.WriteByte(sourceGif.ReadByte()); + this.WriteByte(sourceGif.ReadByte()); this.WriteByte(0); // Background Color Index this.WriteByte(0); // Pixel aspect ratio @@ -301,7 +301,7 @@ namespace ImageProcessor.Imaging.Formats // The different browsers interpret the spec differently when adding a loop. // If the loop count is one IE and FF < 3 (incorrectly) loop an extra number of times. // Removing the Netscape header should fix this. - if (count != 1) + if (count > -1 && count != 1) { // Application Extension Header this.WriteShort(ApplicationExtensionBlockIdentifier); @@ -357,7 +357,7 @@ namespace ImageProcessor.Imaging.Formats this.WriteShort(GraphicControlExtensionBlockIdentifier); // Identifier this.WriteByte(GraphicControlExtensionBlockSize); // Block Size this.WriteByte(blockhead[3] & 0xf7 | 0x08); // Setting disposal flag - this.WriteShort(Convert.ToInt32(frameDelay / 10)); // Setting frame delay + this.WriteShort(Convert.ToInt32(frameDelay / 10.0f)); // Setting frame delay this.WriteByte(blockhead[6]); // Transparent color index this.WriteByte(0); // Terminator } diff --git a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs index ae5fd05c3..f7ff73c66 100644 --- a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs @@ -75,7 +75,7 @@ namespace ImageProcessor.Imaging.Formats { base.ApplyProcessor(processor, factory); - // Set the property item information from any Exif metadata. + // Set the property item information from any Exif metadata. // We do this here so that they can be changed between processor methods. if (factory.PreserveExifData) { diff --git a/src/ImageProcessorConsole/Program.cs b/src/ImageProcessorConsole/Program.cs index 248fe1d7f..5bacb50dd 100644 --- a/src/ImageProcessorConsole/Program.cs +++ b/src/ImageProcessorConsole/Program.cs @@ -15,9 +15,7 @@ namespace ImageProcessorConsole using System.Drawing; using System.IO; using System.Linq; - using ImageProcessor; - using ImageProcessor.Imaging.Formats; /// /// The program. @@ -33,6 +31,7 @@ namespace ImageProcessorConsole public static void Main(string[] args) { string path = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath; + // ReSharper disable once AssignNullToNotNullAttribute string resolvedPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\input")); DirectoryInfo di = new DirectoryInfo(resolvedPath); @@ -41,10 +40,8 @@ namespace ImageProcessorConsole di.Create(); } - //FileInfo[] files = di.GetFiles("*.jpg"); - //FileInfo[] files = di.GetFiles(); - IEnumerable files = GetFilesByExtensions(di, ".gif", ".webp"); - + IEnumerable files = GetFilesByExtensions(di, ".gif"); + //IEnumerable files = GetFilesByExtensions(di, ".gif", ".webp", ".bmp", ".jpg", ".png"); foreach (FileInfo fileInfo in files) { @@ -53,18 +50,13 @@ namespace ImageProcessorConsole // ImageProcessor using (MemoryStream inStream = new MemoryStream(photoBytes)) { - using (ImageFactory imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory(true)) { Size size = new Size(200, 200); // Load, resize, set the format and quality and save an image. imageFactory.Load(inStream) - //.AutoRotate() .Constrain(size) - //.Format(new WebPFormat()) - //.Quality(5) - // ReSharper disable once AssignNullToNotNullAttribute - // .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".webp"))); .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name))); } } @@ -74,7 +66,10 @@ namespace ImageProcessorConsole public static IEnumerable GetFilesByExtensions(DirectoryInfo dir, params string[] extensions) { if (extensions == null) + { throw new ArgumentNullException("extensions"); + } + IEnumerable files = dir.EnumerateFiles(); return files.Where(f => extensions.Contains(f.Extension, StringComparer.OrdinalIgnoreCase)); } diff --git a/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id index 71ce555c1..4767fd13d 100644 --- a/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id +++ b/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id @@ -1 +1 @@ -30ec5c05548fd350f9b7c699715848b9fbfb8ca9 \ No newline at end of file +6f3f997e323adb1fce142930d86338efacffc3fd \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id index 6515d65a0..f0f194a2b 100644 --- a/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id +++ b/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id @@ -1 +1 @@ -fdc62fc2d056ab885eb9e8fd12b9155ee86d7c43 \ No newline at end of file +3ab082661fc5d88f88643c47409e196d66e26d4b \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/circle.png b/src/ImageProcessorConsole/images/output/circle.png new file mode 100644 index 000000000..a96f1ecf3 --- /dev/null +++ b/src/ImageProcessorConsole/images/output/circle.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f31110b7933864eff3b149371c962174a8855a1c65f4fee7cb3bc63a79b71467 +size 2905 diff --git a/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id index c07be0b0f..b8684cd60 100644 --- a/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id +++ b/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id @@ -1 +1 @@ -77cce70db3722920d60f4b17a45a5e390a09838a \ No newline at end of file +e2c2fbac64987ad26e19f5d2721fcaa60fee843d \ No newline at end of file From 84a60954899482452f95caf352190970e9c88466 Mon Sep 17 00:00:00 2001 From: James South Date: Sat, 5 Jul 2014 14:49:35 +0100 Subject: [PATCH 106/155] Fixing unit test Former-commit-id: f13854941670288564cf8e80aceccb91e47a67bc --- .../Extensions/StringExtensionsUnitTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs index c89c09dcd..a3c5ea794 100644 --- a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -156,6 +156,7 @@ namespace ImageProcessor.UnitTests.Extensions /// Whether the value is correct /// /// The full RFC3986 does not seem to pass the test with the square brackets + /// ':' is failing for some reason in VS but not elsewhere. Could be a build issue. /// [Test] [TestCase("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", true)] @@ -163,7 +164,7 @@ namespace ImageProcessor.UnitTests.Extensions [TestCase(".", true)] [TestCase("_", true)] [TestCase("~", true)] - [TestCase(":", false)] + [TestCase(":", true)] [TestCase("/", true)] [TestCase("?", true)] [TestCase("#", false)] From 7cc6b6ffd978b2da1aa74398c14fe7ab1f180948 Mon Sep 17 00:00:00 2001 From: James South Date: Sun, 6 Jul 2014 12:11:52 +0100 Subject: [PATCH 107/155] Refactoring extensions Former-commit-id: 4987805685fb6ec8bad708809ddf0ae6f239f1d4 --- .../Extensions/StringExtensionsUnitTests.cs | 110 -------------- .../Extensions/StringExtensionsUnitTests.cs | 98 ++++++++++++ .../ImageProcessor.Web.UnitTests.csproj | 1 + .../NET45/Configuration/ImageCacheSection.cs | 5 +- .../NET45/Extensions/StringExtensions.cs | 143 ++++++++++++++++++ .../HttpModules/ImageProcessingModule.cs | 2 +- .../NET45/ImageProcessor.Web_NET45.csproj | 1 + .../Common/Extensions/AssemblyExtensions.cs | 13 +- .../Common/Extensions/StringExtensions.cs | 105 ------------- .../Imaging/Formats/GifEncoder.cs | 22 +-- .../Imaging/Formats/JpegFormat.cs | 2 +- .../Imaging/Formats/NativeMethods.cs | 6 + src/ImageProcessor/Settings.StyleCop | 1 + 13 files changed, 272 insertions(+), 237 deletions(-) create mode 100644 src/ImageProcessor.Web.UnitTests/Extensions/StringExtensionsUnitTests.cs create mode 100644 src/ImageProcessor.Web/NET45/Extensions/StringExtensions.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs index a3c5ea794..ab43bd92b 100644 --- a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -10,7 +10,6 @@ namespace ImageProcessor.UnitTests.Extensions { - using System; using System.Collections.Generic; using ImageProcessor.Common.Extensions; using NUnit.Framework; @@ -21,74 +20,6 @@ namespace ImageProcessor.UnitTests.Extensions [TestFixture] public class StringExtensionsUnitTests { - /// - /// Tests the MD5 fingerprint - /// - /// The input value - /// The expected output of the hash - [Test] - [TestCase("test input", "2e7f7a62eabf0993239ca17c78c464d9")] - [TestCase("lorem ipsum dolor", "96ee002fee25e8b675a477c9750fa360")] - [TestCase("LoReM IpSuM DoLoR", "41e201da794c7fbdb8ce5526a71c8c83")] - [TestCase("1234567890", "e15e31c3d8898c92ab172a4311be9e84")] - public void TestToMd5Fingerprint(string input, string expected) - { - string result = input.ToMD5Fingerprint(); - bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); - Assert.True(comparison); - } - - /// - /// Tests the SHA-1 fingerprint - /// - /// The input value - /// The expected output of the hash - [Test] - [TestCase("test input", "49883b34e5a0f48224dd6230f471e9dc1bdbeaf5")] - [TestCase("lorem ipsum dolor", "75899ad8827a32493928903aecd6e931bf36f967")] - [TestCase("LoReM IpSuM DoLoR", "2f44519afae72fc0837b72c6b53cb11338a1f916")] - [TestCase("1234567890", "01b307acba4f54f55aafc33bb06bbbf6ca803e9a")] - public void TestToSHA1Fingerprint(string input, string expected) - { - string result = input.ToSHA1Fingerprint(); - bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); - Assert.True(comparison); - } - - /// - /// Tests the SHA-256 fingerprint - /// - /// The input value - /// The expected output of the hash - [Test] - [TestCase("test input", "9dfe6f15d1ab73af898739394fd22fd72a03db01834582f24bb2e1c66c7aaeae")] - [TestCase("lorem ipsum dolor", "ed03353266c993ea9afb9900a3ca688ddec1656941b1ca15ee1650a022616dfa")] - [TestCase("LoReM IpSuM DoLoR", "55f6cb90ba5cd8eeb6f5f16f083ebcd48ea06c34cc5aed8e33246fc3153d3898")] - [TestCase("1234567890", "c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646")] - public void TestToSHA256Fingerprint(string input, string expected) - { - string result = input.ToSHA256Fingerprint(); - bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); - Assert.True(comparison); - } - - /// - /// Tests the SHA-512 fingerprint - /// - /// The input value - /// The expected output of the hash - [Test] - [TestCase("test input", "40aa1b203c9d8ee150b21c3c7cda8261492e5420c5f2b9f7380700e094c303b48e62f319c1da0e32eb40d113c5f1749cc61aeb499167890ab82f2cc9bb706971")] - [TestCase("lorem ipsum dolor", "cd813e13d1d3919cdccc31c19d8f8b70bd25e9819f8770a011c8c7a6228536e6c9427b338cd732f2da3c0444dfebef838b745cdaf3fd5dcba8db24fc83a3f6ef")] - [TestCase("LoReM IpSuM DoLoR", "3e4704d31f838456c0a5f0892afd392fbc79649a029d017b8104ebd00e2816d94ab4629f731765bf655088b130c51f6f47ca2f8b047749dbd992cf45e89ff431")] - [TestCase("1234567890", "12b03226a6d8be9c6e8cd5e55dc6c7920caaa39df14aab92d5e3ea9340d1c8a4d3d0b8e4314f1f6ef131ba4bf1ceb9186ab87c801af0d5c95b1befb8cedae2b9")] - public void TestToSHA512Fingerprint(string input, string expected) - { - string result = input.ToSHA512Fingerprint(); - bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); - Assert.True(comparison); - } - /// /// Tests the passing to an integer array /// @@ -148,46 +79,5 @@ namespace ImageProcessor.UnitTests.Extensions Assert.AreEqual(item.Value, result); } } - - /// - /// Tests if the value is a valid URI path name. I.E the path part of a uri. - /// - /// The value to test - /// Whether the value is correct - /// - /// The full RFC3986 does not seem to pass the test with the square brackets - /// ':' is failing for some reason in VS but not elsewhere. Could be a build issue. - /// - [Test] - [TestCase("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", true)] - [TestCase("-", true)] - [TestCase(".", true)] - [TestCase("_", true)] - [TestCase("~", true)] - [TestCase(":", true)] - [TestCase("/", true)] - [TestCase("?", true)] - [TestCase("#", false)] - [TestCase("[", false)] - [TestCase("]", false)] - [TestCase("@", true)] - [TestCase("!", true)] - [TestCase("$", true)] - [TestCase("&", true)] - [TestCase("'", true)] - [TestCase("(", true)] - [TestCase(")", true)] - [TestCase("*", true)] - [TestCase("+", true)] - [TestCase(",", true)] - [TestCase(";", true)] - [TestCase("=", true)] - [TestCase("lorem ipsum", false)] - [TestCase("é", false)] - public void TestIsValidUriPathName(string input, bool expected) - { - bool result = input.IsValidVirtualPathName(); - Assert.AreEqual(expected, result); - } } } \ No newline at end of file diff --git a/src/ImageProcessor.Web.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.Web.UnitTests/Extensions/StringExtensionsUnitTests.cs new file mode 100644 index 000000000..57c261c7b --- /dev/null +++ b/src/ImageProcessor.Web.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -0,0 +1,98 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Test harness for the string extensions +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.UnitTests.Extensions +{ + using System; + using ImageProcessor.Web.Extensions; + using NUnit.Framework; + + /// + /// Test harness for the string extensions + /// + [TestFixture] + public class StringExtensionsUnitTests + { + /// + /// Tests the MD5 fingerprint + /// + /// The input value + /// The expected output of the hash + [Test] + [TestCase("test input", "2e7f7a62eabf0993239ca17c78c464d9")] + [TestCase("lorem ipsum dolor", "96ee002fee25e8b675a477c9750fa360")] + [TestCase("LoReM IpSuM DoLoR", "41e201da794c7fbdb8ce5526a71c8c83")] + [TestCase("1234567890", "e15e31c3d8898c92ab172a4311be9e84")] + public void TestToMd5Fingerprint(string input, string expected) + { + string result = input.ToMD5Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + Assert.True(comparison); + } + + /// + /// Tests the SHA-1 fingerprint + /// + /// The input value + /// The expected output of the hash + [Test] + [TestCase("test input", "49883b34e5a0f48224dd6230f471e9dc1bdbeaf5")] + [TestCase("lorem ipsum dolor", "75899ad8827a32493928903aecd6e931bf36f967")] + [TestCase("LoReM IpSuM DoLoR", "2f44519afae72fc0837b72c6b53cb11338a1f916")] + [TestCase("1234567890", "01b307acba4f54f55aafc33bb06bbbf6ca803e9a")] + public void TestToSHA1Fingerprint(string input, string expected) + { + string result = input.ToSHA1Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + Assert.True(comparison); + } + + /// + /// Tests if the value is a valid URI path name. I.E the path part of a uri. + /// + /// The value to test + /// Whether the value is correct + /// + /// The full RFC3986 does not seem to pass the test with the square brackets + /// ':' is failing for some reason in VS but not elsewhere. Could be a build issue. + /// + [Test] + [TestCase("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", true)] + [TestCase("-", true)] + [TestCase(".", true)] + [TestCase("_", true)] + [TestCase("~", true)] + [TestCase(":", true)] + [TestCase("/", true)] + [TestCase("?", true)] + [TestCase("#", false)] + [TestCase("[", false)] + [TestCase("]", false)] + [TestCase("@", true)] + [TestCase("!", true)] + [TestCase("$", true)] + [TestCase("&", true)] + [TestCase("'", true)] + [TestCase("(", true)] + [TestCase(")", true)] + [TestCase("*", true)] + [TestCase("+", true)] + [TestCase(",", true)] + [TestCase(";", true)] + [TestCase("=", true)] + [TestCase("lorem ipsum", false)] + [TestCase("é", false)] + public void TestIsValidUriPathName(string input, bool expected) + { + bool result = input.IsValidVirtualPathName(); + Assert.AreEqual(expected, result); + } + } +} diff --git a/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj b/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj index 17c54d202..460e329b9 100644 --- a/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj +++ b/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj @@ -53,6 +53,7 @@ + diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs index 8e5abad95..1f868fc04 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs @@ -10,16 +10,13 @@ namespace ImageProcessor.Web.Configuration { - #region Using using System.Configuration; using System.IO; using System.Xml; - using ImageProcessor.Common.Extensions; + using ImageProcessor.Web.Extensions; using ImageProcessor.Web.Helpers; - #endregion - /// /// Represents an image cache section within a configuration file. /// diff --git a/src/ImageProcessor.Web/NET45/Extensions/StringExtensions.cs b/src/ImageProcessor.Web/NET45/Extensions/StringExtensions.cs new file mode 100644 index 000000000..5ec1fdf4b --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Extensions/StringExtensions.cs @@ -0,0 +1,143 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Encapsulates a series of time saving extension methods to the class. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.Extensions +{ + using System; + using System.Globalization; + using System.Linq; + using System.Security.Cryptography; + using System.Text; + using System.Text.RegularExpressions; + + /// + /// Encapsulates a series of time saving extension methods to the class. + /// + public static class StringExtensions + { + #region Cryptography + /// + /// Creates an MD5 fingerprint of the String. + /// + /// The String instance that this method extends. + /// An MD5 fingerprint of the String. + public static string ToMD5Fingerprint(this string expression) + { + byte[] bytes = Encoding.Unicode.GetBytes(expression.ToCharArray()); + + using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider()) + { + byte[] hash = md5.ComputeHash(bytes); + + // Concatenate the hash bytes into one long String. + return hash.Aggregate( + new StringBuilder(32), + (sb, b) => sb.Append(b.ToString("X2", CultureInfo.InvariantCulture))) + .ToString().ToLowerInvariant(); + } + } + + /// + /// Creates an SHA1 fingerprint of the String. + /// + /// The String instance that this method extends. + /// An SHA1 fingerprint of the String. + public static string ToSHA1Fingerprint(this string expression) + { + byte[] bytes = Encoding.ASCII.GetBytes(expression.ToCharArray()); + + using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider()) + { + byte[] hash = sha1.ComputeHash(bytes); + + // Concatenate the hash bytes into one long String. + return hash.Aggregate( + new StringBuilder(40), + (sb, b) => sb.Append(b.ToString("X2", CultureInfo.InvariantCulture))) + .ToString().ToLowerInvariant(); + } + } + #endregion + + #region Numbers + /// + /// Creates an array of integers scraped from the String. + /// + /// The String instance that this method extends. + /// An array of integers scraped from the String. + public static int[] ToPositiveIntegerArray(this string expression) + { + if (string.IsNullOrWhiteSpace(expression)) + { + throw new ArgumentNullException("expression"); + } + + Regex regex = new Regex(@"[\d+]+(?=[,-])|[\d+]+(?![,-])", RegexOptions.Compiled); + + MatchCollection matchCollection = regex.Matches(expression); + + // Get the collections. + int count = matchCollection.Count; + int[] matches = new int[count]; + + // Loop and parse the int values. + for (int i = 0; i < count; i++) + { + matches[i] = int.Parse(matchCollection[i].Value, CultureInfo.InvariantCulture); + } + + return matches; + } + + /// + /// Creates an array of floats scraped from the String. + /// + /// The String instance that this method extends. + /// An array of floats scraped from the String. + public static float[] ToPositiveFloatArray(this string expression) + { + if (string.IsNullOrWhiteSpace(expression)) + { + throw new ArgumentNullException("expression"); + } + + Regex regex = new Regex(@"[\d+\.]+(?=[,-])|[\d+\.]+(?![,-])", RegexOptions.Compiled); + + MatchCollection matchCollection = regex.Matches(expression); + + // Get the collections. + int count = matchCollection.Count; + float[] matches = new float[count]; + + // Loop and parse the int values. + for (int i = 0; i < count; i++) + { + matches[i] = float.Parse(matchCollection[i].Value, CultureInfo.InvariantCulture); + } + + return matches; + } + #endregion + + #region Files and Paths + /// + /// Checks the string to see whether the value is a valid virtual path name. + /// + /// The String instance that this method extends. + /// True if the given string is a valid virtual path name + public static bool IsValidVirtualPathName(this string expression) + { + Uri uri; + + return Uri.TryCreate(expression, UriKind.Relative, out uri) && uri.IsWellFormedOriginalString(); + } + #endregion + } +} diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index d70e71867..db378fae4 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -29,9 +29,9 @@ namespace ImageProcessor.Web.HttpModules using System.Web.Hosting; using System.Web.Security; - using ImageProcessor.Common.Extensions; using ImageProcessor.Web.Caching; using ImageProcessor.Web.Configuration; + using ImageProcessor.Web.Extensions; using ImageProcessor.Web.Helpers; #endregion diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj index 2f5e77f23..40bd16bc7 100644 --- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj +++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj @@ -54,6 +54,7 @@ + diff --git a/src/ImageProcessor/Common/Extensions/AssemblyExtensions.cs b/src/ImageProcessor/Common/Extensions/AssemblyExtensions.cs index 763697ef0..e37480ff0 100644 --- a/src/ImageProcessor/Common/Extensions/AssemblyExtensions.cs +++ b/src/ImageProcessor/Common/Extensions/AssemblyExtensions.cs @@ -1,4 +1,13 @@ - +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Encapsulates a series of time saving extension methods to the class. +// +// -------------------------------------------------------------------------------------------------------------------- + namespace ImageProcessor.Common.Extensions { using System; @@ -38,4 +47,4 @@ namespace ImageProcessor.Common.Extensions } } } -} +} \ No newline at end of file diff --git a/src/ImageProcessor/Common/Extensions/StringExtensions.cs b/src/ImageProcessor/Common/Extensions/StringExtensions.cs index fd7d54139..f315df797 100644 --- a/src/ImageProcessor/Common/Extensions/StringExtensions.cs +++ b/src/ImageProcessor/Common/Extensions/StringExtensions.cs @@ -12,9 +12,6 @@ namespace ImageProcessor.Common.Extensions { using System; using System.Globalization; - using System.Linq; - using System.Security.Cryptography; - using System.Text; using System.Text.RegularExpressions; /// @@ -22,93 +19,6 @@ namespace ImageProcessor.Common.Extensions /// public static class StringExtensions { - #region Cryptography - /// - /// Creates an MD5 fingerprint of the String. - /// - /// The String instance that this method extends. - /// An MD5 fingerprint of the String. - public static string ToMD5Fingerprint(this string expression) - { - byte[] bytes = Encoding.Unicode.GetBytes(expression.ToCharArray()); - - using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider()) - { - byte[] hash = md5.ComputeHash(bytes); - - // Concatenate the hash bytes into one long String. - return hash.Aggregate( - new StringBuilder(32), - (sb, b) => sb.Append(b.ToString("X2", CultureInfo.InvariantCulture))) - .ToString().ToLowerInvariant(); - } - } - - /// - /// Creates an SHA1 fingerprint of the String. - /// - /// The String instance that this method extends. - /// An SHA1 fingerprint of the String. - public static string ToSHA1Fingerprint(this string expression) - { - byte[] bytes = Encoding.ASCII.GetBytes(expression.ToCharArray()); - - using (SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider()) - { - byte[] hash = sha1.ComputeHash(bytes); - - // Concatenate the hash bytes into one long String. - return hash.Aggregate( - new StringBuilder(40), - (sb, b) => sb.Append(b.ToString("X2", CultureInfo.InvariantCulture))) - .ToString().ToLowerInvariant(); - } - } - - /// - /// Creates an SHA256 fingerprint of the String. - /// - /// The String instance that this method extends. - /// An SHA256 fingerprint of the String. - public static string ToSHA256Fingerprint(this string expression) - { - byte[] bytes = Encoding.ASCII.GetBytes(expression.ToCharArray()); - - using (SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider()) - { - byte[] hash = sha256.ComputeHash(bytes); - - // Concatenate the hash bytes into one long String. - return hash.Aggregate( - new StringBuilder(64), - (sb, b) => sb.Append(b.ToString("X2", CultureInfo.InvariantCulture))) - .ToString().ToLowerInvariant(); - } - } - - /// - /// Creates an SHA512 fingerprint of the String. - /// - /// The String instance that this method extends. - /// An SHA256 fingerprint of the String. - public static string ToSHA512Fingerprint(this string expression) - { - byte[] bytes = Encoding.ASCII.GetBytes(expression.ToCharArray()); - - using (SHA512CryptoServiceProvider sha512 = new SHA512CryptoServiceProvider()) - { - byte[] hash = sha512.ComputeHash(bytes); - - // Concatenate the hash bytes into one long String. - return hash.Aggregate( - new StringBuilder(70), - (sb, b) => sb.Append(b.ToString("X2", CultureInfo.InvariantCulture))) - .ToString().ToLowerInvariant(); - } - } - #endregion - - #region Numbers /// /// Creates an array of integers scraped from the String. /// @@ -166,20 +76,5 @@ namespace ImageProcessor.Common.Extensions return matches; } - #endregion - - #region Files and Paths - /// - /// Checks the string to see whether the value is a valid virtual path name. - /// - /// The String instance that this method extends. - /// True if the given string is a valid virtual path name - public static bool IsValidVirtualPathName(this string expression) - { - Uri uri; - - return Uri.TryCreate(expression, UriKind.Relative, out uri) && uri.IsWellFormedOriginalString(); - } - #endregion } } diff --git a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs index b7650d099..826ddf42f 100644 --- a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs +++ b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs @@ -298,20 +298,14 @@ namespace ImageProcessor.Imaging.Formats this.WriteByte(0); // Pixel aspect ratio this.WriteColorTable(sourceGif); - // The different browsers interpret the spec differently when adding a loop. - // If the loop count is one IE and FF < 3 (incorrectly) loop an extra number of times. - // Removing the Netscape header should fix this. - if (count > -1 && count != 1) - { - // Application Extension Header - this.WriteShort(ApplicationExtensionBlockIdentifier); - this.WriteByte(ApplicationBlockSize); - this.WriteString(ApplicationIdentification); - this.WriteByte(3); // Application block length - this.WriteByte(1); - this.WriteShort(count); // Repeat count for images. - this.WriteByte(0); // Terminator - } + // Application Extension Header + this.WriteShort(ApplicationExtensionBlockIdentifier); + this.WriteByte(ApplicationBlockSize); + this.WriteString(ApplicationIdentification); + this.WriteByte(3); // Application block length + this.WriteByte(1); + this.WriteShort(count); // Repeat count for images. + this.WriteByte(0); // Terminator } /// diff --git a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs index f7ff73c66..ae5fd05c3 100644 --- a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs @@ -75,7 +75,7 @@ namespace ImageProcessor.Imaging.Formats { base.ApplyProcessor(processor, factory); - // Set the property item information from any Exif metadata. + // Set the property item information from any Exif metadata. // We do this here so that they can be changed between processor methods. if (factory.PreserveExifData) { diff --git a/src/ImageProcessor/Imaging/Formats/NativeMethods.cs b/src/ImageProcessor/Imaging/Formats/NativeMethods.cs index 8aaff3432..574bd1e8f 100644 --- a/src/ImageProcessor/Imaging/Formats/NativeMethods.cs +++ b/src/ImageProcessor/Imaging/Formats/NativeMethods.cs @@ -18,6 +18,12 @@ namespace ImageProcessor.Imaging.Formats /// internal static class NativeMethods { + /// + /// Whether the process is running in 64bit mode. Used for calling the correct dllimport method. + /// Clunky I know but I couldn't get dynamic methods to work. + /// + private static readonly bool Is64Bit = Environment.Is64BitProcess; + #region WebP /// /// Validate the WebP image header and retrieve the image height and width. Pointers *width and *height can be passed NULL if deemed irrelevant diff --git a/src/ImageProcessor/Settings.StyleCop b/src/ImageProcessor/Settings.StyleCop index 29b381707..085067600 100644 --- a/src/ImageProcessor/Settings.StyleCop +++ b/src/ImageProcessor/Settings.StyleCop @@ -4,6 +4,7 @@ bitstream dd ddd + dllimport gps mmmm orig From c53976a85f287492bca85f51409b6bfcfebcabe9 Mon Sep 17 00:00:00 2001 From: James South Date: Sun, 6 Jul 2014 18:58:51 +0100 Subject: [PATCH 108/155] Fixing references. Former-commit-id: cd32f8c955b3fd8ca70862231135ee52a4b97e3a --- .../Extensions/StringExtensionsUnitTests.cs | 83 ------------------- .../ImageProcessor.UnitTests.csproj | 5 +- .../Extensions/StringExtensionsUnitTests.cs | 62 ++++++++++++++ .../NET4/ImageProcessor.Web_NET4.csproj | 3 + .../NET45/Caching/DiskCache.cs | 3 +- .../Helpers/CommonParameterParserUtility.cs | 1 + .../NET45/Processors/Crop.cs | 2 +- .../NET45/Processors/Resize.cs | 2 +- .../NET45/Processors/Watermark.cs | 2 +- .../Common/Extensions/StringExtensions.cs | 80 ------------------ src/ImageProcessor/ImageProcessor.csproj | 1 - 11 files changed, 71 insertions(+), 173 deletions(-) delete mode 100644 src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs delete mode 100644 src/ImageProcessor/Common/Extensions/StringExtensions.cs diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs deleted file mode 100644 index ab43bd92b..000000000 --- a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. -// -// -// Provides a test harness for the string extensions -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace ImageProcessor.UnitTests.Extensions -{ - using System.Collections.Generic; - using ImageProcessor.Common.Extensions; - using NUnit.Framework; - - /// - /// Test harness for the string extensions - /// - [TestFixture] - public class StringExtensionsUnitTests - { - /// - /// Tests the passing to an integer array - /// - [Test] - public void TestToIntegerArray() - { - Dictionary data = new Dictionary - { - { - "123-456,78-90", - new[] { 123, 456, 78, 90 } - }, - { - "87390174,741897498,74816,748297,57355", - new[] - { - 87390174, 741897498, 74816, - 748297, 57355 - } - }, - { "1-2-3", new[] { 1, 2, 3 } } - }; - - foreach (KeyValuePair item in data) - { - int[] result = item.Key.ToPositiveIntegerArray(); - Assert.AreEqual(item.Value, result); - } - } - - /// - /// Tests the passing to an float array - /// - [Test] - public void TestToFloatArray() - { - Dictionary data = new Dictionary - { - { - "12.3-4.56,78-9.0", - new[] { 12.3F, 4.56F, 78, 9 } - }, - { - "87390.174,7.41897498,748.16,748297,5.7355", - new[] - { - 87390.174F, 7.41897498F, - 748.16F, 748297, 5.7355F - } - }, - { "1-2-3", new float[] { 1, 2, 3 } } - }; - - foreach (KeyValuePair item in data) - { - float[] result = item.Key.ToPositiveFloatArray(); - Assert.AreEqual(item.Value, result); - } - } - } -} \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj index 5b6bc12d1..930267a63 100644 --- a/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj +++ b/src/ImageProcessor.UnitTests/ImageProcessor.UnitTests.csproj @@ -48,7 +48,6 @@ - @@ -130,7 +129,5 @@ - - - + \ No newline at end of file diff --git a/src/ImageProcessor.Web.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.Web.UnitTests/Extensions/StringExtensionsUnitTests.cs index 57c261c7b..3e9053aed 100644 --- a/src/ImageProcessor.Web.UnitTests/Extensions/StringExtensionsUnitTests.cs +++ b/src/ImageProcessor.Web.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -11,6 +11,8 @@ namespace ImageProcessor.Web.UnitTests.Extensions { using System; + using System.Collections.Generic; + using ImageProcessor.Web.Extensions; using NUnit.Framework; @@ -20,6 +22,66 @@ namespace ImageProcessor.Web.UnitTests.Extensions [TestFixture] public class StringExtensionsUnitTests { + /// + /// Tests the passing to an integer array + /// + [Test] + public void TestToIntegerArray() + { + Dictionary data = new Dictionary + { + { + "123-456,78-90", + new[] { 123, 456, 78, 90 } + }, + { + "87390174,741897498,74816,748297,57355", + new[] + { + 87390174, 741897498, 74816, + 748297, 57355 + } + }, + { "1-2-3", new[] { 1, 2, 3 } } + }; + + foreach (KeyValuePair item in data) + { + int[] result = item.Key.ToPositiveIntegerArray(); + Assert.AreEqual(item.Value, result); + } + } + + /// + /// Tests the passing to an float array + /// + [Test] + public void TestToFloatArray() + { + Dictionary data = new Dictionary + { + { + "12.3-4.56,78-9.0", + new[] { 12.3F, 4.56F, 78, 9 } + }, + { + "87390.174,7.41897498,748.16,748297,5.7355", + new[] + { + 87390.174F, 7.41897498F, + 748.16F, 748297, 5.7355F + } + }, + { "1-2-3", new float[] { 1, 2, 3 } } + }; + + foreach (KeyValuePair item in data) + { + float[] result = item.Key.ToPositiveFloatArray(); + Assert.AreEqual(item.Value, result); + } + } + /// /// Tests the MD5 fingerprint /// diff --git a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj index d830257ae..82d3986a7 100644 --- a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj +++ b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj @@ -98,6 +98,9 @@ DirectoryInfoExtensions.cs + + StringExtensions.cs + CommonParameterParserUtility.cs diff --git a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs index 6a23d48ad..be6b88744 100644 --- a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs +++ b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs @@ -20,7 +20,6 @@ namespace ImageProcessor.Web.Caching using System.Web; using System.Web.Hosting; - using ImageProcessor.Common.Extensions; using ImageProcessor.Web.Configuration; using ImageProcessor.Web.Extensions; using ImageProcessor.Web.Helpers; @@ -245,7 +244,7 @@ namespace ImageProcessor.Web.Caching fileInfo.Delete(); count -= 1; } - // ReSharper disable once EmptyGeneralCatchClause + // ReSharper disable once EmptyGeneralCatchClause catch { // Do nothing; skip to the next file. diff --git a/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs index ae71ca7ef..505d80d99 100644 --- a/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs +++ b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs @@ -17,6 +17,7 @@ namespace ImageProcessor.Web.Helpers using ImageProcessor.Common.Extensions; using ImageProcessor.Imaging; + using ImageProcessor.Web.Extensions; /// /// Encapsulates methods to correctly parse querystring parameters. diff --git a/src/ImageProcessor.Web/NET45/Processors/Crop.cs b/src/ImageProcessor.Web/NET45/Processors/Crop.cs index c621ebd1a..c669c8e1b 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Crop.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Crop.cs @@ -13,9 +13,9 @@ namespace ImageProcessor.Web.Processors using System.Text; using System.Text.RegularExpressions; - using ImageProcessor.Common.Extensions; using ImageProcessor.Imaging; using ImageProcessor.Processors; + using ImageProcessor.Web.Extensions; /// /// Crops an image to the given directions. diff --git a/src/ImageProcessor.Web/NET45/Processors/Resize.cs b/src/ImageProcessor.Web/NET45/Processors/Resize.cs index 95d962958..09ce9bc3c 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Resize.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Resize.cs @@ -17,9 +17,9 @@ namespace ImageProcessor.Web.Processors using System.Text; using System.Text.RegularExpressions; - using ImageProcessor.Common.Extensions; using ImageProcessor.Imaging; using ImageProcessor.Processors; + using ImageProcessor.Web.Extensions; /// /// Resizes an image to the given dimensions. diff --git a/src/ImageProcessor.Web/NET45/Processors/Watermark.cs b/src/ImageProcessor.Web/NET45/Processors/Watermark.cs index 27e83e288..d87f09388 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Watermark.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Watermark.cs @@ -15,9 +15,9 @@ namespace ImageProcessor.Web.Processors using System.Linq; using System.Text.RegularExpressions; - using ImageProcessor.Common.Extensions; using ImageProcessor.Imaging; using ImageProcessor.Processors; + using ImageProcessor.Web.Extensions; using ImageProcessor.Web.Helpers; /// diff --git a/src/ImageProcessor/Common/Extensions/StringExtensions.cs b/src/ImageProcessor/Common/Extensions/StringExtensions.cs deleted file mode 100644 index f315df797..000000000 --- a/src/ImageProcessor/Common/Extensions/StringExtensions.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. -// -// -// Encapsulates a series of time saving extension methods to the class. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace ImageProcessor.Common.Extensions -{ - using System; - using System.Globalization; - using System.Text.RegularExpressions; - - /// - /// Encapsulates a series of time saving extension methods to the class. - /// - public static class StringExtensions - { - /// - /// Creates an array of integers scraped from the String. - /// - /// The String instance that this method extends. - /// An array of integers scraped from the String. - public static int[] ToPositiveIntegerArray(this string expression) - { - if (string.IsNullOrWhiteSpace(expression)) - { - throw new ArgumentNullException("expression"); - } - - Regex regex = new Regex(@"[\d+]+(?=[,-])|[\d+]+(?![,-])", RegexOptions.Compiled); - - MatchCollection matchCollection = regex.Matches(expression); - - // Get the collections. - int count = matchCollection.Count; - int[] matches = new int[count]; - - // Loop and parse the int values. - for (int i = 0; i < count; i++) - { - matches[i] = int.Parse(matchCollection[i].Value, CultureInfo.InvariantCulture); - } - - return matches; - } - - /// - /// Creates an array of floats scraped from the String. - /// - /// The String instance that this method extends. - /// An array of floats scraped from the String. - public static float[] ToPositiveFloatArray(this string expression) - { - if (string.IsNullOrWhiteSpace(expression)) - { - throw new ArgumentNullException("expression"); - } - - Regex regex = new Regex(@"[\d+\.]+(?=[,-])|[\d+\.]+(?![,-])", RegexOptions.Compiled); - - MatchCollection matchCollection = regex.Matches(expression); - - // Get the collections. - int count = matchCollection.Count; - float[] matches = new float[count]; - - // Loop and parse the int values. - for (int i = 0; i < count; i++) - { - matches[i] = float.Parse(matchCollection[i].Value, CultureInfo.InvariantCulture); - } - - return matches; - } - } -} diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 274b3e76d..0e0d276bb 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -66,7 +66,6 @@ - From 001d8e6d245d3855d56659a734e79e6eba0001e4 Mon Sep 17 00:00:00 2001 From: James South Date: Mon, 7 Jul 2014 08:21:28 +0100 Subject: [PATCH 109/155] Reorganizing native binaries Former-commit-id: 1cf486d20dbf4b385d58002a39328d25bc0138ac --- build/NuSpecs/ImageProcessor.nuspec | 4 +- .../ImageProcessor.Web/web.config.transform | 2 + .../NET4/ImageProcessor.Web_NET4.csproj | 3 + .../ImageProcessorConfiguration.cs | 29 +--- .../ImageProcessorNativeBinaryModule.cs | 159 ++++++++++++++++++ .../NET45/ImageProcessor.Web_NET45.csproj | 1 + src/ImageProcessor.sln.DotSettings | 1 + src/ImageProcessor/ImageProcessor.csproj | 5 +- .../Imaging/Formats/NativeMethods.cs | 127 ++++++++++++-- .../Imaging/Formats/WebPFormat.cs | 60 +------ ...imageprocessor.libwebp.dll.REMOVED.git-id} | 0 ...imageprocessor.libwebp.dll.REMOVED.git-id} | 0 src/ImageProcessorConsole/Program.cs | 4 +- .../images/output/120430.gif.REMOVED.git-id | 2 +- .../images/output/Tl4Yb.gif.REMOVED.git-id | 2 +- .../images/output/nLpfllv.gif.REMOVED.git-id | 2 +- .../images/output/rotate.jpg | 3 + .../NET45/Test_Website_NET45/Web.config | 4 +- 18 files changed, 308 insertions(+), 100 deletions(-) create mode 100644 src/ImageProcessor.Web/NET45/HttpModules/ImageProcessorNativeBinaryModule.cs rename src/ImageProcessor/{libwebp64.dll.REMOVED.git-id => x64/imageprocessor.libwebp.dll.REMOVED.git-id} (100%) rename src/ImageProcessor/{libwebp32.dll.REMOVED.git-id => x86/imageprocessor.libwebp.dll.REMOVED.git-id} (100%) create mode 100644 src/ImageProcessorConsole/images/output/rotate.jpg diff --git a/build/NuSpecs/ImageProcessor.nuspec b/build/NuSpecs/ImageProcessor.nuspec index 557d85150..f12daba8f 100644 --- a/build/NuSpecs/ImageProcessor.nuspec +++ b/build/NuSpecs/ImageProcessor.nuspec @@ -25,8 +25,8 @@ Feedback is always welcome. - - + + \ No newline at end of file diff --git a/build/content/ImageProcessor.Web/web.config.transform b/build/content/ImageProcessor.Web/web.config.transform index 7d02ee462..5c3edb967 100644 --- a/build/content/ImageProcessor.Web/web.config.transform +++ b/build/content/ImageProcessor.Web/web.config.transform @@ -3,6 +3,7 @@ + @@ -13,6 +14,7 @@ + \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj index 82d3986a7..12c43700b 100644 --- a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj +++ b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj @@ -116,6 +116,9 @@ + + ImageProcessorNativeBinaryModule.cs + Alpha.cs diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs index 9d3ea6be9..95c3123e2 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs +++ b/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs @@ -23,6 +23,7 @@ namespace ImageProcessor.Web.Configuration using ImageProcessor.Common.Extensions; using ImageProcessor.Processors; using ImageProcessor.Web.Helpers; + using ImageProcessor.Web.HttpModules; using ImageProcessor.Web.Processors; /// @@ -370,30 +371,14 @@ namespace ImageProcessor.Web.Configuration /// private void EnsureNativeBinariesLoaded() { - string binary = Is64Bit ? "libwebp64.dll" : "libwebp32.dll"; - string sourcePath = HttpContext.Current.Server.MapPath("~/bin"); - string targetPath = new Uri(Assembly.GetExecutingAssembly().Location).LocalPath; - IntPtr pointer = IntPtr.Zero; + // Load the correct method from the native binary module. + // We do it here as on init will cause an UnauthorizedAccessException. + HttpModuleCollection modules = HttpContext.Current.ApplicationInstance.Modules; + ImageProcessorNativeBinaryModule nativeBinaryModule = modules.Get("ImageProcessorNativeBinaryModule") as ImageProcessorNativeBinaryModule; - // Shadow copy the native binaries. - sourcePath = Path.Combine(sourcePath, binary); - targetPath = Path.GetFullPath(Path.Combine(targetPath, "..\\" + binary)); - - File.Copy(sourcePath, targetPath, true); - - try - { - // Load the binary into memory. - pointer = NativeMethods.LoadLibrary(targetPath); - } - catch (Exception ex) - { - Debug.WriteLine(ex.Message); - } - - if (pointer == IntPtr.Zero) + if (nativeBinaryModule != null) { - throw new ApplicationException("Cannot open " + binary); + nativeBinaryModule.LoadNativeBinaries(); } } #endregion diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessorNativeBinaryModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessorNativeBinaryModule.cs new file mode 100644 index 000000000..87120a77b --- /dev/null +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessorNativeBinaryModule.cs @@ -0,0 +1,159 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// The image processing native binary module. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Web.HttpModules +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Reflection; + using System.Web; + + using ImageProcessor.Web.Helpers; + + /// + /// Controls the loading and unloading of any native binaries required by ImageProcessor.Web. + /// + public sealed class ImageProcessorNativeBinaryModule : IHttpModule + { + /// + /// Whether the process is running in 64bit mode. Used for calling the correct dllimport method. + /// + private static readonly bool Is64Bit = Environment.Is64BitProcess; + + /// + /// The object to lock against. + /// + private static readonly object SyncRoot = new object(); + + /// + /// The native binaries. + /// + private static readonly List NativeBinaries = new List(); + + /// + /// A value indicating whether this instance of the given entity has been disposed. + /// + /// if this instance has been disposed; otherwise, . + /// + /// If the entity is disposed, it must not be disposed a second + /// time. The isDisposed field is set the first time the entity + /// is disposed. If the isDisposed field is true, then the Dispose() + /// method will not dispose again. This help not to prolong the entity's + /// life in the Garbage Collector. + /// + private bool isDisposed; + + /// + /// Disposes of the resources (other than memory) used by the module that implements + /// . + /// + public void Dispose() + { + if (this.isDisposed) + { + return; + } + + // Call the appropriate methods to clean up + // unmanaged resources here. + lock (SyncRoot) + { + this.FreeNativeBinaries(); + } + + // Note disposing is done. + this.isDisposed = true; + } + + /// + /// Initializes a module and prepares it to handle requests. + /// + /// An that provides access to + /// the methods, properties, and events common to all application objects within an ASP.NET application + public void Init(HttpApplication context) + { + } + + /// + /// Loads any native ImageProcessor binaries. + /// + public void LoadNativeBinaries() + { + lock (SyncRoot) + { + this.RegisterNativeBinaries(); + } + } + + /// + /// Registers any native binaries. + /// + /// + /// Thrown when a native binary cannot be loaded. + /// + private void RegisterNativeBinaries() + { + if (NativeBinaries.Any()) + { + return; + } + + string folder = Is64Bit ? "x64" : "x86"; + string sourcePath = HttpContext.Current.Server.MapPath("~/bin/" + folder); + string targetBasePath = new Uri(Assembly.GetExecutingAssembly().Location).LocalPath; + + DirectoryInfo directoryInfo = new DirectoryInfo(sourcePath); + if (directoryInfo.Exists) + { + foreach (FileInfo fileInfo in directoryInfo.EnumerateFiles("*.dll")) + { + if (fileInfo.Name.ToUpperInvariant().StartsWith("IMAGEPROCESSOR")) + { + IntPtr pointer; + string targetPath = Path.GetFullPath(Path.Combine(targetBasePath, "..\\" + folder + "\\" + fileInfo.Name)); + File.Copy(sourcePath, targetPath, true); + + try + { + // Load the binary into memory. + pointer = NativeMethods.LoadLibrary(targetPath); + } + catch (Exception ex) + { + throw new ApplicationException(ex.Message); + } + + if (pointer == IntPtr.Zero) + { + throw new ApplicationException("Cannot load " + fileInfo.Name); + } + + NativeBinaries.Add(pointer); + } + } + } + } + + /// + /// Frees the reference to the native binaries. + /// + private void FreeNativeBinaries() + { + foreach (IntPtr nativeBinary in NativeBinaries) + { + // According to http://stackoverflow.com/a/2445558/427899 you need to call this twice. + NativeMethods.FreeLibrary(nativeBinary); + NativeMethods.FreeLibrary(nativeBinary); + } + } + } +} diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj index 40bd16bc7..47bd96a17 100644 --- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj +++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj @@ -62,6 +62,7 @@ + diff --git a/src/ImageProcessor.sln.DotSettings b/src/ImageProcessor.sln.DotSettings index 94cb9dbcb..4970d0c6c 100644 --- a/src/ImageProcessor.sln.DotSettings +++ b/src/ImageProcessor.sln.DotSettings @@ -1,4 +1,5 @@  + BGRA BPP DT FPX diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index 0e0d276bb..73ac24ef7 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -130,13 +130,14 @@ - + PreserveNewest - + PreserveNewest + + - + From f2205ff97c53e62b76380d930b0dd6afef5db8e8 Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 17 Jul 2014 17:20:38 +0100 Subject: [PATCH 117/155] Removing disposal code. Former-commit-id: 6952c37add20141569f77f9820ac5f4a2ffde853 --- .../NET45/HttpModules/ImageProcessingModule.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index d93f8ab77..c1ee8355e 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -13,7 +13,6 @@ namespace ImageProcessor.Web.HttpModules #region Using using System; using System.Collections.Concurrent; - using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; @@ -178,12 +177,6 @@ namespace ImageProcessor.Web.HttpModules if (disposing) { // Dispose of any managed resources here. - foreach (KeyValuePair semaphore in SemaphoreSlims) - { - semaphore.Value.Dispose(); - } - - SemaphoreSlims.Clear(); } // Call the appropriate methods to clean up @@ -385,7 +378,7 @@ namespace ImageProcessor.Web.HttpModules if (isRemote) { SemaphoreSlim semaphore = GetSemaphoreSlim(cachedPath); -#if NET45 +#if NET45 && !__MonoCS__ await semaphore.WaitAsync(); #else semaphore.Wait(); @@ -437,7 +430,7 @@ namespace ImageProcessor.Web.HttpModules else { SemaphoreSlim semaphore = GetSemaphoreSlim(cachedPath); -#if NET45 +#if NET45 && !__MonoCS__ await semaphore.WaitAsync(); #else semaphore.Wait(); From f4dbae4e67bcb30bd5950daa4144690bb6e85377 Mon Sep 17 00:00:00 2001 From: James South Date: Sun, 27 Jul 2014 23:07:11 +0100 Subject: [PATCH 118/155] Adding Linux native dll loading Former-commit-id: b717cc2c643ea66a4ded51211a6efa96217a58dc --- .../Configuration/NativeBinaryFactory.cs | 11 +++++++- .../Configuration/NativeMethods.cs | 28 +++++++++++++++++++ .../images/output/rotate.jpg | 3 ++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/ImageProcessorConsole/images/output/rotate.jpg diff --git a/src/ImageProcessor/Configuration/NativeBinaryFactory.cs b/src/ImageProcessor/Configuration/NativeBinaryFactory.cs index 741da61e2..e210aa036 100644 --- a/src/ImageProcessor/Configuration/NativeBinaryFactory.cs +++ b/src/ImageProcessor/Configuration/NativeBinaryFactory.cs @@ -94,7 +94,7 @@ namespace ImageProcessor.Configuration Assembly assembly = Assembly.GetExecutingAssembly(); string targetBasePath = new Uri(assembly.Location).LocalPath; string targetPath = Path.GetFullPath(Path.Combine(targetBasePath, "..\\" + folder + "\\" + name)); - + // Copy the file across if necessary. FileInfo fileInfo = new FileInfo(targetPath); bool rewrite = true; @@ -122,8 +122,13 @@ namespace ImageProcessor.Configuration try { +#if !__MonoCS__ // Load the binary into memory. pointer = NativeMethods.LoadLibrary(targetPath); +#else + // Load the binary into memory. The second parameter forces it to load immediately. + pointer = NativeMethods.dlopen(targetPath, 2); +#endif } catch (Exception ex) { @@ -187,9 +192,13 @@ namespace ImageProcessor.Configuration { IntPtr pointer = nativeBinary.Value; +#if !__MonoCS__ // According to http://stackoverflow.com/a/2445558/427899 you need to call this twice. NativeMethods.FreeLibrary(pointer); NativeMethods.FreeLibrary(pointer); +#else + NativeMethods.dlclose(pointer); +#endif } } } diff --git a/src/ImageProcessor/Configuration/NativeMethods.cs b/src/ImageProcessor/Configuration/NativeMethods.cs index a20b5a86f..6c1ab9805 100644 --- a/src/ImageProcessor/Configuration/NativeMethods.cs +++ b/src/ImageProcessor/Configuration/NativeMethods.cs @@ -40,5 +40,33 @@ namespace ImageProcessor.Configuration /// If the function succeeds, the return value is nonzero; otherwise zero. [DllImport("kernel32", CharSet = CharSet.Auto)] public static extern bool FreeLibrary(IntPtr hModule); + + /// + /// Loads the specified module into the address space of the calling process. + /// The specified module may cause other modules to be loaded. + /// + /// + /// The name of the module. This can be either a library module or + /// an executable module. + /// + /// + /// The flag indicating whether to load the library immediately or lazily. + /// + /// + /// If the function succeeds, the return value is a handle to the module; otherwise null. + /// + [System.Runtime.InteropServices.DllImport("libdl")] + public static extern IntPtr dlopen(string libname, int flags); + + /// + /// Frees the loaded dynamic-link library (DLL) module and, if necessary, decrements its reference count. + /// When the reference count reaches zero, the module is unloaded from the address space of the calling + /// process and the handle is no longer valid. + /// + /// A handle to the loaded library module. + /// The LoadLibrary, LoadLibraryEx, GetModuleHandle, or GetModuleHandleEx function returns this handle. + /// If the function succeeds, the return value is nonzero; otherwise zero. + [System.Runtime.InteropServices.DllImport("libdl")] + public static extern int dlclose(IntPtr hModule); } } diff --git a/src/ImageProcessorConsole/images/output/rotate.jpg b/src/ImageProcessorConsole/images/output/rotate.jpg new file mode 100644 index 000000000..a9b8b74dc --- /dev/null +++ b/src/ImageProcessorConsole/images/output/rotate.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b7215a59e681f4100078aeb74b5d423dcea54b9d2ea924a2bb7c74b2db3ee3a +size 26227 From f6830f7350addaaf62dc75d1077339e9b43a7836 Mon Sep 17 00:00:00 2001 From: Jeavon Leopold Date: Mon, 28 Jul 2014 17:40:38 +0100 Subject: [PATCH 119/155] Fix for #70 - Height and width ratio should round up to nearest pixel Former-commit-id: d7f54db5301d84a633ee50faeddc22973d4203e8 --- src/ImageProcessor.Web/NET45/Processors/Resize.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageProcessor.Web/NET45/Processors/Resize.cs b/src/ImageProcessor.Web/NET45/Processors/Resize.cs index 09ce9bc3c..3c1772911 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Resize.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Resize.cs @@ -205,13 +205,13 @@ namespace ImageProcessor.Web.Processors // Replace 0 width if (size.Width == 0 && size.Height > 0 && input.Contains(WidthRatio) && !input.Contains(HeightRatio)) { - size.Width = (int)(value.ToPositiveFloatArray()[0] * size.Height); + size.Width = (int)Math.Ceiling(value.ToPositiveFloatArray()[0] * size.Height); } // Replace 0 height if (size.Height == 0 && size.Width > 0 && input.Contains(HeightRatio) && !input.Contains(WidthRatio)) { - size.Height = (int)(value.ToPositiveFloatArray()[0] * size.Width); + size.Height = (int)Math.Ceiling(value.ToPositiveFloatArray()[0] * size.Width); } } From 7f44a51f72a5778f425b2cb12a1e4f18e3ac0a10 Mon Sep 17 00:00:00 2001 From: James South Date: Fri, 1 Aug 2014 15:42:50 +0100 Subject: [PATCH 120/155] Fixing virtual directory mapping issue Former-commit-id: 1adc402cdb870e1399e0d8c297268371237aafa2 --- .../NET45/Caching/DiskCache.cs | 77 +++++++++---------- .../HttpModules/ImageProcessingModule.cs | 6 +- 2 files changed, 38 insertions(+), 45 deletions(-) diff --git a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs index be6b88744..c6300c64d 100644 --- a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs +++ b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs @@ -49,14 +49,14 @@ namespace ImageProcessor.Web.Caching private const int MaxFilesCount = 100; /// - /// The absolute path to virtual cache path on the server. + /// The virtual cache path. /// - private static readonly string AbsoluteCachePath = HostingEnvironment.MapPath(ImageProcessorConfiguration.Instance.VirtualCachePath); + private static readonly string VirtualCachePath = ImageProcessorConfiguration.Instance.VirtualCachePath; /// - /// The request for the image. + /// The absolute path to virtual cache path on the server. /// - private readonly HttpRequest request; + private static readonly string AbsoluteCachePath = HostingEnvironment.MapPath(ImageProcessorConfiguration.Instance.VirtualCachePath); /// /// The request path for the image. @@ -72,15 +72,22 @@ namespace ImageProcessor.Web.Caching /// The image name /// private readonly string imageName; + + /// + /// The physical cached path. + /// + private string physicalCachedPath; + + /// + /// The virtual cached path. + /// + private string virtualCachedPath; #endregion #region Constructors /// /// Initializes a new instance of the class. /// - /// - /// The request for the image. - /// /// /// The request path for the image. /// @@ -90,53 +97,41 @@ namespace ImageProcessor.Web.Caching /// /// The image name. /// - public DiskCache(HttpRequest request, string requestPath, string fullPath, string imageName) + public DiskCache(string requestPath, string fullPath, string imageName) { - this.request = request; this.requestPath = requestPath; this.fullPath = fullPath; this.imageName = imageName; + + // Get the physical and virtual paths. + this.GetCachePaths(); } #endregion - #region Methods - #region Internal /// - /// Gets the full transformed cached path for the image. - /// The images are stored in paths that are based upon the SHA1 of their full request path - /// taking the individual characters of the hash to determine their location. - /// This allows us to store millions of images. + /// Gets the cached path. /// - /// The full cached path for the image. - internal Task GetCachePathAsync() + public string CachedPath { - return TaskHelpers.Run(this.GetCachePath); + get + { + return this.physicalCachedPath; + } } /// - /// Gets the virtual path to the cached processed image. + /// Gets the cached path. /// - /// - /// The path to the cached image. - /// - /// - /// The virtual path to the cached processed image. - /// - internal string GetVirtualCachedPath(string cachedPath) + public string VirtualCachedPath { - string applicationPath = this.request.PhysicalApplicationPath; - string virtualDir = this.request.ApplicationPath; - virtualDir = virtualDir == "/" ? virtualDir : (virtualDir + "/"); - - if (applicationPath != null) + get { - return cachedPath.Replace(applicationPath, virtualDir).Replace(@"\", "/"); + return this.virtualCachedPath; } - - throw new InvalidOperationException( - "We can only map an absolute back to a relative path if the application path is available."); } + #region Methods + #region Internal /// /// Adds an image to the cache. /// @@ -256,15 +251,13 @@ namespace ImageProcessor.Web.Caching } /// - /// Gets the full transformed cached path for the image. + /// Gets the full transformed cached paths for the image. /// The images are stored in paths that are based upon the SHA1 of their full request path /// taking the individual characters of the hash to determine their location. /// This allows us to store millions of images. /// - /// The full cached path for the image. - private string GetCachePath() + private void GetCachePaths() { - string cachedPath = string.Empty; string streamHash = string.Empty; if (AbsoluteCachePath != null) @@ -302,16 +295,16 @@ namespace ImageProcessor.Web.Caching // Collision rate of about 1 in 10000 for the folder structure. string pathFromKey = string.Join("\\", encryptedName.ToCharArray().Take(6)); + string virtualPathFromKey = pathFromKey.Replace(@"\", "/"); string cachedFileName = string.Format( "{0}.{1}", encryptedName, !string.IsNullOrWhiteSpace(parsedExtension) ? parsedExtension.Replace(".", string.Empty) : fallbackExtension); - cachedPath = Path.Combine(AbsoluteCachePath, pathFromKey, cachedFileName); + this.physicalCachedPath = Path.Combine(AbsoluteCachePath, pathFromKey, cachedFileName); + this.virtualCachedPath = Path.Combine(VirtualCachePath, virtualPathFromKey, cachedFileName).Replace(@"\", "/"); } - - return cachedPath; } /// diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index c1ee8355e..0f4db86f3 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -338,15 +338,15 @@ namespace ImageProcessor.Web.HttpModules } // Create a new cache to help process and cache the request. - DiskCache cache = new DiskCache(request, requestPath, fullPath, imageName); - string cachedPath = await cache.GetCachePathAsync(); + DiskCache cache = new DiskCache(requestPath, fullPath, imageName); + string cachedPath = cache.CachedPath; // Since we are now rewriting the path we need to check again that the current user has access // to the rewritten path. // Get the user for the current request // If the user is anonymous or authentication doesn't work for this suffix avoid a NullReferenceException // in the UrlAuthorizationModule by creating a generic identity. - string virtualCachedPath = cache.GetVirtualCachedPath(cachedPath); + string virtualCachedPath = cache.VirtualCachedPath; IPrincipal user = context.User ?? new GenericPrincipal(new GenericIdentity(string.Empty, string.Empty), new string[0]); From 37b1e1f86638e5064f900bc35bda7688e1632c4c Mon Sep 17 00:00:00 2001 From: James South Date: Mon, 4 Aug 2014 15:51:44 +0100 Subject: [PATCH 121/155] Adding AsyncDeDuper Former-commit-id: 30973a9ce646ad5301c4c68fbd66ddb2d37b8f29 --- .../NET4/ImageProcessor.Web_NET4.csproj | 3 + .../NET45/Helpers/AsyncDeDuperLock.cs | 134 ++++++++++++++++++ .../HttpModules/ImageProcessingModule.cs | 40 +----- .../NET45/ImageProcessor.Web_NET45.csproj | 1 + 4 files changed, 144 insertions(+), 34 deletions(-) create mode 100644 src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs diff --git a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj index 82d3986a7..601953a5e 100644 --- a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj +++ b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj @@ -101,6 +101,9 @@ StringExtensions.cs + + AsyncDeDuperLock.cs + CommonParameterParserUtility.cs diff --git a/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs b/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs new file mode 100644 index 000000000..7d6fbf0cd --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs @@ -0,0 +1,134 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Throttles duplicate requests. +// +// -------------------------------------------------------------------------------------------------------------------- +namespace ImageProcessor.Web.Helpers +{ + using System; + using System.Collections.Concurrent; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Throttles duplicate requests. + /// Based loosely on + /// + public sealed class AsyncDeDuperLock + { + /// + /// The semaphore slims. + /// + private static readonly ConcurrentDictionary SemaphoreSlims = new ConcurrentDictionary(); + + /// + /// The lock. + /// + /// + /// The hash. + /// + /// + /// The . + /// + public IDisposable Lock(string key) + { + DisposableScope releaser = new DisposableScope( + key, + s => + { + SemaphoreSlim locker; + if (SemaphoreSlims.TryRemove(s, out locker)) + { + locker.Release(); + locker.Dispose(); + } + }); + + SemaphoreSlim semaphore = SemaphoreSlims.GetOrAdd(key, new SemaphoreSlim(1, 1)); + semaphore.Wait(); + return releaser; + } + +#if NET45 && !__MonoCS__ + /// + /// The lock async. + /// + /// + /// The key. + /// + /// + /// The . + /// + public Task LockAsync(string key) + { + DisposableScope releaser = new DisposableScope( + key, + s => + { + SemaphoreSlim locker; + if (SemaphoreSlims.TryRemove(s, out locker)) + { + locker.Release(); + locker.Dispose(); + } + }); + + Task releaserTask = Task.FromResult(releaser as IDisposable); + SemaphoreSlim semaphore = SemaphoreSlims.GetOrAdd(key, new SemaphoreSlim(1, 1)); + + Task waitTask = semaphore.WaitAsync(); + + return waitTask.IsCompleted + ? releaserTask + : waitTask.ContinueWith( + (_, r) => (IDisposable)r, + releaser, + CancellationToken.None, + TaskContinuationOptions.ExecuteSynchronously, + TaskScheduler.Default); + } +#endif + /// + /// The disposable scope. + /// + internal sealed class DisposableScope : IDisposable + { + /// + /// The key + /// + private readonly string key; + + /// + /// The close scope action. + /// + private readonly Action closeScopeAction; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The key. + /// + /// + /// The close scope action. + /// + public DisposableScope(string key, Action closeScopeAction) + { + this.key = key; + this.closeScopeAction = closeScopeAction; + } + + /// + /// The dispose. + /// + public void Dispose() + { + this.closeScopeAction(this.key); + } + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index 0f4db86f3..2fe0a275d 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -12,7 +12,6 @@ namespace ImageProcessor.Web.HttpModules { #region Using using System; - using System.Collections.Concurrent; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; @@ -22,7 +21,6 @@ namespace ImageProcessor.Web.HttpModules using System.Security.Permissions; using System.Security.Principal; using System.Text.RegularExpressions; - using System.Threading; using System.Threading.Tasks; using System.Web; using System.Web.Hosting; @@ -56,9 +54,9 @@ namespace ImageProcessor.Web.HttpModules private static readonly string AssemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); /// - /// The collection of SemaphoreSlims for identifying given locking individual queries. + /// The locker for preventing duplicate requests. /// - private static readonly ConcurrentDictionary SemaphoreSlims = new ConcurrentDictionary(); + private static readonly AsyncDeDuperLock Locker = new AsyncDeDuperLock(); /// /// The value to prefix any remote image requests with to ensure they get captured. @@ -149,20 +147,6 @@ namespace ImageProcessor.Web.HttpModules GC.SuppressFinalize(this); } - /// - /// Gets the specific for the given id. - /// - /// - /// The id representing the . - /// - /// - /// The for the given id. - /// - private static SemaphoreSlim GetSemaphoreSlim(string id) - { - return SemaphoreSlims.GetOrAdd(id, new SemaphoreSlim(1, 1)); - } - /// /// Disposes the object and frees resources for the Garbage Collector. /// @@ -377,13 +361,11 @@ namespace ImageProcessor.Web.HttpModules { if (isRemote) { - SemaphoreSlim semaphore = GetSemaphoreSlim(cachedPath); #if NET45 && !__MonoCS__ - await semaphore.WaitAsync(); + using (await Locker.LockAsync(cachedPath)) #else - semaphore.Wait(); + using (Locker.Lock(cachedPath)) #endif - try { Uri uri = new Uri(requestPath + "?" + urlParameters); RemoteFile remoteFile = new RemoteFile(uri, false); @@ -422,20 +404,14 @@ namespace ImageProcessor.Web.HttpModules } } } - finally - { - semaphore.Release(); - } } else { - SemaphoreSlim semaphore = GetSemaphoreSlim(cachedPath); #if NET45 && !__MonoCS__ - await semaphore.WaitAsync(); + using (await Locker.LockAsync(cachedPath)) #else - semaphore.Wait(); + using (Locker.Lock(cachedPath)) #endif - try { // Check to see if the file exists. // ReSharper disable once AssignNullToNotNullAttribute @@ -460,10 +436,6 @@ namespace ImageProcessor.Web.HttpModules // Trim the cache. await cache.TrimCachedFolderAsync(cachedPath); } - finally - { - semaphore.Release(); - } } } } diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj index 40bd16bc7..6d4694400 100644 --- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj +++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj @@ -56,6 +56,7 @@ + From 8a302ac126fe1979063050da4488f7f80f69db7a Mon Sep 17 00:00:00 2001 From: James South Date: Mon, 4 Aug 2014 20:40:41 +0100 Subject: [PATCH 122/155] Make DisposalScope private Former-commit-id: 37dfbb252936c81d0b2014fa4e01809564505451 --- src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs b/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs index 7d6fbf0cd..c6896c3a0 100644 --- a/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs +++ b/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs @@ -23,7 +23,8 @@ namespace ImageProcessor.Web.Helpers /// /// The semaphore slims. /// - private static readonly ConcurrentDictionary SemaphoreSlims = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary SemaphoreSlims + = new ConcurrentDictionary(); /// /// The lock. @@ -79,7 +80,7 @@ namespace ImageProcessor.Web.Helpers Task releaserTask = Task.FromResult(releaser as IDisposable); SemaphoreSlim semaphore = SemaphoreSlims.GetOrAdd(key, new SemaphoreSlim(1, 1)); - + Task waitTask = semaphore.WaitAsync(); return waitTask.IsCompleted @@ -95,7 +96,7 @@ namespace ImageProcessor.Web.Helpers /// /// The disposable scope. /// - internal sealed class DisposableScope : IDisposable + private sealed class DisposableScope : IDisposable { /// /// The key From 79a0201003ee6cc7d4da15cc22585f4db275f76a Mon Sep 17 00:00:00 2001 From: James South Date: Sun, 27 Jul 2014 23:07:11 +0100 Subject: [PATCH 123/155] Adding Linux native dll loading Former-commit-id: bf4c36486c3e3db4883d766162c4cf5c3c32da74 --- .../Configuration/NativeBinaryFactory.cs | 11 +++++++- .../Configuration/NativeMethods.cs | 28 +++++++++++++++++++ .../images/output/rotate.jpg | 3 ++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/ImageProcessorConsole/images/output/rotate.jpg diff --git a/src/ImageProcessor/Configuration/NativeBinaryFactory.cs b/src/ImageProcessor/Configuration/NativeBinaryFactory.cs index 741da61e2..e210aa036 100644 --- a/src/ImageProcessor/Configuration/NativeBinaryFactory.cs +++ b/src/ImageProcessor/Configuration/NativeBinaryFactory.cs @@ -94,7 +94,7 @@ namespace ImageProcessor.Configuration Assembly assembly = Assembly.GetExecutingAssembly(); string targetBasePath = new Uri(assembly.Location).LocalPath; string targetPath = Path.GetFullPath(Path.Combine(targetBasePath, "..\\" + folder + "\\" + name)); - + // Copy the file across if necessary. FileInfo fileInfo = new FileInfo(targetPath); bool rewrite = true; @@ -122,8 +122,13 @@ namespace ImageProcessor.Configuration try { +#if !__MonoCS__ // Load the binary into memory. pointer = NativeMethods.LoadLibrary(targetPath); +#else + // Load the binary into memory. The second parameter forces it to load immediately. + pointer = NativeMethods.dlopen(targetPath, 2); +#endif } catch (Exception ex) { @@ -187,9 +192,13 @@ namespace ImageProcessor.Configuration { IntPtr pointer = nativeBinary.Value; +#if !__MonoCS__ // According to http://stackoverflow.com/a/2445558/427899 you need to call this twice. NativeMethods.FreeLibrary(pointer); NativeMethods.FreeLibrary(pointer); +#else + NativeMethods.dlclose(pointer); +#endif } } } diff --git a/src/ImageProcessor/Configuration/NativeMethods.cs b/src/ImageProcessor/Configuration/NativeMethods.cs index a20b5a86f..6c1ab9805 100644 --- a/src/ImageProcessor/Configuration/NativeMethods.cs +++ b/src/ImageProcessor/Configuration/NativeMethods.cs @@ -40,5 +40,33 @@ namespace ImageProcessor.Configuration /// If the function succeeds, the return value is nonzero; otherwise zero. [DllImport("kernel32", CharSet = CharSet.Auto)] public static extern bool FreeLibrary(IntPtr hModule); + + /// + /// Loads the specified module into the address space of the calling process. + /// The specified module may cause other modules to be loaded. + /// + /// + /// The name of the module. This can be either a library module or + /// an executable module. + /// + /// + /// The flag indicating whether to load the library immediately or lazily. + /// + /// + /// If the function succeeds, the return value is a handle to the module; otherwise null. + /// + [System.Runtime.InteropServices.DllImport("libdl")] + public static extern IntPtr dlopen(string libname, int flags); + + /// + /// Frees the loaded dynamic-link library (DLL) module and, if necessary, decrements its reference count. + /// When the reference count reaches zero, the module is unloaded from the address space of the calling + /// process and the handle is no longer valid. + /// + /// A handle to the loaded library module. + /// The LoadLibrary, LoadLibraryEx, GetModuleHandle, or GetModuleHandleEx function returns this handle. + /// If the function succeeds, the return value is nonzero; otherwise zero. + [System.Runtime.InteropServices.DllImport("libdl")] + public static extern int dlclose(IntPtr hModule); } } diff --git a/src/ImageProcessorConsole/images/output/rotate.jpg b/src/ImageProcessorConsole/images/output/rotate.jpg new file mode 100644 index 000000000..a9b8b74dc --- /dev/null +++ b/src/ImageProcessorConsole/images/output/rotate.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b7215a59e681f4100078aeb74b5d423dcea54b9d2ea924a2bb7c74b2db3ee3a +size 26227 From 11b045dec9f6f9e45d135f5f3699a197a336fc03 Mon Sep 17 00:00:00 2001 From: Jeavon Leopold Date: Mon, 28 Jul 2014 17:40:38 +0100 Subject: [PATCH 124/155] Fix for #70 - Height and width ratio should round up to nearest pixel Former-commit-id: 9d7ccd05efaed9b5d4b15196d8062672b26a2d6e --- src/ImageProcessor.Web/NET45/Processors/Resize.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageProcessor.Web/NET45/Processors/Resize.cs b/src/ImageProcessor.Web/NET45/Processors/Resize.cs index 09ce9bc3c..3c1772911 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Resize.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Resize.cs @@ -205,13 +205,13 @@ namespace ImageProcessor.Web.Processors // Replace 0 width if (size.Width == 0 && size.Height > 0 && input.Contains(WidthRatio) && !input.Contains(HeightRatio)) { - size.Width = (int)(value.ToPositiveFloatArray()[0] * size.Height); + size.Width = (int)Math.Ceiling(value.ToPositiveFloatArray()[0] * size.Height); } // Replace 0 height if (size.Height == 0 && size.Width > 0 && input.Contains(HeightRatio) && !input.Contains(WidthRatio)) { - size.Height = (int)(value.ToPositiveFloatArray()[0] * size.Width); + size.Height = (int)Math.Ceiling(value.ToPositiveFloatArray()[0] * size.Width); } } From 9067062aafa6946b9f3e053061d65c1209590f0f Mon Sep 17 00:00:00 2001 From: James South Date: Mon, 4 Aug 2014 15:51:44 +0100 Subject: [PATCH 125/155] Adding AsyncDeDuper Former-commit-id: a5e1f827c161642d6de2b164dcd3224195975ac9 --- .../NET4/ImageProcessor.Web_NET4.csproj | 3 + .../NET45/Helpers/AsyncDeDuperLock.cs | 134 ++++++++++++++++++ .../HttpModules/ImageProcessingModule.cs | 40 +----- .../NET45/ImageProcessor.Web_NET45.csproj | 1 + 4 files changed, 144 insertions(+), 34 deletions(-) create mode 100644 src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs diff --git a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj index 82d3986a7..601953a5e 100644 --- a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj +++ b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj @@ -101,6 +101,9 @@ StringExtensions.cs + + AsyncDeDuperLock.cs + CommonParameterParserUtility.cs diff --git a/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs b/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs new file mode 100644 index 000000000..7d6fbf0cd --- /dev/null +++ b/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs @@ -0,0 +1,134 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Throttles duplicate requests. +// +// -------------------------------------------------------------------------------------------------------------------- +namespace ImageProcessor.Web.Helpers +{ + using System; + using System.Collections.Concurrent; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Throttles duplicate requests. + /// Based loosely on + /// + public sealed class AsyncDeDuperLock + { + /// + /// The semaphore slims. + /// + private static readonly ConcurrentDictionary SemaphoreSlims = new ConcurrentDictionary(); + + /// + /// The lock. + /// + /// + /// The hash. + /// + /// + /// The . + /// + public IDisposable Lock(string key) + { + DisposableScope releaser = new DisposableScope( + key, + s => + { + SemaphoreSlim locker; + if (SemaphoreSlims.TryRemove(s, out locker)) + { + locker.Release(); + locker.Dispose(); + } + }); + + SemaphoreSlim semaphore = SemaphoreSlims.GetOrAdd(key, new SemaphoreSlim(1, 1)); + semaphore.Wait(); + return releaser; + } + +#if NET45 && !__MonoCS__ + /// + /// The lock async. + /// + /// + /// The key. + /// + /// + /// The . + /// + public Task LockAsync(string key) + { + DisposableScope releaser = new DisposableScope( + key, + s => + { + SemaphoreSlim locker; + if (SemaphoreSlims.TryRemove(s, out locker)) + { + locker.Release(); + locker.Dispose(); + } + }); + + Task releaserTask = Task.FromResult(releaser as IDisposable); + SemaphoreSlim semaphore = SemaphoreSlims.GetOrAdd(key, new SemaphoreSlim(1, 1)); + + Task waitTask = semaphore.WaitAsync(); + + return waitTask.IsCompleted + ? releaserTask + : waitTask.ContinueWith( + (_, r) => (IDisposable)r, + releaser, + CancellationToken.None, + TaskContinuationOptions.ExecuteSynchronously, + TaskScheduler.Default); + } +#endif + /// + /// The disposable scope. + /// + internal sealed class DisposableScope : IDisposable + { + /// + /// The key + /// + private readonly string key; + + /// + /// The close scope action. + /// + private readonly Action closeScopeAction; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The key. + /// + /// + /// The close scope action. + /// + public DisposableScope(string key, Action closeScopeAction) + { + this.key = key; + this.closeScopeAction = closeScopeAction; + } + + /// + /// The dispose. + /// + public void Dispose() + { + this.closeScopeAction(this.key); + } + } + } +} \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index 0f4db86f3..2fe0a275d 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -12,7 +12,6 @@ namespace ImageProcessor.Web.HttpModules { #region Using using System; - using System.Collections.Concurrent; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; @@ -22,7 +21,6 @@ namespace ImageProcessor.Web.HttpModules using System.Security.Permissions; using System.Security.Principal; using System.Text.RegularExpressions; - using System.Threading; using System.Threading.Tasks; using System.Web; using System.Web.Hosting; @@ -56,9 +54,9 @@ namespace ImageProcessor.Web.HttpModules private static readonly string AssemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); /// - /// The collection of SemaphoreSlims for identifying given locking individual queries. + /// The locker for preventing duplicate requests. /// - private static readonly ConcurrentDictionary SemaphoreSlims = new ConcurrentDictionary(); + private static readonly AsyncDeDuperLock Locker = new AsyncDeDuperLock(); /// /// The value to prefix any remote image requests with to ensure they get captured. @@ -149,20 +147,6 @@ namespace ImageProcessor.Web.HttpModules GC.SuppressFinalize(this); } - /// - /// Gets the specific for the given id. - /// - /// - /// The id representing the . - /// - /// - /// The for the given id. - /// - private static SemaphoreSlim GetSemaphoreSlim(string id) - { - return SemaphoreSlims.GetOrAdd(id, new SemaphoreSlim(1, 1)); - } - /// /// Disposes the object and frees resources for the Garbage Collector. /// @@ -377,13 +361,11 @@ namespace ImageProcessor.Web.HttpModules { if (isRemote) { - SemaphoreSlim semaphore = GetSemaphoreSlim(cachedPath); #if NET45 && !__MonoCS__ - await semaphore.WaitAsync(); + using (await Locker.LockAsync(cachedPath)) #else - semaphore.Wait(); + using (Locker.Lock(cachedPath)) #endif - try { Uri uri = new Uri(requestPath + "?" + urlParameters); RemoteFile remoteFile = new RemoteFile(uri, false); @@ -422,20 +404,14 @@ namespace ImageProcessor.Web.HttpModules } } } - finally - { - semaphore.Release(); - } } else { - SemaphoreSlim semaphore = GetSemaphoreSlim(cachedPath); #if NET45 && !__MonoCS__ - await semaphore.WaitAsync(); + using (await Locker.LockAsync(cachedPath)) #else - semaphore.Wait(); + using (Locker.Lock(cachedPath)) #endif - try { // Check to see if the file exists. // ReSharper disable once AssignNullToNotNullAttribute @@ -460,10 +436,6 @@ namespace ImageProcessor.Web.HttpModules // Trim the cache. await cache.TrimCachedFolderAsync(cachedPath); } - finally - { - semaphore.Release(); - } } } } diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj index 40bd16bc7..6d4694400 100644 --- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj +++ b/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj @@ -56,6 +56,7 @@ + From 18b7787c8b70d99a2c0e6e63d3b31477be459d76 Mon Sep 17 00:00:00 2001 From: James South Date: Mon, 4 Aug 2014 20:40:41 +0100 Subject: [PATCH 126/155] Make DisposalScope private Former-commit-id: b0d20c38ada344b0d457db7b78a7680366b3e696 --- src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs b/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs index 7d6fbf0cd..c6896c3a0 100644 --- a/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs +++ b/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs @@ -23,7 +23,8 @@ namespace ImageProcessor.Web.Helpers /// /// The semaphore slims. /// - private static readonly ConcurrentDictionary SemaphoreSlims = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary SemaphoreSlims + = new ConcurrentDictionary(); /// /// The lock. @@ -79,7 +80,7 @@ namespace ImageProcessor.Web.Helpers Task releaserTask = Task.FromResult(releaser as IDisposable); SemaphoreSlim semaphore = SemaphoreSlims.GetOrAdd(key, new SemaphoreSlim(1, 1)); - + Task waitTask = semaphore.WaitAsync(); return waitTask.IsCompleted @@ -95,7 +96,7 @@ namespace ImageProcessor.Web.Helpers /// /// The disposable scope. /// - internal sealed class DisposableScope : IDisposable + private sealed class DisposableScope : IDisposable { /// /// The key From b6cf1e07e8d962e296b23c20b644349ddebd7697 Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 5 Aug 2014 00:28:03 +0100 Subject: [PATCH 127/155] WebP is now a separate plugin Former-commit-id: 072872be821a4ac73038dec5a99de6ae2552a713 --- .../HttpModules/ImageProcessingModule.cs | 41 +++++-- src/ImageProcessor.sln | 17 +++ .../ImageProcessorBootstrapper.cs | 85 ++++++++++++++- src/ImageProcessor/ImageProcessor.csproj | 6 -- .../ImageProcessorConsole.csproj | 4 + .../images/output/4.sm.webp | 3 + .../images/output/test.webp | 3 + .../ImageProcessor.Plugins.WebP.csproj | 67 ++++++++++++ .../Imaging/Formats/NativeMethods.cs | 6 +- .../Imaging/Formats/WebPFormat.cs | 3 +- .../Properties/AssemblyInfo.cs | 36 +++++++ .../Unmanaged/x64/libwebp.dll.REMOVED.git-id | 0 .../Unmanaged/x86/libwebp.dll.REMOVED.git-id | 0 .../Controllers/HomeController.cs | 5 + .../Test_Website_MVC_NET45.csproj | 7 ++ .../Test_Website_NET45/Views/Home/WebP.cshtml | 100 ++++++++++++++++++ .../Views/Shared/_Layout.cshtml | 1 + 17 files changed, 361 insertions(+), 23 deletions(-) create mode 100644 src/ImageProcessorConsole/images/output/4.sm.webp create mode 100644 src/ImageProcessorConsole/images/output/test.webp create mode 100644 src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/ImageProcessor.Plugins.WebP.csproj rename src/{ImageProcessor => Plugins/ImageProcessor/ImageProcessor.Plugins.WebP}/Imaging/Formats/NativeMethods.cs (96%) rename src/{ImageProcessor => Plugins/ImageProcessor/ImageProcessor.Plugins.WebP}/Imaging/Formats/WebPFormat.cs (98%) create mode 100644 src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Properties/AssemblyInfo.cs rename src/{ImageProcessor => Plugins/ImageProcessor/ImageProcessor.Plugins.WebP}/Resources/Unmanaged/x64/libwebp.dll.REMOVED.git-id (100%) rename src/{ImageProcessor => Plugins/ImageProcessor/ImageProcessor.Plugins.WebP}/Resources/Unmanaged/x86/libwebp.dll.REMOVED.git-id (100%) create mode 100644 src/TestWebsites/NET45/Test_Website_NET45/Views/Home/WebP.cshtml diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index 2fe0a275d..d7b15e7e1 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -43,6 +43,11 @@ namespace ImageProcessor.Web.HttpModules /// private const string CachedResponseTypeKey = "CACHED_IMAGE_RESPONSE_TYPE_054F217C-11CF-49FF-8D2F-698E8E6EB58F"; + /// + /// The key for storing the file dependency of the current image. + /// + private const string CachedResponseFileDependency = "CACHED_IMAGE_DEPENDENCY_054F217C-11CF-49FF-8D2F-698E8E6EB58F"; + /// /// The regular expression to search strings for. /// @@ -215,15 +220,18 @@ namespace ImageProcessor.Web.HttpModules HttpContext context = ((HttpApplication)sender).Context; object responseTypeObject = context.Items[CachedResponseTypeKey]; + object dependencyFileObject = context.Items[CachedResponseFileDependency]; - if (responseTypeObject != null) + if (responseTypeObject != null && dependencyFileObject != null) { string responseType = (string)responseTypeObject; + string dependencyFile = (string)dependencyFileObject; // Set the headers - this.SetHeaders(context, responseType); + this.SetHeaders(context, responseType, dependencyFile); context.Items[CachedResponseTypeKey] = null; + context.Items[CachedResponseFileDependency] = null; } } @@ -440,7 +448,15 @@ namespace ImageProcessor.Web.HttpModules } } - string incomingEtag = context.Request.Headers["If-None-Match"]; + // Image is from the cache so the mime-type will need to be set. + if (context.Items[CachedResponseTypeKey] == null) + { + context.Items[CachedResponseTypeKey] = ImageHelpers.GetExtension(cachedPath).Replace(".", "image/"); + } + + context.Items[CachedResponseFileDependency] = cachedPath; + + string incomingEtag = context.Request.Headers["If" + "-None-Match"]; if (incomingEtag != null && !isNewOrUpdated) { @@ -449,8 +465,7 @@ namespace ImageProcessor.Web.HttpModules context.Response.AddHeader("Content-Length", "0"); context.Response.StatusCode = (int)HttpStatusCode.NotModified; context.Response.SuppressContent = true; - context.Response.AddFileDependency(context.Server.MapPath(virtualCachedPath)); - this.SetHeaders(context, (string)context.Items[CachedResponseTypeKey]); + this.SetHeaders(context, (string)context.Items[CachedResponseTypeKey], cachedPath); if (!isRemote) { @@ -482,18 +497,28 @@ namespace ImageProcessor.Web.HttpModules /// the HttpContext object that provides /// references to the intrinsic server objects /// - /// The HTTP MIME type to to send. - private void SetHeaders(HttpContext context, string responseType) + /// + /// The HTTP MIME type to to send. + /// + /// + /// The dependency path for the cache dependency. + /// + private void SetHeaders(HttpContext context, string responseType, string dependencyPath) { HttpResponse response = context.Response; response.ContentType = responseType; - response.AddHeader("Image-Served-By", "ImageProcessor.Web/" + AssemblyVersion); + if (response.Headers["Image-Served-By"] == null) + { + response.AddHeader("Image-Served-By", "ImageProcessor.Web/" + AssemblyVersion); + } HttpCachePolicy cache = response.Cache; cache.SetCacheability(HttpCacheability.Public); cache.VaryByHeaders["Accept-Encoding"] = true; + + context.Response.AddFileDependency(dependencyPath); cache.SetLastModifiedFromFileDependencies(); int maxDays = DiskCache.MaxFileCachedDuration; diff --git a/src/ImageProcessor.sln b/src/ImageProcessor.sln index a12d17c68..8ad0ed4e9 100644 --- a/src/ImageProcessor.sln +++ b/src/ImageProcessor.sln @@ -36,6 +36,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web.UnitTest EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.UnitTests", "ImageProcessor.UnitTests\ImageProcessor.UnitTests.csproj", "{633B1C4C-4823-47BE-9A01-A665F3118C8C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Plugins.WebP", "Plugins\ImageProcessor\ImageProcessor.Plugins.WebP\ImageProcessor.Plugins.WebP.csproj", "{2CF69699-959A-44DC-A281-4E2596C25043}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Any CPU = All|Any CPU @@ -201,6 +203,21 @@ Global {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|Mixed Platforms.Build.0 = Release|Any CPU {633B1C4C-4823-47BE-9A01-A665F3118C8C}.Release|x86.ActiveCfg = Release|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.All|Any CPU.ActiveCfg = Release|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.All|Any CPU.Build.0 = Release|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.All|Mixed Platforms.ActiveCfg = Release|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.All|Mixed Platforms.Build.0 = Release|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.All|x86.ActiveCfg = Release|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.Debug|x86.ActiveCfg = Debug|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.Release|Any CPU.Build.0 = Release|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {2CF69699-959A-44DC-A281-4E2596C25043}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs index 09b772455..59f975fb3 100644 --- a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs +++ b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs @@ -4,22 +4,25 @@ // Licensed under the Apache License, Version 2.0. // // -// The image processor bootstrapper. +// The ImageProcessor bootstrapper. // // -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Configuration { using System; + using System.Collections; using System.Collections.Generic; + using System.IO; using System.Linq; + using System.Reflection; using ImageProcessor.Common.Exceptions; using ImageProcessor.Common.Extensions; using ImageProcessor.Imaging.Formats; /// - /// The image processor bootstrapper. + /// The ImageProcessor bootstrapper. /// public class ImageProcessorBootstrapper { @@ -35,8 +38,8 @@ namespace ImageProcessor.Configuration /// private ImageProcessorBootstrapper() { - this.LoadSupportedImageFormats(); this.NativeBinaryFactory = new NativeBinaryFactory(); + this.LoadSupportedImageFormats(); } /// @@ -70,14 +73,42 @@ namespace ImageProcessor.Configuration try { Type type = typeof(ISupportedImageFormat); + HashSet found = new HashSet(); + + // Get any references and used assemblies. + foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + this.LoadReferencedAssemblies(found, assembly); + } + + // Get any referenced but not used assemblies. + Assembly executingAssembly = Assembly.GetExecutingAssembly(); + string targetBasePath = Path.GetDirectoryName(new Uri(executingAssembly.Location).LocalPath); + + // ReSharper disable once AssignNullToNotNullAttribute + FileInfo[] files = new DirectoryInfo(targetBasePath).GetFiles("*.dll", SearchOption.AllDirectories); + + foreach (FileInfo fileInfo in files) + { + AssemblyName assemblyName = AssemblyName.GetAssemblyName(fileInfo.FullName); + + if (!AppDomain.CurrentDomain.GetAssemblies() + .Any(a => AssemblyName.ReferenceMatchesDefinition(assemblyName, a.GetName()))) + { + // In a web app, this assembly will automatically be bound from the + // Asp.Net Temporary folder from where the site actually runs. + this.LoadReferencedAssemblies(found, Assembly.Load(assemblyName)); + } + } + List availableTypes = AppDomain.CurrentDomain .GetAssemblies() - .SelectMany(s => s.GetLoadableTypes()) + .SelectMany(a => a.GetLoadableTypes()) .Where(t => type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract) .ToList(); this.SupportedImageFormats = availableTypes - .Select(x => (Activator.CreateInstance(x) as ISupportedImageFormat)).ToList(); + .Select(f => (Activator.CreateInstance(f) as ISupportedImageFormat)).ToList(); } catch (Exception ex) { @@ -85,5 +116,49 @@ namespace ImageProcessor.Configuration } } } + + /// + /// Loads any referenced assemblies into the current application domain. + /// + /// + /// The collection containing the name of already found assemblies. + /// + /// + /// The assembly to load from. + /// + private void LoadReferencedAssemblies(HashSet found, Assembly assembly) + { + // Used to avoid duplicates + ArrayList results = new ArrayList(); + + // Resulting info + Stack stack = new Stack(); + + // Stack of names + // Store root assembly (level 0) directly into results list + stack.Push(assembly.ToString()); + + // Do a preorder, non-recursive traversal + while (stack.Count > 0) + { + string info = (string)stack.Pop(); + + // Get next assembly + if (!found.Contains(info)) + { + found.Add(info); + results.Add(info); + + // Store it to results ArrayList + Assembly child = Assembly.Load(info); + AssemblyName[] subchild = child.GetReferencedAssemblies(); + + for (int i = subchild.Length - 1; i >= 0; --i) + { + stack.Push(subchild[i].ToString()); + } + } + } + } } } diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index ad69d127b..ed1aa9c64 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -79,7 +79,6 @@ - @@ -87,7 +86,6 @@ - @@ -131,10 +129,6 @@ - - - - diff --git a/src/ImageProcessorConsole/ImageProcessorConsole.csproj b/src/ImageProcessorConsole/ImageProcessorConsole.csproj index fba366b0c..1afd8ef0e 100644 --- a/src/ImageProcessorConsole/ImageProcessorConsole.csproj +++ b/src/ImageProcessorConsole/ImageProcessorConsole.csproj @@ -56,6 +56,10 @@ {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} ImageProcessor + + {2cf69699-959a-44dc-a281-4e2596c25043} + ImageProcessor.Plugins.WebP + + \ No newline at end of file diff --git a/src/ImageProcessor/Imaging/Formats/NativeMethods.cs b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Imaging/Formats/NativeMethods.cs similarity index 96% rename from src/ImageProcessor/Imaging/Formats/NativeMethods.cs rename to src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Imaging/Formats/NativeMethods.cs index 0c42710b0..936b58256 100644 --- a/src/ImageProcessor/Imaging/Formats/NativeMethods.cs +++ b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Imaging/Formats/NativeMethods.cs @@ -8,7 +8,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Imaging.Formats +namespace ImageProcessor.Plugins.WebP.Imaging.Formats { using System; using System.IO; @@ -23,7 +23,7 @@ namespace ImageProcessor.Imaging.Formats internal static class NativeMethods { /// - /// Whether the process is running in 64bit mode. Used for calling the correct dllimport method. + /// Whether the process is running in 64bit mode. Used for calling the correct method. /// Clunky I know but I couldn't get dynamic methods to work. /// private static readonly bool Is64Bit = Environment.Is64BitProcess; @@ -34,7 +34,7 @@ namespace ImageProcessor.Imaging.Formats static NativeMethods() { string folder = Is64Bit ? "x64" : "x86"; - string name = string.Format("ImageProcessor.Resources.Unmanaged.{0}.libwebp.dll", folder); + string name = string.Format("ImageProcessor.Plugins.WebP.Resources.Unmanaged.{0}.libwebp.dll", folder); Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name); using (MemoryStream memoryStream = new MemoryStream()) diff --git a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Imaging/Formats/WebPFormat.cs similarity index 98% rename from src/ImageProcessor/Imaging/Formats/WebPFormat.cs rename to src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Imaging/Formats/WebPFormat.cs index 9f350c5c0..0bc2e2b7b 100644 --- a/src/ImageProcessor/Imaging/Formats/WebPFormat.cs +++ b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Imaging/Formats/WebPFormat.cs @@ -10,7 +10,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.Imaging.Formats +namespace ImageProcessor.Plugins.WebP.Imaging.Formats { using System; using System.Collections.Generic; @@ -22,6 +22,7 @@ namespace ImageProcessor.Imaging.Formats using System.Text; using ImageProcessor.Common.Exceptions; + using ImageProcessor.Imaging.Formats; /// /// Provides the necessary information to support webp images. diff --git a/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Properties/AssemblyInfo.cs b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..d9aa6f985 --- /dev/null +++ b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImageProcessor.Plugins.WebP")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("James South")] +[assembly: AssemblyProduct("ImageProcessor.Plugins.WebP")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("bf160db5-2ea7-4c85-9b0e-f1ddf2595e37")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/ImageProcessor/Resources/Unmanaged/x64/libwebp.dll.REMOVED.git-id b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Resources/Unmanaged/x64/libwebp.dll.REMOVED.git-id similarity index 100% rename from src/ImageProcessor/Resources/Unmanaged/x64/libwebp.dll.REMOVED.git-id rename to src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Resources/Unmanaged/x64/libwebp.dll.REMOVED.git-id diff --git a/src/ImageProcessor/Resources/Unmanaged/x86/libwebp.dll.REMOVED.git-id b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Resources/Unmanaged/x86/libwebp.dll.REMOVED.git-id similarity index 100% rename from src/ImageProcessor/Resources/Unmanaged/x86/libwebp.dll.REMOVED.git-id rename to src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/Resources/Unmanaged/x86/libwebp.dll.REMOVED.git-id diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Controllers/HomeController.cs b/src/TestWebsites/NET45/Test_Website_NET45/Controllers/HomeController.cs index 02fc35575..1eae92d44 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/Controllers/HomeController.cs +++ b/src/TestWebsites/NET45/Test_Website_NET45/Controllers/HomeController.cs @@ -41,6 +41,11 @@ namespace Test_Website_NET45.Controllers return View(); } + public ActionResult WebP() + { + return View(); + } + public ActionResult External() { return this.View(); diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Test_Website_MVC_NET45.csproj b/src/TestWebsites/NET45/Test_Website_NET45/Test_Website_MVC_NET45.csproj index 96f09d69b..c2118914f 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/Test_Website_MVC_NET45.csproj +++ b/src/TestWebsites/NET45/Test_Website_NET45/Test_Website_MVC_NET45.csproj @@ -159,6 +159,10 @@ {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} ImageProcessor + + {2cf69699-959a-44dc-a281-4e2596c25043} + ImageProcessor.Plugins.WebP + @@ -191,6 +195,9 @@ + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/WebP.cshtml b/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/WebP.cshtml new file mode 100644 index 000000000..ff03d1240 --- /dev/null +++ b/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/WebP.cshtml @@ -0,0 +1,100 @@ +@{ + ViewBag.Title = "WebP"; +} + +
+

WebP

+
+
+
+

Resized

+ +
+
+

Cropped

+ +
+
+
+
+

Filter

+
+
+

blackwhite

+ +
+
+

comic

+ +
+
+
+
+

lomograph

+ +
+
+

greyscale

+ +
+
+
+
+

polaroid

+ +
+
+

sepia

+ +
+
+
+
+

gotham

+ +
+
+

hisatch

+ +
+
+
+
+

losatch

+ +
+
+
+
+
+
+

Watermark

+ +
+
+

Format

+ +
+
+
+
+
+
+

Rotate

+ +
+
+

Quality

+ +
+
+
+
+
+
+

Alpha

+ +
+
+
+
diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Shared/_Layout.cshtml b/src/TestWebsites/NET45/Test_Website_NET45/Views/Shared/_Layout.cshtml index 74af019a2..5f8255ea4 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/Views/Shared/_Layout.cshtml +++ b/src/TestWebsites/NET45/Test_Website_NET45/Views/Shared/_Layout.cshtml @@ -29,6 +29,7 @@
  • @Html.ActionLink("Png8", "Png8")
  • @Html.ActionLink("Bmp", "Bmp")
  • @Html.ActionLink("Tiff", "Tiff")
  • +
  • @Html.ActionLink("WebP", "WebP")
  • @Html.ActionLink("External", "External")
  • From 158ae434d55c4f2ad39a821be4e33df1a571f0ab Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 5 Aug 2014 13:32:14 +0100 Subject: [PATCH 128/155] Fix dll load plus regex tests Former-commit-id: 2778a682ce325c1739e49f1e88ab7c5a8fa9f431 --- .../Extensions/DoubleExtensionsUnitTests.cs | 36 +--- .../ImageProcessor.Web.UnitTests.csproj | 4 + .../RegularExpressionUnitTests.cs | 201 +++++++++++++----- .../Helpers/CommonParameterParserUtility.cs | 2 +- .../ImageProcessorBootstrapper.cs | 8 +- 5 files changed, 161 insertions(+), 90 deletions(-) diff --git a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs index cba1c07bc..91b62d74f 100644 --- a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs @@ -10,7 +10,6 @@ namespace ImageProcessor.UnitTests.Extensions { - using System.Collections.Generic; using Common.Extensions; using NUnit.Framework; @@ -20,37 +19,20 @@ namespace ImageProcessor.UnitTests.Extensions [TestFixture] public class DoubleExtensionsUnitTests { - /// - /// Stores the values to test for the ToByte() extension method - /// - private Dictionary doubleToByteTests; - - /// - /// Sets up the values for the tests - /// - [TestFixtureSetUp] - public void Init() - { - this.doubleToByteTests = new Dictionary - { - { -10, 0x0 }, - { 1.5, 0x1 }, - { 25.7, 0x19 }, - { 1289047, 0xFF } - }; - } - /// /// Tests the double to byte conversion /// + /// Double input + /// Expected result [Test] - public void TestDoubleToByte() + [TestCase(-10, 0x0)] + [TestCase(1.5, 0x1)] + [TestCase(25.7, 0x19)] + [TestCase(1289047, 0xFF)] + public void TestDoubleToByte(double input, byte expected) { - foreach (var item in this.doubleToByteTests) - { - var result = item.Key.ToByte(); - Assert.AreEqual(item.Value, result); - } + byte result = input.ToByte(); + Assert.AreEqual(expected, result); } } } \ No newline at end of file diff --git a/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj b/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj index 460e329b9..357f3b11d 100644 --- a/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj +++ b/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj @@ -69,6 +69,10 @@ {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} ImageProcessor + + {2cf69699-959a-44dc-a281-4e2596c25043} + ImageProcessor.Plugins.WebP +
    diff --git a/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs b/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs index c41454563..86c346e38 100644 --- a/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs +++ b/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs @@ -10,10 +10,14 @@ namespace ImageProcessor.Web.UnitTests { + using System; + using System.Collections.Generic; using System.Drawing; using ImageProcessor.Imaging; using ImageProcessor.Imaging.Filters; using ImageProcessor.Imaging.Formats; + using ImageProcessor.Plugins.WebP.Imaging.Formats; + using NUnit.Framework; /// @@ -40,37 +44,55 @@ namespace ImageProcessor.Web.UnitTests } /// - /// The brightness regex unit test. + /// The contrast regex unit test. /// + /// + /// The input string. + /// + /// + /// The expected result. + /// [Test] - public void TestBrightnessRegex() + [TestCase("brightness=56", 56)] + [TestCase("brightness=84", 84)] + [TestCase("brightness=66", 66)] + [TestCase("brightness=101", 1)] + [TestCase("brightness=00001", 1)] + [TestCase("brightness=-50", -50)] + [TestCase("brightness=0", 0)] + public void TestBrightnesstRegex(string input, int expected) { - const string Querystring = "brightness=56"; - const int Expected = 56; - Processors.Brightness brightness = new Processors.Brightness(); - brightness.MatchRegexIndex(Querystring); + brightness.MatchRegexIndex(input); + int result = brightness.Processor.DynamicParameter; - int actual = brightness.Processor.DynamicParameter; - - Assert.AreEqual(Expected, actual); + Assert.AreEqual(expected, result); } /// /// The contrast regex unit test. /// + /// + /// The input string. + /// + /// + /// The expected result. + /// [Test] - public void TestContrastRegex() + [TestCase("contrast=56", 56)] + [TestCase("contrast=84", 84)] + [TestCase("contrast=66", 66)] + [TestCase("contrast=101", 1)] + [TestCase("contrast=00001", 1)] + [TestCase("contrast=-50", -50)] + [TestCase("contrast=0", 0)] + public void TestContrastRegex(string input, int expected) { - const string Querystring = "contrast=56"; - const int Expected = 56; - Processors.Contrast contrast = new Processors.Contrast(); - contrast.MatchRegexIndex(Querystring); - - int actual = contrast.Processor.DynamicParameter; + contrast.MatchRegexIndex(input); + int result = contrast.Processor.DynamicParameter; - Assert.AreEqual(Expected, actual); + Assert.AreEqual(expected, result); } /// @@ -93,52 +115,102 @@ namespace ImageProcessor.Web.UnitTests /// The filter regex unit test. /// [Test] + public void TestFilterRegex() { - // Should really write more for the other filters. - const string Querystring = "filter=lomograph"; - IMatrixFilter expected = MatrixFilters.Lomograph; + Dictionary data = new Dictionary + { + { + "filter=lomograph", MatrixFilters.Lomograph + }, + { + "filter=polaroid", MatrixFilters.Polaroid + }, + { + "filter=comic", MatrixFilters.Comic + }, + { + "filter=greyscale", MatrixFilters.GreyScale + }, + { + "filter=blackwhite", MatrixFilters.BlackWhite + }, + { + "filter=invert", MatrixFilters.Invert + }, + { + "filter=gotham", MatrixFilters.Gotham + }, + { + "filter=hisatch", MatrixFilters.HiSatch + }, + { + "filter=losatch", MatrixFilters.LoSatch + }, + { + "filter=sepia", MatrixFilters.Sepia + } + }; Processors.Filter filter = new Processors.Filter(); - filter.MatchRegexIndex(Querystring); - - IMatrixFilter actual = filter.Processor.DynamicParameter; - - Assert.AreEqual(expected, actual); + foreach (KeyValuePair item in data) + { + filter.MatchRegexIndex(item.Key); + IMatrixFilter result = filter.Processor.DynamicParameter; + Assert.AreEqual(item.Value, result); + } } /// /// The format regex unit test. /// + /// + /// The input querystring. + /// + /// + /// The expected type. + /// [Test] - public void TestFormatRegex() + [TestCase("format=bmp", typeof(BitmapFormat))] + [TestCase("format=png", typeof(PngFormat))] + [TestCase("format=png8", typeof(PngFormat))] + [TestCase("format=jpeg", typeof(JpegFormat))] + [TestCase("format=jpg", typeof(JpegFormat))] + [TestCase("format=gif", typeof(GifFormat))] + [TestCase("format=webp", typeof(WebPFormat))] + public void TestFormatRegex(string input, Type expected) { - const string Querystring = "format=gif"; - ISupportedImageFormat expected = new GifFormat(); - Processors.Format format = new Processors.Format(); - format.MatchRegexIndex(Querystring); - - ISupportedImageFormat actual = format.Processor.DynamicParameter; + format.MatchRegexIndex(input); + Type result = format.Processor.DynamicParameter.GetType(); - Assert.AreEqual(expected, actual); + Assert.AreEqual(expected, result); } /// /// The quality regex unit test. /// + /// + /// The input. + /// + /// + /// The expected result. + /// [Test] - public void TestQualityRegex() + [TestCase("quality=56", 56)] + [TestCase("quality=84", 84)] + [TestCase("quality=66", 66)] + [TestCase("quality=101", 1)] + [TestCase("quality=00001", 1)] + [TestCase("quality=-50", 50)] + [TestCase("quality=0", 0)] + public void TestQualityRegex(string input, int expected) { - const string Querystring = "quality=56"; - const int Expected = 56; - Processors.Quality quality = new Processors.Quality(); - quality.MatchRegexIndex(Querystring); - - int actual = quality.Processor.DynamicParameter; + quality.MatchRegexIndex(input); + int result = quality.Processor.DynamicParameter; - Assert.AreEqual(Expected, actual); + Assert.AreEqual(expected, result); } /// @@ -161,18 +233,25 @@ namespace ImageProcessor.Web.UnitTests /// /// The rotate regex unit test. /// + /// + /// The input string. + /// + /// + /// The expected result. + /// [Test] - public void TestRotateRegex() + [TestCase("rotate=0", 0)] + [TestCase("rotate=270", 270)] + [TestCase("rotate=-270", 0)] + [TestCase("rotate=angle-28", 28)] + public void TestRotateRegex(string input, int expected) { - const string Querystring = "rotate=270"; - const int Expected = 270; - Processors.Rotate rotate = new Processors.Rotate(); - rotate.MatchRegexIndex(Querystring); + rotate.MatchRegexIndex(input); - int actual = rotate.Processor.DynamicParameter; + int result = rotate.Processor.DynamicParameter; - Assert.AreEqual(Expected, actual); + Assert.AreEqual(expected, result); } /// @@ -181,14 +260,26 @@ namespace ImageProcessor.Web.UnitTests [Test] public void TestRoundedCornersRegex() { - const string Querystring = "roundedcorners=30"; - RoundedCornerLayer expected = new RoundedCornerLayer(30, true, true, true, true); - Processors.RoundedCorners roundedCorners = new Processors.RoundedCorners(); - roundedCorners.MatchRegexIndex(Querystring); + Dictionary data = new Dictionary + { + { + "roundedcorners=30", new RoundedCornerLayer(30, true, true, true, true) + }, + { + "roundedcorners=radius-26|tl-true|tr-false|bl-true|br-false", new RoundedCornerLayer(26, true, false, true, false) + }, + { + "roundedcorners=26,tl=true,tr=false,bl=true,br=false", new RoundedCornerLayer(26, true, false, true, false) + } + }; - RoundedCornerLayer actual = roundedCorners.Processor.DynamicParameter; - - Assert.AreEqual(expected, actual); + Processors.RoundedCorners roundedCorners = new Processors.RoundedCorners(); + foreach (KeyValuePair item in data) + { + roundedCorners.MatchRegexIndex(item.Key); + RoundedCornerLayer result = roundedCorners.Processor.DynamicParameter; + Assert.AreEqual(item.Value, result); + } } /// diff --git a/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs index 505d80d99..22c266a85 100644 --- a/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs +++ b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs @@ -37,7 +37,7 @@ namespace ImageProcessor.Web.Helpers /// /// The regular expression to search strings for values between 1 and 100. /// - private static readonly Regex In100RangeRegex = new Regex(@"(-?(?:100)|-?([1-9]?[0-9]))", RegexOptions.Compiled); + private static readonly Regex In100RangeRegex = new Regex(@"(-?(0*(?:[1-9][0-9]?|100)))", RegexOptions.Compiled); /// /// The sharpen regex. diff --git a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs index 59f975fb3..4cffe51eb 100644 --- a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs +++ b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs @@ -73,13 +73,6 @@ namespace ImageProcessor.Configuration try { Type type = typeof(ISupportedImageFormat); - HashSet found = new HashSet(); - - // Get any references and used assemblies. - foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) - { - this.LoadReferencedAssemblies(found, assembly); - } // Get any referenced but not used assemblies. Assembly executingAssembly = Assembly.GetExecutingAssembly(); @@ -88,6 +81,7 @@ namespace ImageProcessor.Configuration // ReSharper disable once AssignNullToNotNullAttribute FileInfo[] files = new DirectoryInfo(targetBasePath).GetFiles("*.dll", SearchOption.AllDirectories); + HashSet found = new HashSet(); foreach (FileInfo fileInfo in files) { AssemblyName assemblyName = AssemblyName.GetAssemblyName(fileInfo.FullName); From 30a7099229f954a493a892bcc9b41cc376cc9263 Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 5 Aug 2014 14:43:07 +0100 Subject: [PATCH 129/155] Moar tests plus known colours! Former-commit-id: 38f02083c8cae1bf549c0863c4842e196a0b90f5 --- .../RegularExpressionUnitTests.cs | 82 ++++++++++++++----- .../Helpers/CommonParameterParserUtility.cs | 42 +++++++++- .../NET45/Processors/Format.cs | 1 - 3 files changed, 103 insertions(+), 22 deletions(-) diff --git a/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs b/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs index 86c346e38..db81f4533 100644 --- a/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs +++ b/src/ImageProcessor.Web.UnitTests/RegularExpressionUnitTests.cs @@ -29,18 +29,25 @@ namespace ImageProcessor.Web.UnitTests /// /// The alpha regex unit test. /// + /// + /// The input string. + /// + /// + /// The expected result. + /// [Test] - public void TestAlphaRegex() + [TestCase("alpha=66", 66)] + [TestCase("alpha=-66", 66)] + [TestCase("alpha=101", 1)] + [TestCase("alpha=-101", 1)] + [TestCase("alpha=000053", 53)] + public void TestAlphaRegex(string input, int expected) { - const string Querystring = "alpha=56"; - const int Expected = 56; - Processors.Alpha alpha = new Processors.Alpha(); - alpha.MatchRegexIndex(Querystring); - - int actual = alpha.Processor.DynamicParameter; + alpha.MatchRegexIndex(input); + int result = alpha.Processor.DynamicParameter; - Assert.AreEqual(Expected, actual); + Assert.AreEqual(expected, result); } /// @@ -95,6 +102,32 @@ namespace ImageProcessor.Web.UnitTests Assert.AreEqual(expected, result); } + /// + /// The saturation regex unit test. + /// + /// + /// The input string. + /// + /// + /// The expected result. + /// + [Test] + [TestCase("saturation=56", 56)] + [TestCase("saturation=84", 84)] + [TestCase("saturation=66", 66)] + [TestCase("saturation=101", 1)] + [TestCase("saturation=00001", 1)] + [TestCase("saturation=-50", -50)] + [TestCase("saturation=0", 0)] + public void TestSaturationRegex(string input, int expected) + { + Processors.Saturation saturation = new Processors.Saturation(); + saturation.MatchRegexIndex(input); + int result = saturation.Processor.DynamicParameter; + + Assert.AreEqual(expected, result); + } + /// /// The rotate regex unit test. /// @@ -288,20 +321,29 @@ namespace ImageProcessor.Web.UnitTests [Test] public void TestTintRegex() { - const string HexQuerystring = "tint=6aa6cc"; - const string RgbaQuerystring = "tint=106,166,204,255"; - Color expectedHex = ColorTranslator.FromHtml("#" + "6aa6cc"); - Color expectedRgba = Color.FromArgb(255, 106, 166, 204); + Dictionary data = new Dictionary + { + { + "tint=6aa6cc", ColorTranslator.FromHtml("#" + "6aa6cc") + }, + { + "tint=106,166,204,255", Color.FromArgb(255, 106, 166, 204) + }, + { + "tint=fff", Color.FromArgb(255, 255, 255, 255) + }, + { + "tint=white", Color.White + } + }; Processors.Tint tint = new Processors.Tint(); - tint.MatchRegexIndex(HexQuerystring); - Color actualHex = tint.Processor.DynamicParameter; - Assert.AreEqual(expectedHex, actualHex); - - tint = new Processors.Tint(); - tint.MatchRegexIndex(RgbaQuerystring); - Color actualRgba = tint.Processor.DynamicParameter; - Assert.AreEqual(expectedRgba, actualRgba); + foreach (KeyValuePair item in data) + { + tint.MatchRegexIndex(item.Key); + Color result = tint.Processor.DynamicParameter; + Assert.AreEqual(item.Value, result); + } } } } \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs index 22c266a85..3e8362d08 100644 --- a/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs +++ b/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs @@ -11,8 +11,10 @@ namespace ImageProcessor.Web.Helpers { using System; + using System.Collections.Generic; using System.Drawing; using System.Globalization; + using System.Text; using System.Text.RegularExpressions; using ImageProcessor.Common.Extensions; @@ -24,10 +26,15 @@ namespace ImageProcessor.Web.Helpers /// public static class CommonParameterParserUtility { + /// + /// The collection of known colors. + /// + private static readonly Dictionary KnownColors = new Dictionary(); + /// /// The regular expression to search strings for colors. /// - private static readonly Regex ColorRegex = new Regex(@"(bgcolor|color|tint|vignette)(=|-)(\d+,\d+,\d+,\d+|([0-9a-fA-F]{3}){1,2})", RegexOptions.Compiled); + private static readonly Regex ColorRegex = BuildColorRegex(); /// /// The regular expression to search strings for angles. @@ -93,6 +100,11 @@ namespace ImageProcessor.Web.Helpers { string value = match.Value.Split(new[] { '=', '-' })[1]; + if (KnownColors.ContainsKey(value)) + { + return Color.FromKnownColor(KnownColors[value]); + } + if (value.Contains(",")) { int[] split = value.ToPositiveIntegerArray(); @@ -224,5 +236,33 @@ namespace ImageProcessor.Web.Helpers return 0; } + + /// + /// Builds a regular expression for the three main colour types. + /// + /// + /// The to match colors. + /// + private static Regex BuildColorRegex() + { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.Append(@"(bgcolor|color|tint|vignette)(=|-)(\d+,\d+,\d+,\d+|([0-9a-fA-F]{3}){1,2}|("); + + KnownColor[] knownColors = (KnownColor[])Enum.GetValues(typeof(KnownColor)); + + for (int i = 0; i < knownColors.Length; i++) + { + KnownColor knownColor = knownColors[i]; + string name = knownColor.ToString().ToLowerInvariant(); + + KnownColors.Add(name, knownColor); + + stringBuilder.Append(i > 0 ? "|" + name : name); + } + + stringBuilder.Append("))"); + + return new Regex(stringBuilder.ToString(), RegexOptions.IgnoreCase); + } } } diff --git a/src/ImageProcessor.Web/NET45/Processors/Format.cs b/src/ImageProcessor.Web/NET45/Processors/Format.cs index b419f211f..7b57d7ddd 100644 --- a/src/ImageProcessor.Web/NET45/Processors/Format.cs +++ b/src/ImageProcessor.Web/NET45/Processors/Format.cs @@ -15,7 +15,6 @@ namespace ImageProcessor.Web.Processors using System.Linq; using System.Text; using System.Text.RegularExpressions; - using System.Web; using ImageProcessor.Configuration; using ImageProcessor.Imaging.Formats; From 1a1b4364bcd37aa1c1322bf02d65f4387b54123c Mon Sep 17 00:00:00 2001 From: Ryan Clark Date: Sat, 9 Aug 2014 10:33:43 -0400 Subject: [PATCH 130/155] Changed maxDays default value from 356 to 365. Former-commit-id: 44e15fda4a56359a7bbf90e39af352c05bd8443d --- .../NET45/Configuration/Resources/cache.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageProcessor.Web/NET45/Configuration/Resources/cache.config b/src/ImageProcessor.Web/NET45/Configuration/Resources/cache.config index 1caab6358..c9b64a68a 100644 --- a/src/ImageProcessor.Web/NET45/Configuration/Resources/cache.config +++ b/src/ImageProcessor.Web/NET45/Configuration/Resources/cache.config @@ -1 +1 @@ - \ No newline at end of file + From d0b3f4a57d43367b57be6f12ac3f6def157b365b Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 14 Aug 2014 21:56:27 +0100 Subject: [PATCH 131/155] Move everything to NET4.5 Former-commit-id: 634684bd47347d7375415a638c2f64c81db1805b --- build/Build.ImageProcessor.Web.proj | 39 ++- build/Build.ImageProcessor.proj | 34 +-- build/Build.bat | 4 - .../NuSpecs/ImageProcessor.Web.Config.nuspec | 12 +- build/NuSpecs/ImageProcessor.Web.nuspec | 10 +- build/NuSpecs/ImageProcessor.nuspec | 7 +- .../ImageProcessor.Web.UnitTests.csproj | 7 +- .../{NET45 => }/Caching/CacheIndexer.cs | 0 .../{NET45 => }/Caching/CachedImage.cs | 0 .../{NET45 => }/Caching/DiskCache.cs | 1 - .../{NET45 => }/Caching/MemCache.cs | 0 .../Configuration/ImageCacheSection.cs | 0 .../Configuration/ImageProcessingSection.cs | 0 .../ImageProcessorConfiguration.cs | 0 .../Configuration/ImageSecuritySection.cs | 0 .../Configuration/Resources/cache.config | 0 .../Configuration/Resources/processing.config | 0 .../Configuration/Resources/security.config | 0 .../Extensions/DirectoryInfoExtensions.cs | 0 .../Extensions/StringExtensions.cs | 0 .../{NET45 => }/Helpers/AsyncDeDuperLock.cs | 3 +- .../Helpers/CommonParameterParserUtility.cs | 0 .../{NET45 => }/Helpers/ImageHelpers.cs | 0 .../{NET45 => }/Helpers/NativeMethods.cs | 0 .../{NET45 => }/Helpers/RemoteFile.cs | 0 .../{NET45 => }/Helpers/ResourceHelpers.cs | 0 .../{NET45 => }/Helpers/TaskHelpers.cs | 0 .../HttpModules/ImageProcessingModule.cs | 17 -- .../{NET45 => }/ImageFactoryExtensions.cs | 0 ...NET45.csproj => ImageProcessor.Web.csproj} | 2 +- .../NET4/ImageProcessor.Web_NET4.csproj | 226 ---------------- src/ImageProcessor.Web/NET4/app.config | 15 -- src/ImageProcessor.Web/NET4/packages.config | 6 - .../{NET45 => }/Processors/Alpha.cs | 0 .../{NET45 => }/Processors/AutoRotate.cs | 0 .../{NET45 => }/Processors/BackgroundColor.cs | 0 .../{NET45 => }/Processors/Brightness.cs | 0 .../{NET45 => }/Processors/Contrast.cs | 0 .../{NET45 => }/Processors/Crop.cs | 0 .../{NET45 => }/Processors/Filter.cs | 0 .../{NET45 => }/Processors/Flip.cs | 0 .../{NET45 => }/Processors/Format.cs | 0 .../{NET45 => }/Processors/GaussianBlur.cs | 0 .../{NET45 => }/Processors/GaussianSharpen.cs | 0 .../Processors/IWebGraphicsProcessor.cs | 0 .../{NET45 => }/Processors/Quality.cs | 0 .../{NET45 => }/Processors/Resize.cs | 0 .../{NET45 => }/Processors/Rotate.cs | 0 .../{NET45 => }/Processors/RoundedCorners.cs | 0 .../{NET45 => }/Processors/Saturation.cs | 0 .../{NET45 => }/Processors/Tint.cs | 0 .../{NET45 => }/Processors/Vignette.cs | 0 .../{NET45 => }/Processors/Watermark.cs | 0 .../{NET45 => }/Properties/AssemblyInfo.cs | 0 .../{NET45 => }/Settings.StyleCop | 0 src/ImageProcessor.sln | 52 +--- src/ImageProcessor.sln.DotSettings | 1 + .../ImageProcessorBootstrapper.cs | 2 +- src/ImageProcessor/ImageProcessor.csproj | 12 +- .../ImageProcessor.Plugins.WebP.csproj | 7 +- .../App_Start/FilterConfig.cs | 0 .../App_Start/RouteConfig.cs | 0 .../App_Start/WebApiConfig.cs | 0 .../Content/responsive.min.css.REMOVED.git-id | 0 .../Controllers/HomeController.cs | 0 .../Test_Website_NET45 => MVC}/Global.asax | 0 .../Test_Website_NET45 => MVC}/Global.asax.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../Test_Website_MVC.csproj} | 8 +- .../{NET4 => MVC}/Views/Home/Bmp.cshtml | 0 .../Views/Home/External.cshtml | 0 .../Views/Home/Gif.cshtml | 0 .../Views/Home/Index.cshtml | 0 .../Views/Home/Png.cshtml | 0 .../{NET4 => MVC}/Views/Home/Png8.cshtml | 0 .../{NET4 => MVC}/Views/Home/Tiff.cshtml | 0 .../Views/Home/WebP.cshtml | 0 .../Views/Shared/_Layout.cshtml | 0 .../Views/Web.config | 0 .../{NET4 => MVC}/Views/_ViewStart.cshtml | 0 .../Web.Debug.config | 0 .../Web.Release.config | 0 .../Test_Website_NET45 => MVC}/Web.config | 0 .../config/imageprocessor/cache.config | 0 .../config/imageprocessor/processing.config | 0 .../config/imageprocessor/security.config | 0 .../packages.config | 0 .../NET4/Controllers/HomeController.cs | 50 ---- src/TestWebsites/NET4/Global.asax | 1 - src/TestWebsites/NET4/Global.asax.cs | 40 --- .../NET4/Properties/AssemblyInfo.cs | 35 --- .../NET4/Scripts/img.srcsect.pollyfill.js | 103 -------- .../NET4/Test_Website_MVC_NET4.csproj | 246 ------------------ .../NET4/Views/Home/External.cshtml | 14 - src/TestWebsites/NET4/Views/Home/Gif.cshtml | 99 ------- src/TestWebsites/NET4/Views/Home/Index.cshtml | 191 -------------- src/TestWebsites/NET4/Views/Home/Png.cshtml | 99 ------- .../NET4/Views/Shared/_Layout.cshtml | 40 --- src/TestWebsites/NET4/Views/Web.config | 58 ----- src/TestWebsites/NET4/Web.Debug.config | 30 --- src/TestWebsites/NET4/Web.Release.config | 31 --- src/TestWebsites/NET4/Web.config | 76 ------ .../config/imageprocessor/processing.config | 45 ---- .../config/imageprocessor/security.config | 8 - src/TestWebsites/NET4/packages.config | 6 - .../Content/responsive.min.css.REMOVED.git-id | 1 - .../Test_Website_NET45/Views/Home/Bmp.cshtml | 100 ------- .../Test_Website_NET45/Views/Home/Png8.cshtml | 100 ------- .../Test_Website_NET45/Views/Home/Tiff.cshtml | 99 ------- .../Views/_ViewStart.cshtml | 3 - .../config/imageprocessor/cache.config | 3 - .../About.aspx | 0 .../About.aspx.cs | 0 .../About.aspx.designer.cs | 0 .../Account/Login.aspx | 0 .../Account/Login.aspx.cs | 0 .../Account/Login.aspx.designer.cs | 0 .../Account/Manage.aspx | 0 .../Account/Manage.aspx.cs | 0 .../Account/Manage.aspx.designer.cs | 0 .../Account/OpenAuthProviders.ascx | 0 .../Account/OpenAuthProviders.ascx.cs | 0 .../OpenAuthProviders.ascx.designer.cs | 0 .../Account/Register.aspx | 0 .../Account/Register.aspx.cs | 0 .../Account/Register.aspx.designer.cs | 0 .../Account/RegisterExternalLogin.aspx | 0 .../Account/RegisterExternalLogin.aspx.cs | 0 .../RegisterExternalLogin.aspx.designer.cs | 0 .../Account/Web.config | 0 .../App_Start/AuthConfig.cs | 0 .../App_Start/BundleConfig.cs | 0 .../App_Start/RouteConfig.cs | 0 .../Bundle.config | 0 .../Contact.aspx | 0 .../Contact.aspx.cs | 0 .../Contact.aspx.designer.cs | 0 .../Content/Site.css | 0 .../Default.aspx | 0 .../Default.aspx.cs | 0 .../Default.aspx.designer.cs | 0 .../Global.asax | 0 .../Global.asax.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../Scripts/WebForms/DetailsView.js | 0 .../Scripts/WebForms/Focus.js | 0 .../Scripts/WebForms/GridView.js | 0 .../MSAjax/MicrosoftAjax.js.REMOVED.git-id | 0 .../MicrosoftAjaxApplicationServices.js | 0 .../MSAjax/MicrosoftAjaxComponentModel.js | 0 .../WebForms/MSAjax/MicrosoftAjaxCore.js | 0 .../MSAjax/MicrosoftAjaxGlobalization.js | 0 .../WebForms/MSAjax/MicrosoftAjaxHistory.js | 0 .../WebForms/MSAjax/MicrosoftAjaxNetwork.js | 0 .../MSAjax/MicrosoftAjaxSerialization.js | 0 .../WebForms/MSAjax/MicrosoftAjaxTimer.js | 0 .../WebForms/MSAjax/MicrosoftAjaxWebForms.js | 0 .../MSAjax/MicrosoftAjaxWebServices.js | 0 .../Scripts/WebForms/Menu.js | 0 .../Scripts/WebForms/MenuStandards.js | 0 .../Scripts/WebForms/SmartNav.js | 0 .../Scripts/WebForms/TreeView.js | 0 .../Scripts/WebForms/WebForms.js | 0 .../Scripts/WebForms/WebParts.js | 0 .../Scripts/WebForms/WebUIValidation.js | 0 .../Scripts/_references.js | Bin ...query-1.8.2.intellisense.js.REMOVED.git-id | 0 .../Scripts/modernizr-2.6.2.js | 0 .../Site.Master | 0 .../Site.Master.cs | 0 .../Site.Master.designer.cs | 0 .../Site.Mobile.Master | 0 .../Site.Mobile.Master.cs | 0 .../Site.Mobile.Master.designer.cs | 0 .../Test_Website_Webforms.csproj} | 6 +- .../ViewSwitcher.ascx | 0 .../ViewSwitcher.ascx.cs | 0 .../ViewSwitcher.ascx.designer.cs | 0 .../Web.Debug.config | 0 .../Web.Release.config | 0 .../Web.config | 0 .../config/imageprocessor/cache.config | 0 .../config/imageprocessor/processing.config | 0 .../config/imageprocessor/security.config | 0 .../favicon.ico | Bin .../packages.config | 0 src/packages/repositories.config | 2 + 187 files changed, 81 insertions(+), 1870 deletions(-) rename src/ImageProcessor.Web/{NET45 => }/Caching/CacheIndexer.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Caching/CachedImage.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Caching/DiskCache.cs (99%) rename src/ImageProcessor.Web/{NET45 => }/Caching/MemCache.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Configuration/ImageCacheSection.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Configuration/ImageProcessingSection.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Configuration/ImageProcessorConfiguration.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Configuration/ImageSecuritySection.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Configuration/Resources/cache.config (100%) rename src/ImageProcessor.Web/{NET45 => }/Configuration/Resources/processing.config (100%) rename src/ImageProcessor.Web/{NET45 => }/Configuration/Resources/security.config (100%) rename src/ImageProcessor.Web/{NET45 => }/Extensions/DirectoryInfoExtensions.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Extensions/StringExtensions.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Helpers/AsyncDeDuperLock.cs (99%) rename src/ImageProcessor.Web/{NET45 => }/Helpers/CommonParameterParserUtility.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Helpers/ImageHelpers.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Helpers/NativeMethods.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Helpers/RemoteFile.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Helpers/ResourceHelpers.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Helpers/TaskHelpers.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/HttpModules/ImageProcessingModule.cs (97%) rename src/ImageProcessor.Web/{NET45 => }/ImageFactoryExtensions.cs (100%) rename src/ImageProcessor.Web/{NET45/ImageProcessor.Web_NET45.csproj => ImageProcessor.Web.csproj} (98%) delete mode 100644 src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj delete mode 100644 src/ImageProcessor.Web/NET4/app.config delete mode 100644 src/ImageProcessor.Web/NET4/packages.config rename src/ImageProcessor.Web/{NET45 => }/Processors/Alpha.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/AutoRotate.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/BackgroundColor.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Brightness.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Contrast.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Crop.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Filter.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Flip.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Format.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/GaussianBlur.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/GaussianSharpen.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/IWebGraphicsProcessor.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Quality.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Resize.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Rotate.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/RoundedCorners.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Saturation.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Tint.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Vignette.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Processors/Watermark.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Properties/AssemblyInfo.cs (100%) rename src/ImageProcessor.Web/{NET45 => }/Settings.StyleCop (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/App_Start/FilterConfig.cs (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/App_Start/RouteConfig.cs (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/App_Start/WebApiConfig.cs (100%) rename src/TestWebsites/{NET4 => MVC}/Content/responsive.min.css.REMOVED.git-id (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Controllers/HomeController.cs (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Global.asax (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Global.asax.cs (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Properties/AssemblyInfo.cs (100%) rename src/TestWebsites/{NET45/Test_Website_NET45/Test_Website_MVC_NET45.csproj => MVC/Test_Website_MVC.csproj} (97%) rename src/TestWebsites/{NET4 => MVC}/Views/Home/Bmp.cshtml (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Views/Home/External.cshtml (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Views/Home/Gif.cshtml (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Views/Home/Index.cshtml (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Views/Home/Png.cshtml (100%) rename src/TestWebsites/{NET4 => MVC}/Views/Home/Png8.cshtml (100%) rename src/TestWebsites/{NET4 => MVC}/Views/Home/Tiff.cshtml (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Views/Home/WebP.cshtml (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Views/Shared/_Layout.cshtml (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Views/Web.config (100%) rename src/TestWebsites/{NET4 => MVC}/Views/_ViewStart.cshtml (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Web.Debug.config (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Web.Release.config (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/Web.config (100%) rename src/TestWebsites/{NET4 => MVC}/config/imageprocessor/cache.config (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/config/imageprocessor/processing.config (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/config/imageprocessor/security.config (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => MVC}/packages.config (100%) delete mode 100644 src/TestWebsites/NET4/Controllers/HomeController.cs delete mode 100644 src/TestWebsites/NET4/Global.asax delete mode 100644 src/TestWebsites/NET4/Global.asax.cs delete mode 100644 src/TestWebsites/NET4/Properties/AssemblyInfo.cs delete mode 100644 src/TestWebsites/NET4/Scripts/img.srcsect.pollyfill.js delete mode 100644 src/TestWebsites/NET4/Test_Website_MVC_NET4.csproj delete mode 100644 src/TestWebsites/NET4/Views/Home/External.cshtml delete mode 100644 src/TestWebsites/NET4/Views/Home/Gif.cshtml delete mode 100644 src/TestWebsites/NET4/Views/Home/Index.cshtml delete mode 100644 src/TestWebsites/NET4/Views/Home/Png.cshtml delete mode 100644 src/TestWebsites/NET4/Views/Shared/_Layout.cshtml delete mode 100644 src/TestWebsites/NET4/Views/Web.config delete mode 100644 src/TestWebsites/NET4/Web.Debug.config delete mode 100644 src/TestWebsites/NET4/Web.Release.config delete mode 100644 src/TestWebsites/NET4/Web.config delete mode 100644 src/TestWebsites/NET4/config/imageprocessor/processing.config delete mode 100644 src/TestWebsites/NET4/config/imageprocessor/security.config delete mode 100644 src/TestWebsites/NET4/packages.config delete mode 100644 src/TestWebsites/NET45/Test_Website_NET45/Content/responsive.min.css.REMOVED.git-id delete mode 100644 src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Bmp.cshtml delete mode 100644 src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Png8.cshtml delete mode 100644 src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Tiff.cshtml delete mode 100644 src/TestWebsites/NET45/Test_Website_NET45/Views/_ViewStart.cshtml delete mode 100644 src/TestWebsites/NET45/Test_Website_Webforms_NET45/config/imageprocessor/cache.config rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/About.aspx (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/About.aspx.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/About.aspx.designer.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/Login.aspx (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/Login.aspx.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/Login.aspx.designer.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/Manage.aspx (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/Manage.aspx.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/Manage.aspx.designer.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/OpenAuthProviders.ascx (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/OpenAuthProviders.ascx.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/OpenAuthProviders.ascx.designer.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/Register.aspx (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/Register.aspx.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/Register.aspx.designer.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/RegisterExternalLogin.aspx (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/RegisterExternalLogin.aspx.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/RegisterExternalLogin.aspx.designer.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Account/Web.config (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/App_Start/AuthConfig.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/App_Start/BundleConfig.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/App_Start/RouteConfig.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Bundle.config (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Contact.aspx (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Contact.aspx.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Contact.aspx.designer.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Content/Site.css (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Default.aspx (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Default.aspx.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Default.aspx.designer.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Global.asax (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Global.asax.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Properties/AssemblyInfo.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/DetailsView.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/Focus.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/GridView.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MSAjax/MicrosoftAjax.js.REMOVED.git-id (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MSAjax/MicrosoftAjaxApplicationServices.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MSAjax/MicrosoftAjaxComponentModel.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MSAjax/MicrosoftAjaxCore.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MSAjax/MicrosoftAjaxGlobalization.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MSAjax/MicrosoftAjaxHistory.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MSAjax/MicrosoftAjaxNetwork.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MSAjax/MicrosoftAjaxSerialization.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MSAjax/MicrosoftAjaxTimer.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MSAjax/MicrosoftAjaxWebForms.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MSAjax/MicrosoftAjaxWebServices.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/Menu.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/MenuStandards.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/SmartNav.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/TreeView.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/WebForms.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/WebParts.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/WebForms/WebUIValidation.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/_references.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/jquery-1.8.2.intellisense.js.REMOVED.git-id (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Scripts/modernizr-2.6.2.js (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Site.Master (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Site.Master.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Site.Master.designer.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Site.Mobile.Master (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Site.Mobile.Master.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Site.Mobile.Master.designer.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45/Test_Website_Webforms_NET45.csproj => WebForms/Test_Website_Webforms.csproj} (98%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/ViewSwitcher.ascx (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/ViewSwitcher.ascx.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/ViewSwitcher.ascx.designer.cs (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Web.Debug.config (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Web.Release.config (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/Web.config (100%) rename src/TestWebsites/{NET45/Test_Website_NET45 => WebForms}/config/imageprocessor/cache.config (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/config/imageprocessor/processing.config (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/config/imageprocessor/security.config (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/favicon.ico (100%) rename src/TestWebsites/{NET45/Test_Website_Webforms_NET45 => WebForms}/packages.config (100%) diff --git a/build/Build.ImageProcessor.Web.proj b/build/Build.ImageProcessor.Web.proj index ab35a64e4..ae6936faf 100644 --- a/build/Build.ImageProcessor.Web.proj +++ b/build/Build.ImageProcessor.Web.proj @@ -2,15 +2,15 @@ .\ - - - - - + Release _BuildOutput\ @@ -19,42 +19,39 @@ $(MSBuildProjectDirectory)\$(BuildFolder) $(BuildFolder)bin\ $(BuildFolderRelativeToProjects)bin\ - $(BuildFolderAbsolutePath)ImageProcessor.Web\lib\net40 - $(BuildFolderAbsolutePath)ImageProcessor.Web\lib\net45 + $(BuildFolderAbsolutePath)ImageProcessor.Web\lib\net45 ..\src\ImageProcessor.Web\ - - + - - - - + + - + - - - + + + - + - \ No newline at end of file + diff --git a/build/Build.ImageProcessor.proj b/build/Build.ImageProcessor.proj index 930275286..134c1ed9f 100644 --- a/build/Build.ImageProcessor.proj +++ b/build/Build.ImageProcessor.proj @@ -2,53 +2,53 @@ .\ - - - - - + Release _BuildOutput\ False $(MSBuildProjectDirectory)\$(BuildFolder) - $(BuildFolderAbsolutePath)ImageProcessor\lib\ + $(BuildFolderAbsolutePath)ImageProcessor\lib\net45 ..\src\ImageProcessor\ - - + - + - + - + - - + + - + - \ No newline at end of file + diff --git a/build/Build.bat b/build/Build.bat index 21c4eb0a4..a1c73ad56 100644 --- a/build/Build.bat +++ b/build/Build.bat @@ -6,10 +6,6 @@ SET webconfigversion=2.0.0.0 ECHO Building ImageProcessor %version%, ImageProcess.Web %webversion% and ImageProcess.Web.Config %webconfigversion% -ECHO Installing the Microsoft.Bcl.Build package before anything else, otherwise you'd have to run build.cmd twice -SET nuGetFolder=%CD%\..\src\packages\ -..\src\.nuget\NuGet.exe install ..\src\ImageProcessor.Web\NET4\packages.config -OutputDirectory %nuGetFolder% - ECHO Removing _BuildOutput directory so everything is nice and clean RD _BuildOutput /q /s diff --git a/build/NuSpecs/ImageProcessor.Web.Config.nuspec b/build/NuSpecs/ImageProcessor.Web.Config.nuspec index f2c7f8412..f2fb1aeb8 100644 --- a/build/NuSpecs/ImageProcessor.Web.Config.nuspec +++ b/build/NuSpecs/ImageProcessor.Web.Config.nuspec @@ -20,10 +20,6 @@ Feedback is always welcome en-GB Image Imaging ASP Performance Processing HttpModule Cache Resize Rotate RoundedCorners Flip Crop Filter Effects Quality Watermark Alpha Vignette Saturation Brightness Contrast Gif Jpg Jpeg Bitmap Png WebP Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated - - - - @@ -31,9 +27,9 @@ Feedback is always welcome - - - + + + - \ No newline at end of file + diff --git a/build/NuSpecs/ImageProcessor.Web.nuspec b/build/NuSpecs/ImageProcessor.Web.nuspec index f9421c49f..7ce0d9848 100644 --- a/build/NuSpecs/ImageProcessor.Web.nuspec +++ b/build/NuSpecs/ImageProcessor.Web.nuspec @@ -13,8 +13,6 @@ Methods include: Resize, Rotate, Rounded Corners, Flip, Crop, Watermark, Filter, Saturation, Brightness, Contrast, Quality, Format, Vignette, Gaussian Blur, Gaussian Sharpen, and Transparency. -This package also requires Microsoft.Bcl.Async on .NET 4.0 which will be added on install if applicable. - If you use ImageProcessor please get in touch via my twitter @james_m_south Feedback is always welcome @@ -24,11 +22,6 @@ Feedback is always welcome en-GB Image Imaging ASP Performance Processing HttpModule Cache Resize AutoRotate Rotate RoundedCorners Flip Crop Filter Effects Quality Watermark Alpha Vignette Saturation Brightness Contrast Gif Jpg Jpeg Bitmap Png WebP Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF - - - - - @@ -36,7 +29,6 @@ Feedback is always welcome - - \ No newline at end of file + diff --git a/build/NuSpecs/ImageProcessor.nuspec b/build/NuSpecs/ImageProcessor.nuspec index 8fd164479..2b9c8af53 100644 --- a/build/NuSpecs/ImageProcessor.nuspec +++ b/build/NuSpecs/ImageProcessor.nuspec @@ -9,13 +9,12 @@ http://imageprocessor.org http://raw.githubusercontent.com/JimBobSquarePants/ImageProcessor/master/build/content/imageprocessor.128.png false - Image Processor is an easy to use and extend processing library written in C#. Its fluent API makes common imaging tasks very simple to perform. + Image Processor is an easy to use and extend processing library written in C#. Its fluent API makes common imaging tasks very simple to perform. Methods include; Resize, Rotate, Rounded Corners, Flip, Crop, Watermark, Filter, Saturation, Brightness, Contrast, Quality, Format, Vignette, Gaussian Blur, Gaussian Sharpen, and Transparency. If you use ImageProcessor please get in touch on my twitter @james_m_south. - Feedback is always welcome. A library for manipulating image files written in C#. @@ -24,6 +23,6 @@ Feedback is always welcome. Image Imaging ASP Performance Processing Resize AutoRotate Rotate RoundedCorners Flip Crop Filter Effects Quality Watermark Alpha Vignette Saturation Brightness Contrast Gif Jpg Jpeg Bitmap Png WebP Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF - + - \ No newline at end of file + diff --git a/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj b/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj index 357f3b11d..d89506079 100644 --- a/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj +++ b/src/ImageProcessor.Web.UnitTests/ImageProcessor.Web.UnitTests.csproj @@ -8,7 +8,7 @@ Properties ImageProcessor.Web.UnitTests ImageProcessor.Web.UnitTests - v4.5.1 + v4.5 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10.0 @@ -18,6 +18,7 @@ UnitTest ..\ true + true @@ -61,9 +62,9 @@ - + {d011a778-59c8-4bfa-a770-c350216bf161} - ImageProcessor.Web_NET45 + ImageProcessor.Web {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} diff --git a/src/ImageProcessor.Web/NET45/Caching/CacheIndexer.cs b/src/ImageProcessor.Web/Caching/CacheIndexer.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Caching/CacheIndexer.cs rename to src/ImageProcessor.Web/Caching/CacheIndexer.cs diff --git a/src/ImageProcessor.Web/NET45/Caching/CachedImage.cs b/src/ImageProcessor.Web/Caching/CachedImage.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Caching/CachedImage.cs rename to src/ImageProcessor.Web/Caching/CachedImage.cs diff --git a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs b/src/ImageProcessor.Web/Caching/DiskCache.cs similarity index 99% rename from src/ImageProcessor.Web/NET45/Caching/DiskCache.cs rename to src/ImageProcessor.Web/Caching/DiskCache.cs index c6300c64d..21fdc974a 100644 --- a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs +++ b/src/ImageProcessor.Web/Caching/DiskCache.cs @@ -17,7 +17,6 @@ namespace ImageProcessor.Web.Caching using System.IO; using System.Linq; using System.Threading.Tasks; - using System.Web; using System.Web.Hosting; using ImageProcessor.Web.Configuration; diff --git a/src/ImageProcessor.Web/NET45/Caching/MemCache.cs b/src/ImageProcessor.Web/Caching/MemCache.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Caching/MemCache.cs rename to src/ImageProcessor.Web/Caching/MemCache.cs diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs b/src/ImageProcessor.Web/Configuration/ImageCacheSection.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs rename to src/ImageProcessor.Web/Configuration/ImageCacheSection.cs diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs b/src/ImageProcessor.Web/Configuration/ImageProcessingSection.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Configuration/ImageProcessingSection.cs rename to src/ImageProcessor.Web/Configuration/ImageProcessingSection.cs diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs b/src/ImageProcessor.Web/Configuration/ImageProcessorConfiguration.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Configuration/ImageProcessorConfiguration.cs rename to src/ImageProcessor.Web/Configuration/ImageProcessorConfiguration.cs diff --git a/src/ImageProcessor.Web/NET45/Configuration/ImageSecuritySection.cs b/src/ImageProcessor.Web/Configuration/ImageSecuritySection.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Configuration/ImageSecuritySection.cs rename to src/ImageProcessor.Web/Configuration/ImageSecuritySection.cs diff --git a/src/ImageProcessor.Web/NET45/Configuration/Resources/cache.config b/src/ImageProcessor.Web/Configuration/Resources/cache.config similarity index 100% rename from src/ImageProcessor.Web/NET45/Configuration/Resources/cache.config rename to src/ImageProcessor.Web/Configuration/Resources/cache.config diff --git a/src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config b/src/ImageProcessor.Web/Configuration/Resources/processing.config similarity index 100% rename from src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config rename to src/ImageProcessor.Web/Configuration/Resources/processing.config diff --git a/src/ImageProcessor.Web/NET45/Configuration/Resources/security.config b/src/ImageProcessor.Web/Configuration/Resources/security.config similarity index 100% rename from src/ImageProcessor.Web/NET45/Configuration/Resources/security.config rename to src/ImageProcessor.Web/Configuration/Resources/security.config diff --git a/src/ImageProcessor.Web/NET45/Extensions/DirectoryInfoExtensions.cs b/src/ImageProcessor.Web/Extensions/DirectoryInfoExtensions.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Extensions/DirectoryInfoExtensions.cs rename to src/ImageProcessor.Web/Extensions/DirectoryInfoExtensions.cs diff --git a/src/ImageProcessor.Web/NET45/Extensions/StringExtensions.cs b/src/ImageProcessor.Web/Extensions/StringExtensions.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Extensions/StringExtensions.cs rename to src/ImageProcessor.Web/Extensions/StringExtensions.cs diff --git a/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs b/src/ImageProcessor.Web/Helpers/AsyncDeDuperLock.cs similarity index 99% rename from src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs rename to src/ImageProcessor.Web/Helpers/AsyncDeDuperLock.cs index c6896c3a0..f436b5442 100644 --- a/src/ImageProcessor.Web/NET45/Helpers/AsyncDeDuperLock.cs +++ b/src/ImageProcessor.Web/Helpers/AsyncDeDuperLock.cs @@ -54,7 +54,6 @@ namespace ImageProcessor.Web.Helpers return releaser; } -#if NET45 && !__MonoCS__ /// /// The lock async. /// @@ -92,7 +91,7 @@ namespace ImageProcessor.Web.Helpers TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); } -#endif + /// /// The disposable scope. /// diff --git a/src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs b/src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs rename to src/ImageProcessor.Web/Helpers/CommonParameterParserUtility.cs diff --git a/src/ImageProcessor.Web/NET45/Helpers/ImageHelpers.cs b/src/ImageProcessor.Web/Helpers/ImageHelpers.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Helpers/ImageHelpers.cs rename to src/ImageProcessor.Web/Helpers/ImageHelpers.cs diff --git a/src/ImageProcessor.Web/NET45/Helpers/NativeMethods.cs b/src/ImageProcessor.Web/Helpers/NativeMethods.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Helpers/NativeMethods.cs rename to src/ImageProcessor.Web/Helpers/NativeMethods.cs diff --git a/src/ImageProcessor.Web/NET45/Helpers/RemoteFile.cs b/src/ImageProcessor.Web/Helpers/RemoteFile.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Helpers/RemoteFile.cs rename to src/ImageProcessor.Web/Helpers/RemoteFile.cs diff --git a/src/ImageProcessor.Web/NET45/Helpers/ResourceHelpers.cs b/src/ImageProcessor.Web/Helpers/ResourceHelpers.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Helpers/ResourceHelpers.cs rename to src/ImageProcessor.Web/Helpers/ResourceHelpers.cs diff --git a/src/ImageProcessor.Web/NET45/Helpers/TaskHelpers.cs b/src/ImageProcessor.Web/Helpers/TaskHelpers.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Helpers/TaskHelpers.cs rename to src/ImageProcessor.Web/Helpers/TaskHelpers.cs diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/HttpModules/ImageProcessingModule.cs similarity index 97% rename from src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs rename to src/ImageProcessor.Web/HttpModules/ImageProcessingModule.cs index d7b15e7e1..82f82d012 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/HttpModules/ImageProcessingModule.cs @@ -175,8 +175,6 @@ namespace ImageProcessor.Web.HttpModules } #endregion -#if NET45 && !__MonoCS__ - /// /// Occurs when the user for the current request has been authorized. /// @@ -195,21 +193,6 @@ namespace ImageProcessor.Web.HttpModules return this.ProcessImageAsync(context); } -#else - - /// - /// Occurs when the user for the current request has been authorized. - /// - /// The source of the event. - /// An EventArgs that contains the event data. - private async void PostAuthorizeRequest(object sender, EventArgs e) - { - HttpContext context = ((HttpApplication)sender).Context; - await this.ProcessImageAsync(context); - } - -#endif - /// /// Occurs just before ASP.NET send HttpHeaders to the client. /// diff --git a/src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs b/src/ImageProcessor.Web/ImageFactoryExtensions.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/ImageFactoryExtensions.cs rename to src/ImageProcessor.Web/ImageFactoryExtensions.cs diff --git a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj b/src/ImageProcessor.Web/ImageProcessor.Web.csproj similarity index 98% rename from src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj rename to src/ImageProcessor.Web/ImageProcessor.Web.csproj index 6d4694400..7b6612b12 100644 --- a/src/ImageProcessor.Web/NET45/ImageProcessor.Web_NET45.csproj +++ b/src/ImageProcessor.Web/ImageProcessor.Web.csproj @@ -87,7 +87,7 @@ - + {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} ImageProcessor diff --git a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj deleted file mode 100644 index 601953a5e..000000000 --- a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj +++ /dev/null @@ -1,226 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43} - Library - Properties - ImageProcessor.Web - ImageProcessor.Web - v4.0 - 512 - ..\..\ - true - - - true - full - false - bin\Debug\ - TRACE;DEBUG;USE_CSHARP_SQLITE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE;USE_CSHARP_SQLITE - prompt - 4 - - - true - bin\All\ - TRACE;DEBUG;USE_CSHARP_SQLITE - full - AnyCPU - prompt - - - - - False - ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll - - - False - ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll - - - False - ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll - - - - - - - ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.IO.dll - True - - - - ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Runtime.dll - - - - ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Threading.Tasks.dll - - - - - - - - - CacheIndexer.cs - - - - MemCache.cs - - - ImageCacheSection.cs - - - ImageProcessingSection.cs - - - ImageProcessorConfiguration.cs - - - ImageSecuritySection.cs - - - DirectoryInfoExtensions.cs - - - StringExtensions.cs - - - AsyncDeDuperLock.cs - - - CommonParameterParserUtility.cs - - - ImageHelpers.cs - - - NativeMethods.cs - - - - ResourceHelpers.cs - - - - - - Alpha.cs - - - AutoRotate.cs - - - BackgroundColor.cs - - - Brightness.cs - - - Contrast.cs - - - Crop.cs - - - Filter.cs - - - Flip.cs - - - Format.cs - - - GaussianBlur.cs - - - GaussianSharpen.cs - - - IWebGraphicsProcessor.cs - - - Quality.cs - - - Resize.cs - - - Rotate.cs - - - RoundedCorners.cs - - - Saturation.cs - - - Tint.cs - - - Vignette.cs - - - Watermark.cs - - - - - - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} - ImageProcessor - - - - - Configuration\Resources\cache.config - - - Configuration\Resources\processing.config - - - Configuration\Resources\security.config - - - Designer - - - Designer - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET4/app.config b/src/ImageProcessor.Web/NET4/app.config deleted file mode 100644 index 31d365ae5..000000000 --- a/src/ImageProcessor.Web/NET4/app.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET4/packages.config b/src/ImageProcessor.Web/NET4/packages.config deleted file mode 100644 index c7068f590..000000000 --- a/src/ImageProcessor.Web/NET4/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET45/Processors/Alpha.cs b/src/ImageProcessor.Web/Processors/Alpha.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Alpha.cs rename to src/ImageProcessor.Web/Processors/Alpha.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/AutoRotate.cs b/src/ImageProcessor.Web/Processors/AutoRotate.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/AutoRotate.cs rename to src/ImageProcessor.Web/Processors/AutoRotate.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs b/src/ImageProcessor.Web/Processors/BackgroundColor.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/BackgroundColor.cs rename to src/ImageProcessor.Web/Processors/BackgroundColor.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Brightness.cs b/src/ImageProcessor.Web/Processors/Brightness.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Brightness.cs rename to src/ImageProcessor.Web/Processors/Brightness.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Contrast.cs b/src/ImageProcessor.Web/Processors/Contrast.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Contrast.cs rename to src/ImageProcessor.Web/Processors/Contrast.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Crop.cs b/src/ImageProcessor.Web/Processors/Crop.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Crop.cs rename to src/ImageProcessor.Web/Processors/Crop.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Filter.cs b/src/ImageProcessor.Web/Processors/Filter.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Filter.cs rename to src/ImageProcessor.Web/Processors/Filter.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Flip.cs b/src/ImageProcessor.Web/Processors/Flip.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Flip.cs rename to src/ImageProcessor.Web/Processors/Flip.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Format.cs b/src/ImageProcessor.Web/Processors/Format.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Format.cs rename to src/ImageProcessor.Web/Processors/Format.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/GaussianBlur.cs b/src/ImageProcessor.Web/Processors/GaussianBlur.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/GaussianBlur.cs rename to src/ImageProcessor.Web/Processors/GaussianBlur.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/GaussianSharpen.cs b/src/ImageProcessor.Web/Processors/GaussianSharpen.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/GaussianSharpen.cs rename to src/ImageProcessor.Web/Processors/GaussianSharpen.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/IWebGraphicsProcessor.cs b/src/ImageProcessor.Web/Processors/IWebGraphicsProcessor.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/IWebGraphicsProcessor.cs rename to src/ImageProcessor.Web/Processors/IWebGraphicsProcessor.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Quality.cs b/src/ImageProcessor.Web/Processors/Quality.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Quality.cs rename to src/ImageProcessor.Web/Processors/Quality.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Resize.cs b/src/ImageProcessor.Web/Processors/Resize.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Resize.cs rename to src/ImageProcessor.Web/Processors/Resize.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Rotate.cs b/src/ImageProcessor.Web/Processors/Rotate.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Rotate.cs rename to src/ImageProcessor.Web/Processors/Rotate.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/RoundedCorners.cs b/src/ImageProcessor.Web/Processors/RoundedCorners.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/RoundedCorners.cs rename to src/ImageProcessor.Web/Processors/RoundedCorners.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Saturation.cs b/src/ImageProcessor.Web/Processors/Saturation.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Saturation.cs rename to src/ImageProcessor.Web/Processors/Saturation.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Tint.cs b/src/ImageProcessor.Web/Processors/Tint.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Tint.cs rename to src/ImageProcessor.Web/Processors/Tint.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Vignette.cs b/src/ImageProcessor.Web/Processors/Vignette.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Vignette.cs rename to src/ImageProcessor.Web/Processors/Vignette.cs diff --git a/src/ImageProcessor.Web/NET45/Processors/Watermark.cs b/src/ImageProcessor.Web/Processors/Watermark.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Processors/Watermark.cs rename to src/ImageProcessor.Web/Processors/Watermark.cs diff --git a/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs b/src/ImageProcessor.Web/Properties/AssemblyInfo.cs similarity index 100% rename from src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs rename to src/ImageProcessor.Web/Properties/AssemblyInfo.cs diff --git a/src/ImageProcessor.Web/NET45/Settings.StyleCop b/src/ImageProcessor.Web/Settings.StyleCop similarity index 100% rename from src/ImageProcessor.Web/NET45/Settings.StyleCop rename to src/ImageProcessor.Web/Settings.StyleCop diff --git a/src/ImageProcessor.sln b/src/ImageProcessor.sln index 8ad0ed4e9..23483c741 100644 --- a/src/ImageProcessor.sln +++ b/src/ImageProcessor.sln @@ -18,17 +18,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1E656C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor", "ImageProcessor\ImageProcessor.csproj", "{3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web.Tests", "Web.Test\Web.Tests.csproj", "{23CE0FC0-9E59-4C93-A604-A4A98A6284D1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_MVC_NET4", "TestWebsites\NET4\Test_Website_MVC_NET4.csproj", "{30327C08-7574-4D7E-AC95-6A58753C6855}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_MVC_NET45", "TestWebsites\NET45\Test_Website_NET45\Test_Website_MVC_NET45.csproj", "{F6A208E9-C18F-43E9-B051-3C6EED30FDAF}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET4", "ImageProcessor.Web\NET4\ImageProcessor.Web_NET4.csproj", "{4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web_NET45", "ImageProcessor.Web\NET45\ImageProcessor.Web_NET45.csproj", "{D011A778-59C8-4BFA-A770-C350216BF161}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web", "ImageProcessor.Web\ImageProcessor.Web.csproj", "{D011A778-59C8-4BFA-A770-C350216BF161}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_Webforms_NET45", "TestWebsites\NET45\Test_Website_Webforms_NET45\Test_Website_Webforms_NET45.csproj", "{8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Plugins.WebP", "Plugins\ImageProcessor\ImageProcessor.Plugins.WebP\ImageProcessor.Plugins.WebP.csproj", "{2CF69699-959A-44DC-A281-4E2596C25043}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessorConsole", "ImageProcessorConsole\ImageProcessorConsole.csproj", "{7BF5274B-56A7-4B62-8105-E9BDF25BAFE7}" EndProject @@ -36,8 +28,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Web.UnitTest EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.UnitTests", "ImageProcessor.UnitTests\ImageProcessor.UnitTests.csproj", "{633B1C4C-4823-47BE-9A01-A665F3118C8C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageProcessor.Plugins.WebP", "Plugins\ImageProcessor\ImageProcessor.Plugins.WebP\ImageProcessor.Plugins.WebP.csproj", "{2CF69699-959A-44DC-A281-4E2596C25043}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web.Tests", "Web.Test\Web.Tests.csproj", "{23CE0FC0-9E59-4C93-A604-A4A98A6284D1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_MVC", "TestWebsites\MVC\Test_Website_MVC.csproj", "{F6A208E9-C18F-43E9-B051-3C6EED30FDAF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_Website_Webforms", "TestWebsites\WebForms\Test_Website_Webforms.csproj", "{8DA47D8C-DB1A-4D82-843F-896AB9C3B3D2}" EndProject + Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Any CPU = All|Any CPU @@ -80,24 +77,6 @@ Global {23CE0FC0-9E59-4C93-A604-A4A98A6284D1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {23CE0FC0-9E59-4C93-A604-A4A98A6284D1}.Release|Mixed Platforms.Build.0 = Release|Any CPU {23CE0FC0-9E59-4C93-A604-A4A98A6284D1}.Release|x86.ActiveCfg = Release|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.ActiveCfg = All|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Any CPU.Build.0 = All|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.ActiveCfg = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|Mixed Platforms.Build.0 = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.ActiveCfg = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.All|x86.Build.0 = All|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Any CPU.Build.0 = Debug|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.ActiveCfg = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Debug|x86.Build.0 = Debug|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.ActiveCfg = Release|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Any CPU.Build.0 = Release|Any CPU - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|Mixed Platforms.Build.0 = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.ActiveCfg = Release|x86 - {30327C08-7574-4D7E-AC95-6A58753C6855}.Release|x86.Build.0 = Release|x86 {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Any CPU.ActiveCfg = Release|Any CPU {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Any CPU.Build.0 = Release|Any CPU {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.All|Mixed Platforms.ActiveCfg = Release|Any CPU @@ -113,21 +92,6 @@ Global {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|Mixed Platforms.Build.0 = Release|Any CPU {F6A208E9-C18F-43E9-B051-3C6EED30FDAF}.Release|x86.ActiveCfg = Release|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Any CPU.ActiveCfg = All|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Any CPU.Build.0 = All|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Mixed Platforms.ActiveCfg = All|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|Mixed Platforms.Build.0 = All|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.All|x86.ActiveCfg = All|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Debug|x86.ActiveCfg = Debug|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Any CPU.Build.0 = Release|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {4F7050F2-465F-4E10-8DB2-2FB97AC6AA43}.Release|x86.ActiveCfg = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.All|Any CPU.ActiveCfg = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.All|Any CPU.Build.0 = Release|Any CPU {D011A778-59C8-4BFA-A770-C350216BF161}.All|Mixed Platforms.ActiveCfg = Release|Any CPU diff --git a/src/ImageProcessor.sln.DotSettings b/src/ImageProcessor.sln.DotSettings index 4970d0c6c..824137ce2 100644 --- a/src/ImageProcessor.sln.DotSettings +++ b/src/ImageProcessor.sln.DotSettings @@ -11,6 +11,7 @@ JPEGDC JPEGQ LPI + MD OECF REF SRGB diff --git a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs index 4cffe51eb..e2d61b54a 100644 --- a/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs +++ b/src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs @@ -132,7 +132,7 @@ namespace ImageProcessor.Configuration // Store root assembly (level 0) directly into results list stack.Push(assembly.ToString()); - // Do a preorder, non-recursive traversal + // Do a pre-order, non-recursive traversal while (stack.Count > 0) { string info = (string)stack.Pop(); diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index ed1aa9c64..9d163d5c7 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -1,5 +1,6 @@  - + + Debug AnyCPU @@ -8,12 +9,12 @@ Properties ImageProcessor ImageProcessor - v4.0 + v4.5 512 ..\ true - Client - False + + true @@ -24,6 +25,7 @@ prompt 4 bin\Debug\ImageProcessor.XML + false pdbonly @@ -33,6 +35,7 @@ prompt 4 bin\Release\ImageProcessor.XML + false true @@ -46,6 +49,7 @@ true 4 false + false diff --git a/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/ImageProcessor.Plugins.WebP.csproj b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/ImageProcessor.Plugins.WebP.csproj index 0c8976d8f..c1721713e 100644 --- a/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/ImageProcessor.Plugins.WebP.csproj +++ b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.WebP/ImageProcessor.Plugins.WebP.csproj @@ -9,9 +9,10 @@ Properties ImageProcessor.Plugins.WebP ImageProcessor.Plugins.WebP - v4.0 + v4.5 512 - Client + + true @@ -21,6 +22,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -29,6 +31,7 @@ TRACE prompt 4 + false diff --git a/src/TestWebsites/NET45/Test_Website_NET45/App_Start/FilterConfig.cs b/src/TestWebsites/MVC/App_Start/FilterConfig.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/App_Start/FilterConfig.cs rename to src/TestWebsites/MVC/App_Start/FilterConfig.cs diff --git a/src/TestWebsites/NET45/Test_Website_NET45/App_Start/RouteConfig.cs b/src/TestWebsites/MVC/App_Start/RouteConfig.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/App_Start/RouteConfig.cs rename to src/TestWebsites/MVC/App_Start/RouteConfig.cs diff --git a/src/TestWebsites/NET45/Test_Website_NET45/App_Start/WebApiConfig.cs b/src/TestWebsites/MVC/App_Start/WebApiConfig.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/App_Start/WebApiConfig.cs rename to src/TestWebsites/MVC/App_Start/WebApiConfig.cs diff --git a/src/TestWebsites/NET4/Content/responsive.min.css.REMOVED.git-id b/src/TestWebsites/MVC/Content/responsive.min.css.REMOVED.git-id similarity index 100% rename from src/TestWebsites/NET4/Content/responsive.min.css.REMOVED.git-id rename to src/TestWebsites/MVC/Content/responsive.min.css.REMOVED.git-id diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Controllers/HomeController.cs b/src/TestWebsites/MVC/Controllers/HomeController.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Controllers/HomeController.cs rename to src/TestWebsites/MVC/Controllers/HomeController.cs diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Global.asax b/src/TestWebsites/MVC/Global.asax similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Global.asax rename to src/TestWebsites/MVC/Global.asax diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Global.asax.cs b/src/TestWebsites/MVC/Global.asax.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Global.asax.cs rename to src/TestWebsites/MVC/Global.asax.cs diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Properties/AssemblyInfo.cs b/src/TestWebsites/MVC/Properties/AssemblyInfo.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Properties/AssemblyInfo.cs rename to src/TestWebsites/MVC/Properties/AssemblyInfo.cs diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Test_Website_MVC_NET45.csproj b/src/TestWebsites/MVC/Test_Website_MVC.csproj similarity index 97% rename from src/TestWebsites/NET45/Test_Website_NET45/Test_Website_MVC_NET45.csproj rename to src/TestWebsites/MVC/Test_Website_MVC.csproj index c2118914f..9cdaaaad9 100644 --- a/src/TestWebsites/NET45/Test_Website_NET45/Test_Website_MVC_NET45.csproj +++ b/src/TestWebsites/MVC/Test_Website_MVC.csproj @@ -151,15 +151,15 @@ - + {d011a778-59c8-4bfa-a770-c350216bf161} - ImageProcessor.Web_NET45 + ImageProcessor.Web - + {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} ImageProcessor - + {2cf69699-959a-44dc-a281-4e2596c25043} ImageProcessor.Plugins.WebP diff --git a/src/TestWebsites/NET4/Views/Home/Bmp.cshtml b/src/TestWebsites/MVC/Views/Home/Bmp.cshtml similarity index 100% rename from src/TestWebsites/NET4/Views/Home/Bmp.cshtml rename to src/TestWebsites/MVC/Views/Home/Bmp.cshtml diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/External.cshtml b/src/TestWebsites/MVC/Views/Home/External.cshtml similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Views/Home/External.cshtml rename to src/TestWebsites/MVC/Views/Home/External.cshtml diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Gif.cshtml b/src/TestWebsites/MVC/Views/Home/Gif.cshtml similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Gif.cshtml rename to src/TestWebsites/MVC/Views/Home/Gif.cshtml diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Index.cshtml b/src/TestWebsites/MVC/Views/Home/Index.cshtml similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Index.cshtml rename to src/TestWebsites/MVC/Views/Home/Index.cshtml diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Png.cshtml b/src/TestWebsites/MVC/Views/Home/Png.cshtml similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Png.cshtml rename to src/TestWebsites/MVC/Views/Home/Png.cshtml diff --git a/src/TestWebsites/NET4/Views/Home/Png8.cshtml b/src/TestWebsites/MVC/Views/Home/Png8.cshtml similarity index 100% rename from src/TestWebsites/NET4/Views/Home/Png8.cshtml rename to src/TestWebsites/MVC/Views/Home/Png8.cshtml diff --git a/src/TestWebsites/NET4/Views/Home/Tiff.cshtml b/src/TestWebsites/MVC/Views/Home/Tiff.cshtml similarity index 100% rename from src/TestWebsites/NET4/Views/Home/Tiff.cshtml rename to src/TestWebsites/MVC/Views/Home/Tiff.cshtml diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/WebP.cshtml b/src/TestWebsites/MVC/Views/Home/WebP.cshtml similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Views/Home/WebP.cshtml rename to src/TestWebsites/MVC/Views/Home/WebP.cshtml diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Shared/_Layout.cshtml b/src/TestWebsites/MVC/Views/Shared/_Layout.cshtml similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Views/Shared/_Layout.cshtml rename to src/TestWebsites/MVC/Views/Shared/_Layout.cshtml diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Web.config b/src/TestWebsites/MVC/Views/Web.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Views/Web.config rename to src/TestWebsites/MVC/Views/Web.config diff --git a/src/TestWebsites/NET4/Views/_ViewStart.cshtml b/src/TestWebsites/MVC/Views/_ViewStart.cshtml similarity index 100% rename from src/TestWebsites/NET4/Views/_ViewStart.cshtml rename to src/TestWebsites/MVC/Views/_ViewStart.cshtml diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Web.Debug.config b/src/TestWebsites/MVC/Web.Debug.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Web.Debug.config rename to src/TestWebsites/MVC/Web.Debug.config diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Web.Release.config b/src/TestWebsites/MVC/Web.Release.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Web.Release.config rename to src/TestWebsites/MVC/Web.Release.config diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Web.config b/src/TestWebsites/MVC/Web.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/Web.config rename to src/TestWebsites/MVC/Web.config diff --git a/src/TestWebsites/NET4/config/imageprocessor/cache.config b/src/TestWebsites/MVC/config/imageprocessor/cache.config similarity index 100% rename from src/TestWebsites/NET4/config/imageprocessor/cache.config rename to src/TestWebsites/MVC/config/imageprocessor/cache.config diff --git a/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config b/src/TestWebsites/MVC/config/imageprocessor/processing.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config rename to src/TestWebsites/MVC/config/imageprocessor/processing.config diff --git a/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/security.config b/src/TestWebsites/MVC/config/imageprocessor/security.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/security.config rename to src/TestWebsites/MVC/config/imageprocessor/security.config diff --git a/src/TestWebsites/NET45/Test_Website_NET45/packages.config b/src/TestWebsites/MVC/packages.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/packages.config rename to src/TestWebsites/MVC/packages.config diff --git a/src/TestWebsites/NET4/Controllers/HomeController.cs b/src/TestWebsites/NET4/Controllers/HomeController.cs deleted file mode 100644 index 88b37915f..000000000 --- a/src/TestWebsites/NET4/Controllers/HomeController.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; - -namespace Test.Controllers -{ - public class HomeController : Controller - { - // - // GET: /Home/ - - public ActionResult Index() - { - return this.View(); - } - - public ActionResult Png() - { - return this.View(); - } - - public ActionResult Png8() - { - return this.View(); - } - - public ActionResult Gif() - { - return this.View(); - } - - public ActionResult Bmp() - { - return View(); - } - - public ActionResult Tiff() - { - return View(); - } - - public ActionResult External() - { - return this.View(); - } - - } -} diff --git a/src/TestWebsites/NET4/Global.asax b/src/TestWebsites/NET4/Global.asax deleted file mode 100644 index 5798265d5..000000000 --- a/src/TestWebsites/NET4/Global.asax +++ /dev/null @@ -1 +0,0 @@ -<%@ Application Codebehind="Global.asax.cs" Inherits="Test.MvcApplication" Language="C#" %> diff --git a/src/TestWebsites/NET4/Global.asax.cs b/src/TestWebsites/NET4/Global.asax.cs deleted file mode 100644 index 1d151b372..000000000 --- a/src/TestWebsites/NET4/Global.asax.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using System.Web.Routing; - -namespace Test -{ - // Note: For instructions on enabling IIS6 or IIS7 classic mode, - // visit http://go.microsoft.com/?LinkId=9394801 - - public class MvcApplication : System.Web.HttpApplication - { - public static void RegisterGlobalFilters(GlobalFilterCollection filters) - { - filters.Add(new HandleErrorAttribute()); - } - - public static void RegisterRoutes(RouteCollection routes) - { - routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); - - routes.MapRoute( - "Default", // Route name - "{controller}/{action}/{id}", // URL with parameters - new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults - ); - - } - - protected void Application_Start() - { - AreaRegistration.RegisterAllAreas(); - - RegisterGlobalFilters(GlobalFilters.Filters); - RegisterRoutes(RouteTable.Routes); - } - } -} \ No newline at end of file diff --git a/src/TestWebsites/NET4/Properties/AssemblyInfo.cs b/src/TestWebsites/NET4/Properties/AssemblyInfo.cs deleted file mode 100644 index 499251b9f..000000000 --- a/src/TestWebsites/NET4/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Test")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Test")] -[assembly: AssemblyCopyright("Copyright © 2012")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("34f4c859-67cc-40d2-97ae-27e8c7157052")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/TestWebsites/NET4/Scripts/img.srcsect.pollyfill.js b/src/TestWebsites/NET4/Scripts/img.srcsect.pollyfill.js deleted file mode 100644 index 9eaa4e2ed..000000000 --- a/src/TestWebsites/NET4/Scripts/img.srcsect.pollyfill.js +++ /dev/null @@ -1,103 +0,0 @@ -(function ($) { - // http: //www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#attr-img-srcset - - // Regexes for matching queries. - var rSrc = /[^\s]+/, - rWidth = /(\d+)w/, - rRatio = /(\d+)x/; - - // Detect retina display - // http: //www.quirksmode.org/blog/archives/2012/06/devicepixelrati.html - var pixelRatio = (window.devicePixelRatio || 1); - - // Cache the images as theres no point querying them twice. - var imageList = []; - - // http://lodash.com/docs/#debounce - var debounce = function (func, wait, immediate) { - var args, - result, - thisArg, - timeoutId; - - function delayed() { - timeoutId = null; - if (!immediate) { - func.apply(thisArg, args); - } - } - - return function () { - var isImmediate = immediate && !timeoutId; - args = arguments; - thisArg = this; - - clearTimeout(timeoutId); - timeoutId = setTimeout(delayed, wait); - - if (isImmediate) { - result = func.apply(thisArg, args); - } - return result; - }; - }; - - var getImgSrc = function (image) { - var imgSrc = null, imgWidth = 0, i, - imgSrcParts = image.attributes["srcset"].nodeValue.split(","), - len = imgSrcParts.length, - width = $(window).width(); - - for (i = 0; i < len; i += 1) { - - // This is just a rough play on the algorithm. - var newImgSrc = imgSrcParts[i].match(rSrc)[0], - newImgWidth = rWidth.test(imgSrcParts[i]) ? parseInt(imgSrcParts[i].match(rWidth)[1], 10) : 1, // Use 1 for truthy - newPixelRatio = rRatio.test(imgSrcParts[i]) ? parseInt(imgSrcParts[i].match(rRatio)[1], 10) : 1; - - if ((newImgWidth > imgWidth && width > newImgWidth && newPixelRatio === pixelRatio)) { - - imgWidth = newImgWidth || imgWidth; - imgSrc = newImgSrc; - } - } - - // Return null - return imgSrc; - }; - - $(window).resize(function () { - - $.each(imageList, function () { - var self = this, - checkImage = function () { - var src = getImgSrc(self); - - if (src) { - self.src = src; - } - - }, - lazyCheck = debounce(checkImage, 100); - - // Run debounced - lazyCheck(); - - }); - - }); - - $(window).load(function () { - $("img[srcset]").each(function () { - - var src = getImgSrc(this); - - if (src) { - this.src = src; - } - - imageList.push(this); - }); - }); - -} (jQuery)); \ No newline at end of file diff --git a/src/TestWebsites/NET4/Test_Website_MVC_NET4.csproj b/src/TestWebsites/NET4/Test_Website_MVC_NET4.csproj deleted file mode 100644 index 6158a3bce..000000000 --- a/src/TestWebsites/NET4/Test_Website_MVC_NET4.csproj +++ /dev/null @@ -1,246 +0,0 @@ - - - - - Debug - AnyCPU - - - 2.0 - {30327C08-7574-4D7E-AC95-6A58753C6855} - {E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - Properties - Test - Test - v4.0 - false - false - - - - - 4.0 - - - - - ..\..\ - true - true - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\ - TRACE - prompt - 4 - - - true - bin\ - DEBUG;TRACE - full - AnyCPU - prompt - - - - - False - ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll - - - False - ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll - - - False - ..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll - - - - ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.IO.dll - - - - ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Runtime.dll - - - ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Threading.Tasks.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - Global.asax - - - - - - - - - Designer - - - Web.config - - - Web.config - - - - - - - - - - - - {4f7050f2-465f-4e10-8db2-2fb97ac6aa43} - ImageProcessor.Web_NET4 - - - {3B5DD734-FB7A-487D-8CE6-55E7AF9AEA7E} - ImageProcessor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - true - bin\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - bin\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - - - true - bin\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - - - - False - True - 21961 - / - - - False - False - - - False - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/TestWebsites/NET4/Views/Home/External.cshtml b/src/TestWebsites/NET4/Views/Home/External.cshtml deleted file mode 100644 index 220d6a0a9..000000000 --- a/src/TestWebsites/NET4/Views/Home/External.cshtml +++ /dev/null @@ -1,14 +0,0 @@ -@{ - ViewBag.Title = "External"; -} -

    External

    -
    -
    -
    - -
    -
    - -
    -
    -
    diff --git a/src/TestWebsites/NET4/Views/Home/Gif.cshtml b/src/TestWebsites/NET4/Views/Home/Gif.cshtml deleted file mode 100644 index cb7c3ba25..000000000 --- a/src/TestWebsites/NET4/Views/Home/Gif.cshtml +++ /dev/null @@ -1,99 +0,0 @@ -@{ - ViewBag.Title = "Gif"; -} -
    -

    Gif

    -
    -
    -
    -

    Resized

    - -
    -
    -

    Cropped

    - -
    -
    -
    -
    -

    Filter

    -
    -
    -

    blackwhite

    - -
    -
    -

    comic

    - -
    -
    -
    -
    -

    lomograph

    - -
    -
    -

    greyscale

    - -
    -
    -
    -
    -

    polaroid

    - -
    -
    -

    sepia

    - -
    -
    -
    -
    -

    gotham

    - -
    -
    -

    hisatch

    - -
    -
    -
    -
    -

    losatch

    - -
    -
    -
    -
    -
    -
    -

    Watermark

    - -
    -
    -

    Format

    - -
    -
    -
    -
    -
    -
    -

    Rotate

    - -
    -
    -

    Quality

    - -
    -
    -
    -
    -
    -
    -

    Alpha

    - -
    -
    -
    -
    diff --git a/src/TestWebsites/NET4/Views/Home/Index.cshtml b/src/TestWebsites/NET4/Views/Home/Index.cshtml deleted file mode 100644 index adde1b4a6..000000000 --- a/src/TestWebsites/NET4/Views/Home/Index.cshtml +++ /dev/null @@ -1,191 +0,0 @@ -@{ - ViewBag.Title = "Home Page"; -} -
    -

    Jpg

    -
    -
    -
    -

    Resized

    - -

    Foreign language test.

    - - -
    -
    -

    Cropped

    - -
    -
    -
    -
    -
    -

    Reside Pad

    -
    - -
    -
    - -
    -
    -
    -
    -
    -

    Resize Crop

    -
    - -
    -
    - -
    -
    -
    -
    -
    -

    Resize Max

    -
    - -
    -
    - -
    -
    -
    -
    -
    -

    Resize Stretch

    -
    - -
    -
    - -
    -
    -
    -
    -

    Filter

    -
    -
    -

    blackwhite

    - -
    -
    -

    comic

    - -
    -
    -
    -
    -

    lomograph

    - -
    -
    -

    greyscale

    - -
    -
    -
    -
    -

    polaroid

    - -
    -
    -

    sepia

    - -
    -
    -
    -
    -

    gotham

    - -
    -
    -

    hisatch

    - -
    -
    -
    -
    -

    losatch

    - -
    -
    -
    -
    -
    -
    -

    Watermark

    - -
    -
    -

    Format

    - -
    -
    -
    -
    -
    -
    -

    Rotate

    - -
    -
    -

    Quality

    - -
    -
    -
    -
    -
    -
    -

    Alpha

    - -
    -
    -

    Remote

    -
    -
    -
    -
    -
    -
    -

    Flip - horizontal

    - -
    -
    -

    Flip - vertical

    - -
    -
    -
    -
    - - -
    -

    Color Profiles

    - @*
    -
    -
    -

    CMYK original jpg

    - -
    -
    -

    sRGB original jpg

    - -
    -
    -
    *@ -
    -
    -
    -

    CMYK resized jpg

    - -
    - -
    -

    sRGB resized jpg

    - -
    -
    -
    -
    diff --git a/src/TestWebsites/NET4/Views/Home/Png.cshtml b/src/TestWebsites/NET4/Views/Home/Png.cshtml deleted file mode 100644 index d01e7ae8c..000000000 --- a/src/TestWebsites/NET4/Views/Home/Png.cshtml +++ /dev/null @@ -1,99 +0,0 @@ -@{ - ViewBag.Title = "Png"; -} -
    -

    Png

    -
    -
    -
    -

    Resized

    - -
    -
    -

    Cropped

    - -
    -
    -
    -
    -

    Filter

    -
    -
    -

    blackwhite

    - -
    -
    -

    comic

    - -
    -
    -
    -
    -

    lomograph

    - -
    -
    -

    greyscale

    - -
    -
    -
    -
    -

    polaroid

    - -
    -
    -

    sepia

    - -
    -
    -
    -
    -

    gotham

    - -
    -
    -

    hisatch

    - -
    -
    -
    -
    -

    losatch

    - -
    -
    -
    -
    -
    -
    -

    Watermark

    - -
    -
    -

    Format

    - -
    -
    -
    -
    -
    -
    -

    Rotate

    - -
    -
    -

    Quality

    - -
    -
    -
    -
    -
    -
    -

    Alpha

    - -
    -
    -
    -
    diff --git a/src/TestWebsites/NET4/Views/Shared/_Layout.cshtml b/src/TestWebsites/NET4/Views/Shared/_Layout.cshtml deleted file mode 100644 index 2a812b676..000000000 --- a/src/TestWebsites/NET4/Views/Shared/_Layout.cshtml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - @ViewBag.Title - - - - -
    -
    -

    ImageProcessor NET4

    -
    - -
    - @RenderBody() -
    -
    - - diff --git a/src/TestWebsites/NET4/Views/Web.config b/src/TestWebsites/NET4/Views/Web.config deleted file mode 100644 index a4def2a3d..000000000 --- a/src/TestWebsites/NET4/Views/Web.config +++ /dev/null @@ -1,58 +0,0 @@ - - - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/TestWebsites/NET4/Web.Debug.config b/src/TestWebsites/NET4/Web.Debug.config deleted file mode 100644 index 2c6dd51a7..000000000 --- a/src/TestWebsites/NET4/Web.Debug.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/TestWebsites/NET4/Web.Release.config b/src/TestWebsites/NET4/Web.Release.config deleted file mode 100644 index 4122d79bf..000000000 --- a/src/TestWebsites/NET4/Web.Release.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/TestWebsites/NET4/Web.config b/src/TestWebsites/NET4/Web.config deleted file mode 100644 index 52384bc51..000000000 --- a/src/TestWebsites/NET4/Web.config +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/TestWebsites/NET4/config/imageprocessor/processing.config b/src/TestWebsites/NET4/config/imageprocessor/processing.config deleted file mode 100644 index 9628cf652..000000000 --- a/src/TestWebsites/NET4/config/imageprocessor/processing.config +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/TestWebsites/NET4/config/imageprocessor/security.config b/src/TestWebsites/NET4/config/imageprocessor/security.config deleted file mode 100644 index 44fbb5d64..000000000 --- a/src/TestWebsites/NET4/config/imageprocessor/security.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/TestWebsites/NET4/packages.config b/src/TestWebsites/NET4/packages.config deleted file mode 100644 index c7068f590..000000000 --- a/src/TestWebsites/NET4/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Content/responsive.min.css.REMOVED.git-id b/src/TestWebsites/NET45/Test_Website_NET45/Content/responsive.min.css.REMOVED.git-id deleted file mode 100644 index bcf841f2a..000000000 --- a/src/TestWebsites/NET45/Test_Website_NET45/Content/responsive.min.css.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -e0fbb23ec0c6b4a6980ac29f0c71b82ff900eebc \ No newline at end of file diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Bmp.cshtml b/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Bmp.cshtml deleted file mode 100644 index 26b21ad46..000000000 --- a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Bmp.cshtml +++ /dev/null @@ -1,100 +0,0 @@ -@{ - ViewBag.Title = "Bmp"; -} - -
    -

    Bmp

    -
    -
    -
    -

    Resized

    - -
    -
    -

    Cropped

    - -
    -
    -
    -
    -

    Filter

    -
    -
    -

    blackwhite

    - -
    -
    -

    comic

    - -
    -
    -
    -
    -

    lomograph

    - -
    -
    -

    greyscale

    - -
    -
    -
    -
    -

    polaroid

    - -
    -
    -

    sepia

    - -
    -
    -
    -
    -

    gotham

    - -
    -
    -

    hisatch

    - -
    -
    -
    -
    -

    losatch

    - -
    -
    -
    -
    -
    -
    -

    Watermark

    - -
    -
    -

    Format

    - -
    -
    -
    -
    -
    -
    -

    Rotate

    - -
    -
    -

    Quality

    - -
    -
    -
    -
    -
    -
    -

    Alpha

    - -
    -
    -
    -
    diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Png8.cshtml b/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Png8.cshtml deleted file mode 100644 index 8784c836f..000000000 --- a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Png8.cshtml +++ /dev/null @@ -1,100 +0,0 @@ -@{ - ViewBag.Title = "Png8"; -} - -
    -

    Png8

    -
    -
    -
    -

    Resized

    - -
    -
    -

    Cropped

    - -
    -
    -
    -
    -

    Filter

    -
    -
    -

    blackwhite

    - -
    -
    -

    comic

    - -
    -
    -
    -
    -

    lomograph

    - -
    -
    -

    greyscale

    - -
    -
    -
    -
    -

    polaroid

    - -
    -
    -

    sepia

    - -
    -
    -
    -
    -

    gotham

    - -
    -
    -

    hisatch

    - -
    -
    -
    -
    -

    losatch

    - -
    -
    -
    -
    -
    -
    -

    Watermark

    - -
    -
    -

    Format

    - -
    -
    -
    -
    -
    -
    -

    Rotate

    - -
    -
    -

    Quality

    - -
    -
    -
    -
    -
    -
    -

    Alpha

    - -
    -
    -
    -
    diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Tiff.cshtml b/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Tiff.cshtml deleted file mode 100644 index 091e068fb..000000000 --- a/src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Tiff.cshtml +++ /dev/null @@ -1,99 +0,0 @@ -@{ - ViewBag.Title = "Tiff"; -} -
    -

    Tiff

    -
    -
    -
    -

    Resized

    - -
    -
    -

    Cropped

    - -
    -
    -
    -
    -

    Filter

    -
    -
    -

    blackwhite

    - -
    -
    -

    comic

    - -
    -
    -
    -
    -

    lomograph

    - -
    -
    -

    greyscale

    - -
    -
    -
    -
    -

    polaroid

    - -
    -
    -

    sepia

    - -
    -
    -
    -
    -

    gotham

    - -
    -
    -

    hisatch

    - -
    -
    -
    -
    -

    losatch

    - -
    -
    -
    -
    -
    -
    -

    Watermark

    - -
    -
    -

    Format

    - -
    -
    -
    -
    -
    -
    -

    Rotate

    - -
    -
    -

    Quality

    - -
    -
    -
    -
    -
    -
    -

    Alpha

    - -
    -
    -
    -
    diff --git a/src/TestWebsites/NET45/Test_Website_NET45/Views/_ViewStart.cshtml b/src/TestWebsites/NET45/Test_Website_NET45/Views/_ViewStart.cshtml deleted file mode 100644 index efda124b1..000000000 --- a/src/TestWebsites/NET45/Test_Website_NET45/Views/_ViewStart.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@{ - Layout = "~/Views/Shared/_Layout.cshtml"; -} \ No newline at end of file diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/config/imageprocessor/cache.config b/src/TestWebsites/NET45/Test_Website_Webforms_NET45/config/imageprocessor/cache.config deleted file mode 100644 index e4a9c5e9a..000000000 --- a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/config/imageprocessor/cache.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/About.aspx b/src/TestWebsites/WebForms/About.aspx similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/About.aspx rename to src/TestWebsites/WebForms/About.aspx diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/About.aspx.cs b/src/TestWebsites/WebForms/About.aspx.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/About.aspx.cs rename to src/TestWebsites/WebForms/About.aspx.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/About.aspx.designer.cs b/src/TestWebsites/WebForms/About.aspx.designer.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/About.aspx.designer.cs rename to src/TestWebsites/WebForms/About.aspx.designer.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Login.aspx b/src/TestWebsites/WebForms/Account/Login.aspx similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Login.aspx rename to src/TestWebsites/WebForms/Account/Login.aspx diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Login.aspx.cs b/src/TestWebsites/WebForms/Account/Login.aspx.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Login.aspx.cs rename to src/TestWebsites/WebForms/Account/Login.aspx.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Login.aspx.designer.cs b/src/TestWebsites/WebForms/Account/Login.aspx.designer.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Login.aspx.designer.cs rename to src/TestWebsites/WebForms/Account/Login.aspx.designer.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Manage.aspx b/src/TestWebsites/WebForms/Account/Manage.aspx similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Manage.aspx rename to src/TestWebsites/WebForms/Account/Manage.aspx diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Manage.aspx.cs b/src/TestWebsites/WebForms/Account/Manage.aspx.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Manage.aspx.cs rename to src/TestWebsites/WebForms/Account/Manage.aspx.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Manage.aspx.designer.cs b/src/TestWebsites/WebForms/Account/Manage.aspx.designer.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Manage.aspx.designer.cs rename to src/TestWebsites/WebForms/Account/Manage.aspx.designer.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/OpenAuthProviders.ascx b/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/OpenAuthProviders.ascx rename to src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/OpenAuthProviders.ascx.cs b/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/OpenAuthProviders.ascx.cs rename to src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/OpenAuthProviders.ascx.designer.cs b/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.designer.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/OpenAuthProviders.ascx.designer.cs rename to src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.designer.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Register.aspx b/src/TestWebsites/WebForms/Account/Register.aspx similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Register.aspx rename to src/TestWebsites/WebForms/Account/Register.aspx diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Register.aspx.cs b/src/TestWebsites/WebForms/Account/Register.aspx.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Register.aspx.cs rename to src/TestWebsites/WebForms/Account/Register.aspx.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Register.aspx.designer.cs b/src/TestWebsites/WebForms/Account/Register.aspx.designer.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Register.aspx.designer.cs rename to src/TestWebsites/WebForms/Account/Register.aspx.designer.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/RegisterExternalLogin.aspx b/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/RegisterExternalLogin.aspx rename to src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/RegisterExternalLogin.aspx.cs b/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/RegisterExternalLogin.aspx.cs rename to src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/RegisterExternalLogin.aspx.designer.cs b/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.designer.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/RegisterExternalLogin.aspx.designer.cs rename to src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.designer.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Web.config b/src/TestWebsites/WebForms/Account/Web.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Account/Web.config rename to src/TestWebsites/WebForms/Account/Web.config diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/App_Start/AuthConfig.cs b/src/TestWebsites/WebForms/App_Start/AuthConfig.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/App_Start/AuthConfig.cs rename to src/TestWebsites/WebForms/App_Start/AuthConfig.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/App_Start/BundleConfig.cs b/src/TestWebsites/WebForms/App_Start/BundleConfig.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/App_Start/BundleConfig.cs rename to src/TestWebsites/WebForms/App_Start/BundleConfig.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/App_Start/RouteConfig.cs b/src/TestWebsites/WebForms/App_Start/RouteConfig.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/App_Start/RouteConfig.cs rename to src/TestWebsites/WebForms/App_Start/RouteConfig.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Bundle.config b/src/TestWebsites/WebForms/Bundle.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Bundle.config rename to src/TestWebsites/WebForms/Bundle.config diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Contact.aspx b/src/TestWebsites/WebForms/Contact.aspx similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Contact.aspx rename to src/TestWebsites/WebForms/Contact.aspx diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Contact.aspx.cs b/src/TestWebsites/WebForms/Contact.aspx.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Contact.aspx.cs rename to src/TestWebsites/WebForms/Contact.aspx.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Contact.aspx.designer.cs b/src/TestWebsites/WebForms/Contact.aspx.designer.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Contact.aspx.designer.cs rename to src/TestWebsites/WebForms/Contact.aspx.designer.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Content/Site.css b/src/TestWebsites/WebForms/Content/Site.css similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Content/Site.css rename to src/TestWebsites/WebForms/Content/Site.css diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Default.aspx b/src/TestWebsites/WebForms/Default.aspx similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Default.aspx rename to src/TestWebsites/WebForms/Default.aspx diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Default.aspx.cs b/src/TestWebsites/WebForms/Default.aspx.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Default.aspx.cs rename to src/TestWebsites/WebForms/Default.aspx.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Default.aspx.designer.cs b/src/TestWebsites/WebForms/Default.aspx.designer.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Default.aspx.designer.cs rename to src/TestWebsites/WebForms/Default.aspx.designer.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Global.asax b/src/TestWebsites/WebForms/Global.asax similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Global.asax rename to src/TestWebsites/WebForms/Global.asax diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Global.asax.cs b/src/TestWebsites/WebForms/Global.asax.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Global.asax.cs rename to src/TestWebsites/WebForms/Global.asax.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Properties/AssemblyInfo.cs b/src/TestWebsites/WebForms/Properties/AssemblyInfo.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Properties/AssemblyInfo.cs rename to src/TestWebsites/WebForms/Properties/AssemblyInfo.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/DetailsView.js b/src/TestWebsites/WebForms/Scripts/WebForms/DetailsView.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/DetailsView.js rename to src/TestWebsites/WebForms/Scripts/WebForms/DetailsView.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/Focus.js b/src/TestWebsites/WebForms/Scripts/WebForms/Focus.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/Focus.js rename to src/TestWebsites/WebForms/Scripts/WebForms/Focus.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/GridView.js b/src/TestWebsites/WebForms/Scripts/WebForms/GridView.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/GridView.js rename to src/TestWebsites/WebForms/Scripts/WebForms/GridView.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjax.js.REMOVED.git-id b/src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjax.js.REMOVED.git-id similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjax.js.REMOVED.git-id rename to src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjax.js.REMOVED.git-id diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxApplicationServices.js b/src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxApplicationServices.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxApplicationServices.js rename to src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxApplicationServices.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxComponentModel.js b/src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxComponentModel.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxComponentModel.js rename to src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxComponentModel.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxCore.js b/src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxCore.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxCore.js rename to src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxCore.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxGlobalization.js b/src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxGlobalization.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxGlobalization.js rename to src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxGlobalization.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxHistory.js b/src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxHistory.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxHistory.js rename to src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxHistory.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxNetwork.js b/src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxNetwork.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxNetwork.js rename to src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxNetwork.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxSerialization.js b/src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxSerialization.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxSerialization.js rename to src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxSerialization.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxTimer.js b/src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxTimer.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxTimer.js rename to src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxTimer.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxWebForms.js b/src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxWebForms.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxWebForms.js rename to src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxWebForms.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxWebServices.js b/src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxWebServices.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MSAjax/MicrosoftAjaxWebServices.js rename to src/TestWebsites/WebForms/Scripts/WebForms/MSAjax/MicrosoftAjaxWebServices.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/Menu.js b/src/TestWebsites/WebForms/Scripts/WebForms/Menu.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/Menu.js rename to src/TestWebsites/WebForms/Scripts/WebForms/Menu.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MenuStandards.js b/src/TestWebsites/WebForms/Scripts/WebForms/MenuStandards.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/MenuStandards.js rename to src/TestWebsites/WebForms/Scripts/WebForms/MenuStandards.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/SmartNav.js b/src/TestWebsites/WebForms/Scripts/WebForms/SmartNav.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/SmartNav.js rename to src/TestWebsites/WebForms/Scripts/WebForms/SmartNav.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/TreeView.js b/src/TestWebsites/WebForms/Scripts/WebForms/TreeView.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/TreeView.js rename to src/TestWebsites/WebForms/Scripts/WebForms/TreeView.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/WebForms.js b/src/TestWebsites/WebForms/Scripts/WebForms/WebForms.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/WebForms.js rename to src/TestWebsites/WebForms/Scripts/WebForms/WebForms.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/WebParts.js b/src/TestWebsites/WebForms/Scripts/WebForms/WebParts.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/WebParts.js rename to src/TestWebsites/WebForms/Scripts/WebForms/WebParts.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/WebUIValidation.js b/src/TestWebsites/WebForms/Scripts/WebForms/WebUIValidation.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/WebForms/WebUIValidation.js rename to src/TestWebsites/WebForms/Scripts/WebForms/WebUIValidation.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/_references.js b/src/TestWebsites/WebForms/Scripts/_references.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/_references.js rename to src/TestWebsites/WebForms/Scripts/_references.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/jquery-1.8.2.intellisense.js.REMOVED.git-id b/src/TestWebsites/WebForms/Scripts/jquery-1.8.2.intellisense.js.REMOVED.git-id similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/jquery-1.8.2.intellisense.js.REMOVED.git-id rename to src/TestWebsites/WebForms/Scripts/jquery-1.8.2.intellisense.js.REMOVED.git-id diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/modernizr-2.6.2.js b/src/TestWebsites/WebForms/Scripts/modernizr-2.6.2.js similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Scripts/modernizr-2.6.2.js rename to src/TestWebsites/WebForms/Scripts/modernizr-2.6.2.js diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Master b/src/TestWebsites/WebForms/Site.Master similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Master rename to src/TestWebsites/WebForms/Site.Master diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Master.cs b/src/TestWebsites/WebForms/Site.Master.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Master.cs rename to src/TestWebsites/WebForms/Site.Master.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Master.designer.cs b/src/TestWebsites/WebForms/Site.Master.designer.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Master.designer.cs rename to src/TestWebsites/WebForms/Site.Master.designer.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Mobile.Master b/src/TestWebsites/WebForms/Site.Mobile.Master similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Mobile.Master rename to src/TestWebsites/WebForms/Site.Mobile.Master diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Mobile.Master.cs b/src/TestWebsites/WebForms/Site.Mobile.Master.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Mobile.Master.cs rename to src/TestWebsites/WebForms/Site.Mobile.Master.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Mobile.Master.designer.cs b/src/TestWebsites/WebForms/Site.Mobile.Master.designer.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Site.Mobile.Master.designer.cs rename to src/TestWebsites/WebForms/Site.Mobile.Master.designer.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Test_Website_Webforms_NET45.csproj b/src/TestWebsites/WebForms/Test_Website_Webforms.csproj similarity index 98% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Test_Website_Webforms_NET45.csproj rename to src/TestWebsites/WebForms/Test_Website_Webforms.csproj index 424aabccd..ddb6983ea 100644 --- a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Test_Website_Webforms_NET45.csproj +++ b/src/TestWebsites/WebForms/Test_Website_Webforms.csproj @@ -271,11 +271,11 @@ - + {d011a778-59c8-4bfa-a770-c350216bf161} - ImageProcessor.Web_NET45 + ImageProcessor.Web - + {3b5dd734-fb7a-487d-8ce6-55e7af9aea7e} ImageProcessor diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/ViewSwitcher.ascx b/src/TestWebsites/WebForms/ViewSwitcher.ascx similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/ViewSwitcher.ascx rename to src/TestWebsites/WebForms/ViewSwitcher.ascx diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/ViewSwitcher.ascx.cs b/src/TestWebsites/WebForms/ViewSwitcher.ascx.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/ViewSwitcher.ascx.cs rename to src/TestWebsites/WebForms/ViewSwitcher.ascx.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/ViewSwitcher.ascx.designer.cs b/src/TestWebsites/WebForms/ViewSwitcher.ascx.designer.cs similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/ViewSwitcher.ascx.designer.cs rename to src/TestWebsites/WebForms/ViewSwitcher.ascx.designer.cs diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Web.Debug.config b/src/TestWebsites/WebForms/Web.Debug.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Web.Debug.config rename to src/TestWebsites/WebForms/Web.Debug.config diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Web.Release.config b/src/TestWebsites/WebForms/Web.Release.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Web.Release.config rename to src/TestWebsites/WebForms/Web.Release.config diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/Web.config b/src/TestWebsites/WebForms/Web.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/Web.config rename to src/TestWebsites/WebForms/Web.config diff --git a/src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/cache.config b/src/TestWebsites/WebForms/config/imageprocessor/cache.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/cache.config rename to src/TestWebsites/WebForms/config/imageprocessor/cache.config diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/config/imageprocessor/processing.config b/src/TestWebsites/WebForms/config/imageprocessor/processing.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/config/imageprocessor/processing.config rename to src/TestWebsites/WebForms/config/imageprocessor/processing.config diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/config/imageprocessor/security.config b/src/TestWebsites/WebForms/config/imageprocessor/security.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/config/imageprocessor/security.config rename to src/TestWebsites/WebForms/config/imageprocessor/security.config diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/favicon.ico b/src/TestWebsites/WebForms/favicon.ico similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/favicon.ico rename to src/TestWebsites/WebForms/favicon.ico diff --git a/src/TestWebsites/NET45/Test_Website_Webforms_NET45/packages.config b/src/TestWebsites/WebForms/packages.config similarity index 100% rename from src/TestWebsites/NET45/Test_Website_Webforms_NET45/packages.config rename to src/TestWebsites/WebForms/packages.config diff --git a/src/packages/repositories.config b/src/packages/repositories.config index 14108b962..3406fa91f 100644 --- a/src/packages/repositories.config +++ b/src/packages/repositories.config @@ -4,7 +4,9 @@ + + \ No newline at end of file From bd93c7d2996df1e62890e68fe97a9c1b4aaf3919 Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 14 Aug 2014 21:57:28 +0100 Subject: [PATCH 132/155] Adding webforms project Former-commit-id: 95ac43679849712a131a8bb7cf36e5f907ccf75d --- src/TestWebsites/WebForms/config/imageprocessor/cache.config | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/TestWebsites/WebForms/config/imageprocessor/cache.config diff --git a/src/TestWebsites/WebForms/config/imageprocessor/cache.config b/src/TestWebsites/WebForms/config/imageprocessor/cache.config new file mode 100644 index 000000000..e4a9c5e9a --- /dev/null +++ b/src/TestWebsites/WebForms/config/imageprocessor/cache.config @@ -0,0 +1,3 @@ + + + From 30eeff9001f4333bdb2eb7a9364687f667251e89 Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 14 Aug 2014 22:18:57 +0100 Subject: [PATCH 133/155] Removing auth stuff to lighten test Former-commit-id: 69ca89e8a6ba95cb47197930ec4d9aa01db9f9f5 --- src/TestWebsites/WebForms/Account/Login.aspx | 47 ------ .../WebForms/Account/Login.aspx.cs | 24 --- .../WebForms/Account/Login.aspx.designer.cs | 35 ---- src/TestWebsites/WebForms/Account/Manage.aspx | 126 --------------- .../WebForms/Account/Manage.aspx.cs | 95 ----------- .../WebForms/Account/Manage.aspx.designer.cs | 66 -------- .../WebForms/Account/OpenAuthProviders.ascx | 21 --- .../Account/OpenAuthProviders.ascx.cs | 43 ----- .../OpenAuthProviders.ascx.designer.cs | 27 ---- .../WebForms/Account/Register.aspx | 62 ------- .../WebForms/Account/Register.aspx.cs | 31 ---- .../Account/Register.aspx.designer.cs | 35 ---- .../Account/RegisterExternalLogin.aspx | 35 ---- .../Account/RegisterExternalLogin.aspx.cs | 151 ------------------ .../RegisterExternalLogin.aspx.designer.cs | 39 ----- src/TestWebsites/WebForms/Account/Web.config | 12 -- .../WebForms/App_Start/AuthConfig.cs | 31 ---- src/TestWebsites/WebForms/Global.asax.cs | 1 - .../WebForms/Test_Website_Webforms.csproj | 76 --------- src/TestWebsites/WebForms/packages.config | 8 - 20 files changed, 965 deletions(-) delete mode 100644 src/TestWebsites/WebForms/Account/Login.aspx delete mode 100644 src/TestWebsites/WebForms/Account/Login.aspx.cs delete mode 100644 src/TestWebsites/WebForms/Account/Login.aspx.designer.cs delete mode 100644 src/TestWebsites/WebForms/Account/Manage.aspx delete mode 100644 src/TestWebsites/WebForms/Account/Manage.aspx.cs delete mode 100644 src/TestWebsites/WebForms/Account/Manage.aspx.designer.cs delete mode 100644 src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx delete mode 100644 src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.cs delete mode 100644 src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.designer.cs delete mode 100644 src/TestWebsites/WebForms/Account/Register.aspx delete mode 100644 src/TestWebsites/WebForms/Account/Register.aspx.cs delete mode 100644 src/TestWebsites/WebForms/Account/Register.aspx.designer.cs delete mode 100644 src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx delete mode 100644 src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.cs delete mode 100644 src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.designer.cs delete mode 100644 src/TestWebsites/WebForms/Account/Web.config delete mode 100644 src/TestWebsites/WebForms/App_Start/AuthConfig.cs diff --git a/src/TestWebsites/WebForms/Account/Login.aspx b/src/TestWebsites/WebForms/Account/Login.aspx deleted file mode 100644 index 9a04e8149..000000000 --- a/src/TestWebsites/WebForms/Account/Login.aspx +++ /dev/null @@ -1,47 +0,0 @@ -<%@ Page Title="Log in" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Test_Website_Webforms_NET45.Account.Login" %> -<%@ Register Src="~/Account/OpenAuthProviders.ascx" TagPrefix="uc" TagName="OpenAuthProviders" %> - - -
    -

    <%: Title %>.

    -
    -
    -

    Use a local account to log in.

    - - -

    - -

    -
    - Log in Form -
      -
    1. - User name - - -
    2. -
    3. - Password - - -
    4. -
    5. - - Remember me? -
    6. -
    - -
    -
    -
    -

    - Register - if you don't have an account. -

    -
    - -
    -

    Use another service to log in.

    - -
    -
    diff --git a/src/TestWebsites/WebForms/Account/Login.aspx.cs b/src/TestWebsites/WebForms/Account/Login.aspx.cs deleted file mode 100644 index 234c882fe..000000000 --- a/src/TestWebsites/WebForms/Account/Login.aspx.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; - -namespace Test_Website_Webforms_NET45.Account -{ - public partial class Login : Page - { - protected void Page_Load(object sender, EventArgs e) - { - RegisterHyperLink.NavigateUrl = "Register"; - OpenAuthLogin.ReturnUrl = Request.QueryString["ReturnUrl"]; - - var returnUrl = HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); - if (!String.IsNullOrEmpty(returnUrl)) - { - RegisterHyperLink.NavigateUrl += "?ReturnUrl=" + returnUrl; - } - } - } -} \ No newline at end of file diff --git a/src/TestWebsites/WebForms/Account/Login.aspx.designer.cs b/src/TestWebsites/WebForms/Account/Login.aspx.designer.cs deleted file mode 100644 index b021637f7..000000000 --- a/src/TestWebsites/WebForms/Account/Login.aspx.designer.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Test_Website_Webforms_NET45.Account -{ - - - public partial class Login - { - - /// - /// RegisterHyperLink control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.HyperLink RegisterHyperLink; - - /// - /// OpenAuthLogin control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::Test_Website_Webforms_NET45.Account.OpenAuthProviders OpenAuthLogin; - } -} diff --git a/src/TestWebsites/WebForms/Account/Manage.aspx b/src/TestWebsites/WebForms/Account/Manage.aspx deleted file mode 100644 index 4675b60af..000000000 --- a/src/TestWebsites/WebForms/Account/Manage.aspx +++ /dev/null @@ -1,126 +0,0 @@ -<%@ Page Title="Manage Account" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Manage.aspx.cs" Inherits="Test_Website_Webforms_NET45.Account.Manage" %> -<%@ Register Src="~/Account/OpenAuthProviders.ascx" TagPrefix="uc" TagName="OpenAuthProviders" %> - - -
    -

    <%: Title %>.

    -
    - -
    - -

    <%: SuccessMessage %>

    -
    - -

    You're logged in as <%: User.Identity.Name %>.

    - - -

    - You do not have a local password for this site. Add a local - password so you can log in without an external login. -

    -
    - Set Password Form -
      -
    1. - Password - - - - - -
    2. -
    3. - Confirm password - - - -
    4. -
    - -
    -
    - - -

    Change password

    - - -

    - -

    -
    - Change password details -
      -
    1. - Current password - - -
    2. -
    3. - New password - - -
    4. -
    5. - Confirm new password - - - -
    6. -
    - -
    -
    -
    -
    -
    - -
    - - - - -

    Registered external logins

    - - - - - -
    ServiceUser NameLast Used 
    -
    - - - - <%#: Item.ProviderDisplayName %> - <%#: Item.ProviderUserName %> - <%#: ConvertToDisplayDateTime(Item.LastUsedUtc) %> - - - - - - -
    - -

    Add an external login

    - -
    -
    diff --git a/src/TestWebsites/WebForms/Account/Manage.aspx.cs b/src/TestWebsites/WebForms/Account/Manage.aspx.cs deleted file mode 100644 index 311c127ff..000000000 --- a/src/TestWebsites/WebForms/Account/Manage.aspx.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -using Microsoft.AspNet.Membership.OpenAuth; - -namespace Test_Website_Webforms_NET45.Account -{ - public partial class Manage : System.Web.UI.Page - { - protected string SuccessMessage - { - get; - private set; - } - - protected bool CanRemoveExternalLogins - { - get; - private set; - } - - protected void Page_Load() - { - if (!IsPostBack) - { - // Determine the sections to render - var hasLocalPassword = OpenAuth.HasLocalPassword(User.Identity.Name); - setPassword.Visible = !hasLocalPassword; - changePassword.Visible = hasLocalPassword; - - CanRemoveExternalLogins = hasLocalPassword; - - // Render success message - var message = Request.QueryString["m"]; - if (message != null) - { - // Strip the query string from action - Form.Action = ResolveUrl("~/Account/Manage"); - - SuccessMessage = - message == "ChangePwdSuccess" ? "Your password has been changed." - : message == "SetPwdSuccess" ? "Your password has been set." - : message == "RemoveLoginSuccess" ? "The external login was removed." - : String.Empty; - successMessage.Visible = !String.IsNullOrEmpty(SuccessMessage); - } - } - - } - - protected void setPassword_Click(object sender, EventArgs e) - { - if (IsValid) - { - var result = OpenAuth.AddLocalPassword(User.Identity.Name, password.Text); - if (result.IsSuccessful) - { - Response.Redirect("~/Account/Manage?m=SetPwdSuccess"); - } - else - { - - ModelState.AddModelError("NewPassword", result.ErrorMessage); - - } - } - } - - - public IEnumerable GetExternalLogins() - { - var accounts = OpenAuth.GetAccountsForUser(User.Identity.Name); - CanRemoveExternalLogins = CanRemoveExternalLogins || accounts.Count() > 1; - return accounts; - } - - public void RemoveExternalLogin(string providerName, string providerUserId) - { - var m = OpenAuth.DeleteAccount(User.Identity.Name, providerName, providerUserId) - ? "?m=RemoveLoginSuccess" - : String.Empty; - Response.Redirect("~/Account/Manage" + m); - } - - - protected static string ConvertToDisplayDateTime(DateTime? utcDateTime) - { - // You can change this method to convert the UTC date time into the desired display - // offset and format. Here we're converting it to the server timezone and formatting - // as a short date and a long time string, using the current thread culture. - return utcDateTime.HasValue ? utcDateTime.Value.ToLocalTime().ToString("G") : "[never]"; - } - } -} \ No newline at end of file diff --git a/src/TestWebsites/WebForms/Account/Manage.aspx.designer.cs b/src/TestWebsites/WebForms/Account/Manage.aspx.designer.cs deleted file mode 100644 index f746b03b4..000000000 --- a/src/TestWebsites/WebForms/Account/Manage.aspx.designer.cs +++ /dev/null @@ -1,66 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Test_Website_Webforms_NET45.Account -{ - - - public partial class Manage - { - - /// - /// successMessage control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder successMessage; - - /// - /// setPassword control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder setPassword; - - /// - /// password control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox password; - - - - /// - /// confirmPassword control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox confirmPassword; - - /// - /// changePassword control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder changePassword; - - - } -} diff --git a/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx b/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx deleted file mode 100644 index 27fe593c0..000000000 --- a/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx +++ /dev/null @@ -1,21 +0,0 @@ -<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="OpenAuthProviders.ascx.cs" Inherits="Test_Website_Webforms_NET45.Account.OpenAuthProviders" %> - -
    - Log in using another service - - - - - - - -
    -

    There are no external authentication services configured. See this article for details on setting up this ASP.NET application to support logging in via external services.

    -
    -
    -
    -
    \ No newline at end of file diff --git a/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.cs b/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.cs deleted file mode 100644 index 98ac696ba..000000000 --- a/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Web; -using Microsoft.AspNet.Membership.OpenAuth; - -namespace Test_Website_Webforms_NET45.Account -{ - public partial class OpenAuthProviders : System.Web.UI.UserControl - { - protected void Page_Load(object sender, EventArgs e) - { - - if (IsPostBack) - { - var provider = Request.Form["provider"]; - if (provider == null) - { - return; - } - - var redirectUrl = "~/Account/RegisterExternalLogin"; - if (!String.IsNullOrEmpty(ReturnUrl)) - { - var resolvedReturnUrl = ResolveUrl(ReturnUrl); - redirectUrl += "?ReturnUrl=" + HttpUtility.UrlEncode(resolvedReturnUrl); - } - - OpenAuth.RequestAuthentication(provider, redirectUrl); - } - } - - - - public string ReturnUrl { get; set; } - - - public IEnumerable GetProviderNames() - { - return OpenAuth.AuthenticationClients.GetAll(); - } - - } -} \ No newline at end of file diff --git a/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.designer.cs b/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.designer.cs deleted file mode 100644 index 4433c3d0c..000000000 --- a/src/TestWebsites/WebForms/Account/OpenAuthProviders.ascx.designer.cs +++ /dev/null @@ -1,27 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Test_Website_Webforms_NET45.Account -{ - - - public partial class OpenAuthProviders - { - - /// - /// providerDetails control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.ListView providerDetails; - - } -} diff --git a/src/TestWebsites/WebForms/Account/Register.aspx b/src/TestWebsites/WebForms/Account/Register.aspx deleted file mode 100644 index 74a7221d5..000000000 --- a/src/TestWebsites/WebForms/Account/Register.aspx +++ /dev/null @@ -1,62 +0,0 @@ -<%@ Page Title="Register" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="Test_Website_Webforms_NET45.Account.Register" %> - - -
    -

    <%: Title %>.

    -

    Use the form below to create a new account.

    -
    - - - - - - - - - -

    - Passwords are required to be a minimum of <%: Membership.MinRequiredPasswordLength %> characters in length. -

    - -

    - -

    - -
    - Registration Form -
      -
    1. - User name - - -
    2. -
    3. - Email address - - -
    4. -
    5. - Password - - -
    6. -
    7. - Confirm password - - - -
    8. -
    - -
    -
    - -
    -
    -
    -
    \ No newline at end of file diff --git a/src/TestWebsites/WebForms/Account/Register.aspx.cs b/src/TestWebsites/WebForms/Account/Register.aspx.cs deleted file mode 100644 index e36cc3174..000000000 --- a/src/TestWebsites/WebForms/Account/Register.aspx.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Security; -using System.Web.UI; -using System.Web.UI.WebControls; -using Microsoft.AspNet.Membership.OpenAuth; - -namespace Test_Website_Webforms_NET45.Account -{ - public partial class Register : Page - { - protected void Page_Load(object sender, EventArgs e) - { - RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"]; - } - - protected void RegisterUser_CreatedUser(object sender, EventArgs e) - { - FormsAuthentication.SetAuthCookie(RegisterUser.UserName, createPersistentCookie: false); - - string continueUrl = RegisterUser.ContinueDestinationPageUrl; - if (!OpenAuth.IsLocalUrl(continueUrl)) - { - continueUrl = "~/"; - } - Response.Redirect(continueUrl); - } - } -} \ No newline at end of file diff --git a/src/TestWebsites/WebForms/Account/Register.aspx.designer.cs b/src/TestWebsites/WebForms/Account/Register.aspx.designer.cs deleted file mode 100644 index af06bbb97..000000000 --- a/src/TestWebsites/WebForms/Account/Register.aspx.designer.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Test_Website_Webforms_NET45.Account -{ - - - public partial class Register - { - - /// - /// RegisterUser control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CreateUserWizard RegisterUser; - - /// - /// RegisterUserWizardStep control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.CreateUserWizardStep RegisterUserWizardStep; - } -} diff --git a/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx b/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx deleted file mode 100644 index a5914d591..000000000 --- a/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx +++ /dev/null @@ -1,35 +0,0 @@ -<%@ Page Language="C#" Title="Register an external login" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="RegisterExternalLogin.aspx.cs" Inherits="Test_Website_Webforms_NET45.Account.RegisterExternalLogin" %> - -
    -

    Register with your <%: ProviderDisplayName %> account

    -

    <%: ProviderUserName %>.

    -
    - - - - - - -
    - Association Form -

    - You've authenticated with <%: ProviderDisplayName %> as - <%: ProviderUserName %>. Please enter a user name below for the current site - and click the Log in button. -

    -
      - -
    - - -
    -
    -
    diff --git a/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.cs b/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.cs deleted file mode 100644 index 18b667b12..000000000 --- a/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.cs +++ /dev/null @@ -1,151 +0,0 @@ -using System; -using System.Web; -using System.Web.Security; -using DotNetOpenAuth.AspNet; -using Microsoft.AspNet.Membership.OpenAuth; - -namespace Test_Website_Webforms_NET45.Account -{ - public partial class RegisterExternalLogin : System.Web.UI.Page - { - protected string ProviderName - { - get { return (string)ViewState["ProviderName"] ?? String.Empty; } - private set { ViewState["ProviderName"] = value; } - } - - protected string ProviderDisplayName - { - get { return (string)ViewState["ProviderDisplayName"] ?? String.Empty; } - private set { ViewState["ProviderDisplayName"] = value; } - } - - protected string ProviderUserId - { - get { return (string)ViewState["ProviderUserId"] ?? String.Empty; } - private set { ViewState["ProviderUserId"] = value; } - } - - protected string ProviderUserName - { - get { return (string)ViewState["ProviderUserName"] ?? String.Empty; } - private set { ViewState["ProviderUserName"] = value; } - } - - protected void Page_Load() - { - if (!IsPostBack) - { - ProcessProviderResult(); - } - } - - protected void logIn_Click(object sender, EventArgs e) - { - CreateAndLoginUser(); - } - - protected void cancel_Click(object sender, EventArgs e) - { - RedirectToReturnUrl(); - } - - private void ProcessProviderResult() - { - // Process the result from an auth provider in the request - ProviderName = OpenAuth.GetProviderNameFromCurrentRequest(); - - if (String.IsNullOrEmpty(ProviderName)) - { - Response.Redirect(FormsAuthentication.LoginUrl); - } - - // Build the redirect url for OpenAuth verification - var redirectUrl = "~/Account/RegisterExternalLogin"; - var returnUrl = Request.QueryString["ReturnUrl"]; - if (!String.IsNullOrEmpty(returnUrl)) - { - redirectUrl += "?ReturnUrl=" + HttpUtility.UrlEncode(returnUrl); - } - - // Verify the OpenAuth payload - var authResult = OpenAuth.VerifyAuthentication(redirectUrl); - ProviderDisplayName = OpenAuth.GetProviderDisplayName(ProviderName); - if (!authResult.IsSuccessful) - { - Title = "External login failed"; - userNameForm.Visible = false; - - ModelState.AddModelError("Provider", String.Format("External login {0} failed.", ProviderDisplayName)); - - // To view this error, enable page tracing in web.config () and visit ~/Trace.axd - Trace.Warn("OpenAuth", String.Format("There was an error verifying authentication with {0})", ProviderDisplayName), authResult.Error); - return; - } - - // User has logged in with provider successfully - // Check if user is already registered locally - if (OpenAuth.Login(authResult.Provider, authResult.ProviderUserId, createPersistentCookie: false)) - { - RedirectToReturnUrl(); - } - - // Store the provider details in ViewState - ProviderName = authResult.Provider; - ProviderUserId = authResult.ProviderUserId; - ProviderUserName = authResult.UserName; - - // Strip the query string from action - Form.Action = ResolveUrl(redirectUrl); - - if (User.Identity.IsAuthenticated) - { - // User is already authenticated, add the external login and redirect to return url - OpenAuth.AddAccountToExistingUser(ProviderName, ProviderUserId, ProviderUserName, User.Identity.Name); - RedirectToReturnUrl(); - } - else - { - // User is new, ask for their desired membership name - userName.Text = authResult.UserName; - } - } - - private void CreateAndLoginUser() - { - if (!IsValid) - { - return; - } - - var createResult = OpenAuth.CreateUser(ProviderName, ProviderUserId, ProviderUserName, userName.Text); - if (!createResult.IsSuccessful) - { - - ModelState.AddModelError("UserName", createResult.ErrorMessage); - - } - else - { - // User created & associated OK - if (OpenAuth.Login(ProviderName, ProviderUserId, createPersistentCookie: false)) - { - RedirectToReturnUrl(); - } - } - } - - private void RedirectToReturnUrl() - { - var returnUrl = Request.QueryString["ReturnUrl"]; - if (!String.IsNullOrEmpty(returnUrl) && OpenAuth.IsLocalUrl(returnUrl)) - { - Response.Redirect(returnUrl); - } - else - { - Response.Redirect("~/"); - } - } - } -} \ No newline at end of file diff --git a/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.designer.cs b/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.designer.cs deleted file mode 100644 index d3bd505c4..000000000 --- a/src/TestWebsites/WebForms/Account/RegisterExternalLogin.aspx.designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Test_Website_Webforms_NET45.Account -{ - - - public partial class RegisterExternalLogin - { - - - - /// - /// userNameForm control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.PlaceHolder userNameForm; - - /// - /// userName control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox userName; - - - } -} diff --git a/src/TestWebsites/WebForms/Account/Web.config b/src/TestWebsites/WebForms/Account/Web.config deleted file mode 100644 index 90fe314f6..000000000 --- a/src/TestWebsites/WebForms/Account/Web.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/src/TestWebsites/WebForms/App_Start/AuthConfig.cs b/src/TestWebsites/WebForms/App_Start/AuthConfig.cs deleted file mode 100644 index 24093ce83..000000000 --- a/src/TestWebsites/WebForms/App_Start/AuthConfig.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using Microsoft.AspNet.Membership.OpenAuth; - -namespace Test_Website_Webforms_NET45 -{ - internal static class AuthConfig - { - public static void RegisterOpenAuth() - { - // See http://go.microsoft.com/fwlink/?LinkId=252803 for details on setting up this ASP.NET - // application to support logging in via external services. - - //OpenAuth.AuthenticationClients.AddTwitter( - // consumerKey: "your Twitter consumer key", - // consumerSecret: "your Twitter consumer secret"); - - //OpenAuth.AuthenticationClients.AddFacebook( - // appId: "your Facebook app id", - // appSecret: "your Facebook app secret"); - - //OpenAuth.AuthenticationClients.AddMicrosoft( - // clientId: "your Microsoft account client id", - // clientSecret: "your Microsoft account client secret"); - - //OpenAuth.AuthenticationClients.AddGoogle(); - } - } -} \ No newline at end of file diff --git a/src/TestWebsites/WebForms/Global.asax.cs b/src/TestWebsites/WebForms/Global.asax.cs index 0ce814eed..21e6fd992 100644 --- a/src/TestWebsites/WebForms/Global.asax.cs +++ b/src/TestWebsites/WebForms/Global.asax.cs @@ -15,7 +15,6 @@ namespace Test_Website_Webforms_NET45 { // Code that runs on application startup BundleConfig.RegisterBundles(BundleTable.Bundles); - AuthConfig.RegisterOpenAuth(); RouteConfig.RegisterRoutes(RouteTable.Routes); } diff --git a/src/TestWebsites/WebForms/Test_Website_Webforms.csproj b/src/TestWebsites/WebForms/Test_Website_Webforms.csproj index ddb6983ea..67fe7fb43 100644 --- a/src/TestWebsites/WebForms/Test_Website_Webforms.csproj +++ b/src/TestWebsites/WebForms/Test_Website_Webforms.csproj @@ -73,46 +73,12 @@ ..\..\..\packages\Microsoft.AspNet.ScriptManager.WebForms.4.5.6\lib\net45\Microsoft.ScriptManager.WebForms.dll - - ..\..\..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll - ..\..\..\packages\Microsoft.AspNet.Web.Optimization.1.0.0\lib\net40\System.Web.Optimization.dll ..\..\..\packages\Microsoft.AspNet.Providers.Core.1.2\lib\net40\System.Web.Providers.dll - - False - ..\..\..\packages\DotNetOpenAuth.Core.4.1.4.12333\lib\net40-full\DotNetOpenAuth.Core.dll - - - False - ..\..\..\packages\DotNetOpenAuth.OAuth.Core.4.1.4.12333\lib\net40-full\DotNetOpenAuth.OAuth.dll - - - False - ..\..\..\packages\DotNetOpenAuth.OAuth.Consumer.4.1.4.12333\lib\net40-full\DotNetOpenAuth.OAuth.Consumer.dll - - - False - ..\..\..\packages\DotNetOpenAuth.OpenId.Core.4.1.4.12333\lib\net40-full\DotNetOpenAuth.OpenId.dll - - - False - ..\..\..\packages\DotNetOpenAuth.OpenId.RelyingParty.4.1.4.12333\lib\net40-full\DotNetOpenAuth.OpenId.RelyingParty.dll - - - False - ..\..\..\packages\DotNetOpenAuth.AspNet.4.1.4.12333\lib\net40-full\DotNetOpenAuth.AspNet.dll - - - ..\..\..\packages\Microsoft.AspNet.Membership.OpenAuth.1.0.1\lib\net45\Microsoft.AspNet.Membership.OpenAuth.dll - - - True - ..\..\..\packages\Microsoft.AspNet.Web.Optimization.WebForms.1.0.0\lib\net45\Microsoft.AspNet.Web.Optimization.WebForms.dll - ..\..\..\packages\Microsoft.AspNet.FriendlyUrls.Core.1.0.0\lib\net45\Microsoft.AspNet.FriendlyUrls.dll @@ -123,11 +89,6 @@
    - - - - - @@ -179,7 +140,6 @@ - About.aspx ASPXCodeBehind @@ -187,41 +147,6 @@ About.aspx - - Login.aspx - ASPXCodeBehind - - - Login.aspx - - - Manage.aspx - ASPXCodeBehind - - - Manage.aspx - - - OpenAuthProviders.ascx - ASPXCodeBehind - - - OpenAuthProviders.ascx - - - Register.aspx - ASPXCodeBehind - - - Register.aspx - - - RegisterExternalLogin.aspx - ASPXCodeBehind - - - RegisterExternalLogin.aspx - Contact.aspx @@ -267,7 +192,6 @@ - diff --git a/src/TestWebsites/WebForms/packages.config b/src/TestWebsites/WebForms/packages.config index 319f73f4f..d689bdfcd 100644 --- a/src/TestWebsites/WebForms/packages.config +++ b/src/TestWebsites/WebForms/packages.config @@ -1,15 +1,7 @@  - - - - - - - - From 0183ccb9c56ded46c4091c97fd655e46febbd84e Mon Sep 17 00:00:00 2001 From: James South Date: Thu, 14 Aug 2014 22:32:46 +0100 Subject: [PATCH 134/155] Removing unnecessary references Former-commit-id: 95844a4fa76b2edb1d2fc15bc483ca9efaa6c1fd --- .../WebForms/App_Start/BundleConfig.cs | 36 --------------- src/TestWebsites/WebForms/Bundle.config | 20 --------- src/TestWebsites/WebForms/Global.asax.cs | 1 - src/TestWebsites/WebForms/Site.Master | 41 ----------------- .../WebForms/Test_Website_Webforms.csproj | 2 - src/TestWebsites/WebForms/Web.config | 15 ++----- .../config/imageprocessor/processing.config | 45 +++++++++---------- .../config/imageprocessor/security.config | 20 ++++++--- src/TestWebsites/WebForms/packages.config | 3 -- 9 files changed, 39 insertions(+), 144 deletions(-) delete mode 100644 src/TestWebsites/WebForms/App_Start/BundleConfig.cs delete mode 100644 src/TestWebsites/WebForms/Bundle.config diff --git a/src/TestWebsites/WebForms/App_Start/BundleConfig.cs b/src/TestWebsites/WebForms/App_Start/BundleConfig.cs deleted file mode 100644 index 6e3260970..000000000 --- a/src/TestWebsites/WebForms/App_Start/BundleConfig.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Optimization; - -namespace Test_Website_Webforms_NET45 -{ - public class BundleConfig - { - // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254726 - public static void RegisterBundles(BundleCollection bundles) - { - bundles.Add(new ScriptBundle("~/bundles/WebFormsJs").Include( - "~/Scripts/WebForms/WebForms.js", - "~/Scripts/WebForms/WebUIValidation.js", - "~/Scripts/WebForms/MenuStandards.js", - "~/Scripts/WebForms/Focus.js", - "~/Scripts/WebForms/GridView.js", - "~/Scripts/WebForms/DetailsView.js", - "~/Scripts/WebForms/TreeView.js", - "~/Scripts/WebForms/WebParts.js")); - - bundles.Add(new ScriptBundle("~/bundles/MsAjaxJs").Include( - "~/Scripts/WebForms/MsAjax/MicrosoftAjax.js", - "~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js", - "~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js", - "~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js")); - - // Use the Development version of Modernizr to develop with and learn from. Then, when you’re - // ready for production, use the build tool at http://modernizr.com to pick only the tests you need - bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( - "~/Scripts/modernizr-*")); - } - } -} \ No newline at end of file diff --git a/src/TestWebsites/WebForms/Bundle.config b/src/TestWebsites/WebForms/Bundle.config deleted file mode 100644 index 669a33e5b..000000000 --- a/src/TestWebsites/WebForms/Bundle.config +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/src/TestWebsites/WebForms/Global.asax.cs b/src/TestWebsites/WebForms/Global.asax.cs index 21e6fd992..57ad56372 100644 --- a/src/TestWebsites/WebForms/Global.asax.cs +++ b/src/TestWebsites/WebForms/Global.asax.cs @@ -14,7 +14,6 @@ namespace Test_Website_Webforms_NET45 void Application_Start(object sender, EventArgs e) { // Code that runs on application startup - BundleConfig.RegisterBundles(BundleTable.Bundles); RouteConfig.RegisterRoutes(RouteTable.Routes); } diff --git a/src/TestWebsites/WebForms/Site.Master b/src/TestWebsites/WebForms/Site.Master index ba076a8eb..4c342877f 100644 --- a/src/TestWebsites/WebForms/Site.Master +++ b/src/TestWebsites/WebForms/Site.Master @@ -5,35 +5,11 @@ <%: Page.Title %> - My ASP.NET Application - - <%: Scripts.Render("~/bundles/modernizr") %> - - -
    - - - <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=272931&clcid=0x409 --%> - <%--Framework Scripts--%> - - - - - - - - - - - - <%--Site Scripts--%> - - -
    @@ -42,23 +18,6 @@

    -
    - - - - - -

    - Hello, - ! - -

    -
    -
    -