From 8669b1645d0b05938528244eda0ab53425a147b3 Mon Sep 17 00:00:00 2001 From: James South Date: Tue, 6 May 2014 22:17:16 +0100 Subject: [PATCH] Versions, 1.9.0, 3.2.3, 1.1.0 Adding animated gif support Adding Tint Method Former-commit-id: d09479101a3f63af6310ad98059777f820f574be --- build/Build.bat | 6 +-- .../NuSpecs/ImageProcessor.Web.Config.nuspec | 12 +++++- build/NuSpecs/ImageProcessor.Web.nuspec | 4 +- build/NuSpecs/ImageProcessor.nuspec | 2 +- .../RegularExpressionUnitTests.cs | 7 ++-- .../HttpModules/ImageProcessingModule.cs | 16 ++----- .../NET45/Properties/AssemblyInfo.cs | 4 +- .../Extensions/ImageExtensions.cs | 1 + src/ImageProcessor/Imaging/CropLayer.cs | 42 +++++++++++++++++++ .../Imaging/RoundedCornerLayer.cs | 9 +--- src/ImageProcessor/Properties/AssemblyInfo.cs | 4 +- src/ImageProcessorConsole/Program.cs | 9 +--- src/Web.Test/LoadTest1.loadtest | 16 +++---- 13 files changed, 81 insertions(+), 51 deletions(-) diff --git a/build/Build.bat b/build/Build.bat index 72bed329d6..c0ff43e014 100644 --- a/build/Build.bat +++ b/build/Build.bat @@ -1,7 +1,7 @@ @ECHO OFF -SET version=1.8.8.0 -SET webversion=3.2.2.0 -SET webconfigversion=1.0.0.0 +SET version=1.9.0.0 +SET webversion=3.2.3.0 +SET webconfigversion=1.1.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 5c0d60d5e1..73ecb00fbb 100644 --- a/build/NuSpecs/ImageProcessor.Web.Config.nuspec +++ b/build/NuSpecs/ImageProcessor.Web.Config.nuspec @@ -2,7 +2,7 @@ ImageProcessor.Web.Config - 1.0.0.0 + 1.1.0.0 ImageProcessor.Web.Config James South James South @@ -19,6 +19,16 @@ Feedback is always welcome James South 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 Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated + + + + + + + + + + diff --git a/build/NuSpecs/ImageProcessor.Web.nuspec b/build/NuSpecs/ImageProcessor.Web.nuspec index 61d01bbc48..3ccb06b4f5 100644 --- a/build/NuSpecs/ImageProcessor.Web.nuspec +++ b/build/NuSpecs/ImageProcessor.Web.nuspec @@ -28,11 +28,11 @@ Feedback is always welcome - + - + diff --git a/build/NuSpecs/ImageProcessor.nuspec b/build/NuSpecs/ImageProcessor.nuspec index f05c30c217..7c5fe668d7 100644 --- a/build/NuSpecs/ImageProcessor.nuspec +++ b/build/NuSpecs/ImageProcessor.nuspec @@ -2,7 +2,7 @@ ImageProcessor - 1.8.8.0 + 1.9.0.0 ImageProcessor James South James South diff --git a/src/ImageProcessor.Tests/RegularExpressionUnitTests.cs b/src/ImageProcessor.Tests/RegularExpressionUnitTests.cs index 6c188e749a..84e1d6c5b8 100644 --- a/src/ImageProcessor.Tests/RegularExpressionUnitTests.cs +++ b/src/ImageProcessor.Tests/RegularExpressionUnitTests.cs @@ -79,14 +79,13 @@ namespace ImageProcessor.Tests [TestMethod] public void TestCropRegex() { - const string Querystring = "crop=0-0-150-300"; - Rectangle expected = new Rectangle(0, 0, 150, 300); + const string Querystring = "crop=0,0,150,300"; + CropLayer expected = new CropLayer(0, 0, 150, 300, CropMode.Pixels); Crop crop = new Crop(); crop.MatchRegexIndex(Querystring); - Rectangle actual = crop.DynamicParameter; - + CropLayer actual = crop.DynamicParameter; Assert.AreEqual(expected, actual); } diff --git a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs index 63f81a8b55..5e36ff1285 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -12,6 +12,7 @@ namespace ImageProcessor.Web.HttpModules { #region Using using System; + using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; @@ -31,9 +32,6 @@ namespace ImageProcessor.Web.HttpModules using ImageProcessor.Web.Caching; using ImageProcessor.Web.Config; using ImageProcessor.Web.Helpers; - - using Microsoft.Web.Infrastructure.DynamicModuleHelper; - #endregion /// @@ -60,7 +58,7 @@ namespace ImageProcessor.Web.HttpModules /// /// The collection of SemaphoreSlims for identifying given locking individual queries. /// - private static readonly Dictionary SemaphoreSlims = new Dictionary(); + private static readonly ConcurrentDictionary SemaphoreSlims = new ConcurrentDictionary(); /// /// The value to prefix any remote image requests with to ensure they get captured. @@ -153,14 +151,7 @@ namespace ImageProcessor.Web.HttpModules private static SemaphoreSlim GetSemaphoreSlim(string id) { id = id.ToMD5Fingerprint(); - - if (SemaphoreSlims.ContainsKey(id)) - { - return SemaphoreSlims[id]; - } - - SemaphoreSlim semaphore = new SemaphoreSlim(1, 1); - SemaphoreSlims.Add(id, semaphore); + SemaphoreSlim semaphore = SemaphoreSlims.GetOrAdd(id, new SemaphoreSlim(1, 1)); return semaphore; } @@ -180,7 +171,6 @@ namespace ImageProcessor.Web.HttpModules // Dispose of any managed resources here. foreach (KeyValuePair semaphore in SemaphoreSlims) { - semaphore.Value.Wait(); semaphore.Value.Dispose(); } diff --git a/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs b/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs index f3dee6b7af..30109a6c42 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.2.0")] -[assembly: AssemblyFileVersion("3.2.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("3.2.3.0")] +[assembly: AssemblyFileVersion("3.2.3.0")] \ No newline at end of file diff --git a/src/ImageProcessor/Extensions/ImageExtensions.cs b/src/ImageProcessor/Extensions/ImageExtensions.cs index 833fdf46e8..a4134016e8 100644 --- a/src/ImageProcessor/Extensions/ImageExtensions.cs +++ b/src/ImageProcessor/Extensions/ImageExtensions.cs @@ -42,6 +42,7 @@ namespace ImageProcessor.Extensions { Height = image.Height, Width = image.Width, + // ReSharper disable once BitwiseOperatorOnEnumWithoutFlags IsIndexed = (image.PixelFormat & PixelFormat.Indexed) != 0 }; diff --git a/src/ImageProcessor/Imaging/CropLayer.cs b/src/ImageProcessor/Imaging/CropLayer.cs index b9b163fb2c..8d10f3b407 100644 --- a/src/ImageProcessor/Imaging/CropLayer.cs +++ b/src/ImageProcessor/Imaging/CropLayer.cs @@ -77,5 +77,47 @@ namespace ImageProcessor.Imaging /// Gets or sets the . /// public CropMode CropMode { get; set; } + + /// + /// Determines whether the specified , is + /// equal to this instance. + /// + /// + /// The to compare with this instance. + /// + /// + /// true if the specified is equal to + /// this instance; otherwise, false. + /// + public override bool Equals(object obj) + { + CropLayer cropLayer = obj as CropLayer; + + if (cropLayer == null) + { + return false; + } + + // Define the tolerance for variation in their values + return Math.Abs(this.Top - cropLayer.Top) <= Math.Abs(this.Top * .0001) + && Math.Abs(this.Right - cropLayer.Right) <= Math.Abs(this.Right * .0001) + && Math.Abs(this.Bottom - cropLayer.Bottom) <= Math.Abs(this.Bottom * .0001) + && Math.Abs(this.Left - cropLayer.Left) <= Math.Abs(this.Left * .0001) + && this.CropMode.Equals(cropLayer.CropMode); + } + + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in hashing algorithms + /// and data structures like a hash table. + /// + public override int GetHashCode() + { + return this.Top.GetHashCode() + this.Right.GetHashCode() + + this.Bottom.GetHashCode() + this.Left.GetHashCode() + + this.CropMode.GetHashCode(); + } } } diff --git a/src/ImageProcessor/Imaging/RoundedCornerLayer.cs b/src/ImageProcessor/Imaging/RoundedCornerLayer.cs index 89faa83190..edfcfd33e1 100644 --- a/src/ImageProcessor/Imaging/RoundedCornerLayer.cs +++ b/src/ImageProcessor/Imaging/RoundedCornerLayer.cs @@ -1,11 +1,4 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) James South. -// Licensed under the Apache License, Version 2.0. -// -// ----------------------------------------------------------------------- - -namespace ImageProcessor.Imaging +namespace ImageProcessor.Imaging { #region Using using System.Drawing; diff --git a/src/ImageProcessor/Properties/AssemblyInfo.cs b/src/ImageProcessor/Properties/AssemblyInfo.cs index f7c90f178d..0e7ded17b6 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.8.8.0")] -[assembly: AssemblyFileVersion("1.8.8.0")] +[assembly: AssemblyVersion("1.9.0.0")] +[assembly: AssemblyFileVersion("1.9.0.0")] diff --git a/src/ImageProcessorConsole/Program.cs b/src/ImageProcessorConsole/Program.cs index b5f0abdb33..070afe2d82 100644 --- a/src/ImageProcessorConsole/Program.cs +++ b/src/ImageProcessorConsole/Program.cs @@ -1,17 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; + namespace ImageProcessorConsole { + using System; using System.Drawing; using System.Drawing.Imaging; using System.IO; - using ImageProcessor; - using ImageProcessor.Imaging.Filters; class Program { diff --git a/src/Web.Test/LoadTest1.loadtest b/src/Web.Test/LoadTest1.loadtest index 0690f1a847..40022d4490 100644 --- a/src/Web.Test/LoadTest1.loadtest +++ b/src/Web.Test/LoadTest1.loadtest @@ -1,17 +1,17 @@  - + - + - + -
+
@@ -92,7 +92,7 @@ - + @@ -157,7 +157,7 @@ - + @@ -303,7 +303,7 @@ - + @@ -416,7 +416,7 @@ - +