From 86688b3c94d185868fb89e760b867ec1f44ab1e4 Mon Sep 17 00:00:00 2001 From: James South Date: Sun, 15 Jun 2014 00:14:55 +0200 Subject: [PATCH 1/3] Adding Autorotate Former-commit-id: 2903805a22fbf83397cf2dac48d8ce3e8ad3d1f8 --- .../NET45/Config/Resources/processing.config | 1 + src/ImageProcessor/ImageFactory.cs | 91 ++++++---- src/ImageProcessor/ImageProcessor.csproj | 1 + src/ImageProcessor/Processors/AutoRotate.cs | 158 ++++++++++++++++++ src/Images/rotate.jpg.REMOVED.git-id | 1 + 5 files changed, 223 insertions(+), 29 deletions(-) create mode 100644 src/ImageProcessor/Processors/AutoRotate.cs create mode 100644 src/Images/rotate.jpg.REMOVED.git-id diff --git a/src/ImageProcessor.Web/NET45/Config/Resources/processing.config b/src/ImageProcessor.Web/NET45/Config/Resources/processing.config index 562cafcb8..e792c3950 100644 --- a/src/ImageProcessor.Web/NET45/Config/Resources/processing.config +++ b/src/ImageProcessor.Web/NET45/Config/Resources/processing.config @@ -3,6 +3,7 @@ + diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index b88c3d3bf..31665c2a6 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -182,12 +182,10 @@ namespace ImageProcessor this.backupImageFormat = this.ImageFormat; this.isIndexed = ImageUtils.IsIndexed(this.Image); - if (this.PreserveExifData) + // Always load the data. + foreach (PropertyItem propertyItem in this.Image.PropertyItems) { - foreach (PropertyItem propertyItem in this.Image.PropertyItems) - { - this.ExifPropertyItems[propertyItem.Id] = propertyItem; - } + this.ExifPropertyItems[propertyItem.Id] = propertyItem; } this.ShouldProcess = true; @@ -244,12 +242,10 @@ namespace ImageProcessor this.ImageFormat = imageFormat; this.isIndexed = ImageUtils.IsIndexed(this.Image); - if (this.PreserveExifData) + // Always load the data. + foreach (PropertyItem propertyItem in this.Image.PropertyItems) { - foreach (PropertyItem propertyItem in this.Image.PropertyItems) - { - this.ExifPropertyItems[propertyItem.Id] = propertyItem; - } + this.ExifPropertyItems[propertyItem.Id] = propertyItem; } this.ShouldProcess = true; @@ -347,6 +343,24 @@ namespace ImageProcessor return this; } + /// + /// Performs auto-rotation to ensure that EXIF defined rotation is reflected in + /// the final image. + /// + /// + /// The current instance of the class. + /// + public ImageFactory AutoRotate() + { + if (this.ShouldProcess) + { + AutoRotate autoRotate = new AutoRotate(); + this.ApplyProcessor(autoRotate.ProcessImage); + } + + return this; + } + /// /// Changes the brightness of the current image. /// @@ -868,6 +882,25 @@ namespace ImageProcessor // Fix the colour palette of indexed images. this.FixIndexedPallete(); + // 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. + } + } + } + // ReSharper disable once AssignNullToNotNullAttribute DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(filePath)); @@ -944,6 +977,25 @@ namespace ImageProcessor // Fix the colour palette of gif and png8 images. this.FixIndexedPallete(); + // 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. + } + } + } + if (this.ImageFormat.Equals(ImageFormat.Jpeg)) { // Jpegs can be saved with different settings to include a quality setting for the JPEG compression. @@ -1074,25 +1126,6 @@ namespace ImageProcessor { 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..026c166c4 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -100,6 +100,7 @@ + diff --git a/src/ImageProcessor/Processors/AutoRotate.cs b/src/ImageProcessor/Processors/AutoRotate.cs new file mode 100644 index 000000000..e99f6c905 --- /dev/null +++ b/src/ImageProcessor/Processors/AutoRotate.cs @@ -0,0 +1,158 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Performs auto-rotation to ensure that EXIF defined rotation is reflected in +// the final image. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Processors +{ + using System.Collections.Generic; + using System.Drawing; + using System.Text.RegularExpressions; + using ImageProcessor.Imaging; + + /// + /// Performs auto-rotation to ensure that EXIF defined rotation is reflected in + /// the final image. + /// + public class AutoRotate : IGraphicsProcessor + { + /// + /// The regular expression to search strings for. + /// + private static readonly Regex QueryRegex = new Regex(@"autorotate=true", RegexOptions.Compiled); + + /// + /// Gets the regular expression to search strings for. + /// + public Regex RegexPattern + { + get + { + return QueryRegex; + } + } + + /// + /// Gets or sets DynamicParameter. + /// + public dynamic DynamicParameter + { + get; + set; + } + + /// + /// Gets the order in which this processor is to be used in a chain. + /// + public int SortOrder + { + get; + private set; + } + + /// + /// Gets or sets any additional settings required by the processor. + /// + public Dictionary Settings + { + get; + set; + } + + /// + /// The position in the original string where the first character of the captured substring was found. + /// + /// + /// The query string to search. + /// + /// + /// The zero-based starting position in the original string where the captured substring was found. + /// + public int MatchRegexIndex(string queryString) + { + int index = 0; + + // Set the sort order to max to allow filtering. + this.SortOrder = int.MaxValue; + + foreach (Match match in this.RegexPattern.Matches(queryString)) + { + if (match.Success) + { + if (index == 0) + { + // Set the index on the first instance only. + this.SortOrder = match.Index; + } + + index += 1; + } + } + + return this.SortOrder; + } + + /// + /// 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 + { + const int Orientation = (int)ExifPropertyTag.Orientation; + if (!factory.PreserveExifData && factory.ExifPropertyItems.ContainsKey(Orientation)) + { + newImage = new Bitmap(image); + + int rotationValue = factory.ExifPropertyItems[Orientation].Value[0]; + switch (rotationValue) + { + case 1: // Landscape, do nothing + break; + + case 8: // Rotated 90 right + // De-rotate: + newImage.RotateFlip(RotateFlipType.Rotate270FlipNone); + break; + + case 3: // Bottoms up + newImage.RotateFlip(RotateFlipType.Rotate180FlipNone); + break; + + case 6: // Rotated 90 left + newImage.RotateFlip(RotateFlipType.Rotate90FlipNone); + break; + } + + // Reassign the image. + image.Dispose(); + image = newImage; + } + } + catch + { + if (newImage != null) + { + newImage.Dispose(); + } + } + + return image; + } + } +} \ No newline at end of file diff --git a/src/Images/rotate.jpg.REMOVED.git-id b/src/Images/rotate.jpg.REMOVED.git-id new file mode 100644 index 000000000..bf0538b24 --- /dev/null +++ b/src/Images/rotate.jpg.REMOVED.git-id @@ -0,0 +1 @@ +406a6a7916628c0c0bea8243565a7162ebd5a505 \ No newline at end of file From ac7b06c8d356017636884db9bf6a52d927b15e23 Mon Sep 17 00:00:00 2001 From: James South Date: Mon, 16 Jun 2014 21:36:05 +0100 Subject: [PATCH 2/3] Fixes issue #55 Former-commit-id: eac31cce528fb55ee6c7fb99707b6c274e7c0af5 --- src/ImageProcessor/ImageFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 31665c2a6..082795b86 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -449,7 +449,7 @@ namespace ImageProcessor { if (this.ShouldProcess) { - CropLayer cropLayer = new CropLayer(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom, CropMode.Pixels); + CropLayer cropLayer = new CropLayer(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height, CropMode.Pixels); return this.Crop(cropLayer); } From 54f0c11e880adf62ba200349b0886f1662091d93 Mon Sep 17 00:00:00 2001 From: James South Date: Wed, 18 Jun 2014 13:50:45 +0100 Subject: [PATCH 3/3] v1.9.2, v3.2.7, v1.1.2 - Adds AutoRotate - Fixes ImageProcessor.Crop bug. - Updates cache to be compatible with Azure Image Optimizer Former-commit-id: 6314e378ebcb00ece8b1b5f39c4bfa4524d6cdc2 --- build/Build.bat | 6 +- .../NuSpecs/ImageProcessor.Web.Config.nuspec | 8 +- build/NuSpecs/ImageProcessor.Web.nuspec | 8 +- build/NuSpecs/ImageProcessor.nuspec | 2 +- .../NET4/ImageProcessor.Web_NET4.csproj | 7 +- src/ImageProcessor.Web/NET4/app.config | 4 +- src/ImageProcessor.Web/NET4/packages.config | 2 +- .../NET45/Caching/CacheIndexer.cs | 3 +- .../NET45/Caching/CachedImage.cs | 5 - .../NET45/Caching/DiskCache.cs | 161 ++++-------------- .../HttpModules/ImageProcessingModule.cs | 10 +- .../NET45/Properties/AssemblyInfo.cs | 4 +- src/ImageProcessor/Properties/AssemblyInfo.cs | 4 +- .../NET4/Test_Website_MVC_NET4.csproj | 6 +- src/TestWebsites/NET4/Web.config | 10 +- .../config/imageprocessor/processing.config | 1 + src/TestWebsites/NET4/packages.config | 2 +- 17 files changed, 71 insertions(+), 172 deletions(-) diff --git a/build/Build.bat b/build/Build.bat index 93e60ce61..61973a204 100644 --- a/build/Build.bat +++ b/build/Build.bat @@ -1,7 +1,7 @@ @ECHO OFF -SET version=1.9.2.0 -SET webversion=3.2.6.0 -SET webconfigversion=1.1.1.0 +SET version=1.9.3.0 +SET webversion=3.2.7.0 +SET webconfigversion=1.1.2.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 d20d8fc73..cb27a3fb2 100644 --- a/build/NuSpecs/ImageProcessor.Web.Config.nuspec +++ b/build/NuSpecs/ImageProcessor.Web.Config.nuspec @@ -21,12 +21,12 @@ 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 - - + + - - + + diff --git a/build/NuSpecs/ImageProcessor.Web.nuspec b/build/NuSpecs/ImageProcessor.Web.nuspec index 78dec17d9..5e640a422 100644 --- a/build/NuSpecs/ImageProcessor.Web.nuspec +++ b/build/NuSpecs/ImageProcessor.Web.nuspec @@ -22,15 +22,15 @@ 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 + 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 Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF - - + + - + diff --git a/build/NuSpecs/ImageProcessor.nuspec b/build/NuSpecs/ImageProcessor.nuspec index 757d7a76c..80bdd79a1 100644 --- a/build/NuSpecs/ImageProcessor.nuspec +++ b/build/NuSpecs/ImageProcessor.nuspec @@ -21,7 +21,7 @@ Feedback is always welcome. James South en-GB - Image Imaging ASP Performance Processing 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 + 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 diff --git a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj index 4432f1f25..cad554bb4 100644 --- a/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj +++ b/src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj @@ -59,15 +59,16 @@ - ..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll + ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.IO.dll + True - ..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll + ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Runtime.dll - ..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll + ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Threading.Tasks.dll diff --git a/src/ImageProcessor.Web/NET4/app.config b/src/ImageProcessor.Web/NET4/app.config index d7f44b988..31d365ae5 100644 --- a/src/ImageProcessor.Web/NET4/app.config +++ b/src/ImageProcessor.Web/NET4/app.config @@ -4,11 +4,11 @@ - + - + diff --git a/src/ImageProcessor.Web/NET4/packages.config b/src/ImageProcessor.Web/NET4/packages.config index fd0874c23..c7068f590 100644 --- a/src/ImageProcessor.Web/NET4/packages.config +++ b/src/ImageProcessor.Web/NET4/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET45/Caching/CacheIndexer.cs b/src/ImageProcessor.Web/NET45/Caching/CacheIndexer.cs index 6e975dbd3..cd40c9439 100644 --- a/src/ImageProcessor.Web/NET45/Caching/CacheIndexer.cs +++ b/src/ImageProcessor.Web/NET45/Caching/CacheIndexer.cs @@ -114,8 +114,7 @@ namespace ImageProcessor.Web.Caching { Key = Path.GetFileNameWithoutExtension(cachePath), Path = cachePath, - CreationTimeUtc = fileInfo.CreationTimeUtc, - LastWriteTimeUtc = fileInfo.LastWriteTimeUtc + CreationTimeUtc = fileInfo.CreationTimeUtc }; } } diff --git a/src/ImageProcessor.Web/NET45/Caching/CachedImage.cs b/src/ImageProcessor.Web/NET45/Caching/CachedImage.cs index 592d84eb4..f775ac1c8 100644 --- a/src/ImageProcessor.Web/NET45/Caching/CachedImage.cs +++ b/src/ImageProcessor.Web/NET45/Caching/CachedImage.cs @@ -33,10 +33,5 @@ namespace ImageProcessor.Web.Caching /// Gets or sets the creation time of the cached image. /// public DateTime CreationTimeUtc { get; set; } - - /// - /// Gets or sets the last write time of the cached image. - /// - public DateTime LastWriteTimeUtc { get; set; } } } diff --git a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs index 8052e0540..e48e57207 100644 --- a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs +++ b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs @@ -14,13 +14,12 @@ namespace ImageProcessor.Web.Caching using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - using System.Globalization; using System.IO; using System.Linq; + using System.Security.Cryptography; using System.Threading.Tasks; using System.Web; using System.Web.Hosting; - using ImageProcessor.Extensions; using ImageProcessor.Web.Config; using ImageProcessor.Web.Helpers; @@ -52,8 +51,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); + private static readonly string AbsoluteCachePath = HostingEnvironment.MapPath(ImageProcessorConfig.Instance.VirtualCachePath); /// /// The request for the image. @@ -142,18 +140,14 @@ namespace ImageProcessor.Web.Caching /// /// Adds an image to the cache. /// - /// - /// The creation and last write times. - /// - internal void AddImageToCache(Tuple creationAndLastWriteDateTimes) + internal void AddImageToCache() { string key = Path.GetFileNameWithoutExtension(this.CachedPath); CachedImage cachedImage = new CachedImage { Key = key, Path = this.CachedPath, - CreationTimeUtc = creationAndLastWriteDateTimes.Item1, - LastWriteTimeUtc = creationAndLastWriteDateTimes.Item2 + CreationTimeUtc = DateTime.UtcNow }; CacheIndexer.Add(cachedImage); @@ -196,26 +190,7 @@ namespace ImageProcessor.Web.Caching // Test now for locally requested files. cachedImage = await CacheIndexer.GetValueAsync(path); - if (cachedImage != null) - { - FileInfo imageFileInfo = new FileInfo(this.requestPath); - - if (imageFileInfo.Exists) - { - // Pull the latest info. - imageFileInfo.Refresh(); - - // Check to see if the last write time is different of whether the - // cached image is set to expire or if the max age is different. - if (!this.RoughDateTimeCompare(imageFileInfo.LastWriteTimeUtc, cachedImage.LastWriteTimeUtc) - || this.IsExpired(cachedImage.CreationTimeUtc)) - { - CacheIndexer.Remove(path); - isUpdated = true; - } - } - } - else + if (cachedImage == null) { // Nothing in the cache so we should return true. isUpdated = true; @@ -225,38 +200,6 @@ namespace ImageProcessor.Web.Caching return isUpdated; } - /// - /// Gets the set to the last write time of the file. - /// - /// - /// The last write time of the file. - /// - internal async Task GetLastWriteTimeAsync() - { - DateTime dateTime = DateTime.UtcNow; - - CachedImage cachedImage = await CacheIndexer.GetValueAsync(this.CachedPath); - - if (cachedImage != null) - { - dateTime = cachedImage.LastWriteTimeUtc; - } - - return dateTime; - } - - /// - /// Sets the LastWriteTime of the cached file to match the original file. - /// - /// - /// The set to the last write time of the file. - /// - internal async Task> SetCachedLastWriteTimeAsync() - { - // Create Action delegate for SetCachedLastWriteTime. - return await TaskHelpers.Run(() => this.SetCachedLastWriteTime()); - } - /// /// Trims a cached folder ensuring that it does not exceed the maximum file count. /// @@ -273,46 +216,6 @@ namespace ImageProcessor.Web.Caching #endregion #region Private - /// - /// Sets the LastWriteTime of the cached file to match the original file. - /// - /// - /// The of the original and cached file. - /// - private Tuple SetCachedLastWriteTime() - { - FileInfo cachedFileInfo = new FileInfo(this.CachedPath); - - // DateTime.Min explodes when used east of GMT. - DateTime baseDateTime = DateTime.UtcNow; - DateTime creationTime = baseDateTime; - DateTime lastWriteTime = baseDateTime; - - if (this.isRemote) - { - if (cachedFileInfo.Exists) - { - creationTime = cachedFileInfo.CreationTimeUtc; - lastWriteTime = cachedFileInfo.LastWriteTimeUtc; - } - } - else - { - FileInfo imageFileInfo = new FileInfo(this.requestPath); - - if (imageFileInfo.Exists && cachedFileInfo.Exists) - { - DateTime dateTime = imageFileInfo.LastWriteTimeUtc; - creationTime = cachedFileInfo.CreationTimeUtc; - - cachedFileInfo.LastWriteTimeUtc = dateTime; - lastWriteTime = dateTime; - } - } - - return new Tuple(creationTime, lastWriteTime); - } - /// /// Trims a cached folder ensuring that it does not exceed the maximum file count. /// @@ -368,15 +271,43 @@ namespace ImageProcessor.Web.Caching private string GetCachePath() { string cachedPath = string.Empty; + string streamHash = string.Empty; if (AbsoluteCachePath != null) { + try + { + if (new Uri(this.requestPath).IsFile) + { + // Get the hash for the filestream. That way we can ensure that if the image is + // updated but has the same name we will know. + FileInfo imageFileInfo = new FileInfo(this.requestPath); + if (imageFileInfo.Exists) + { + // Pull the latest info. + imageFileInfo.Refresh(); + using (MD5 md5 = MD5.Create()) + { + using (FileStream stream = File.OpenRead(imageFileInfo.FullName)) + { + byte[] hash = md5.ComputeHash(stream); + streamHash = BitConverter.ToString(hash); + } + } + } + } + } + catch + { + streamHash = string.Empty; + } + // Use an sha1 hash of the full path including the querystring to create the image name. // That name can also be used as a key for the cached image and we should be able to use // The characters of that hash as subfolders. string parsedExtension = ImageHelpers.GetExtension(this.fullPath); string fallbackExtension = this.imageName.Substring(this.imageName.LastIndexOf(".", StringComparison.Ordinal) + 1); - string encryptedName = this.fullPath.ToSHA1Fingerprint(); + string encryptedName = (streamHash + this.fullPath).ToSHA1Fingerprint(); // Collision rate of about 1 in 10000 for the folder structure. string pathFromKey = string.Join("\\", encryptedName.ToCharArray().Take(6)); @@ -392,28 +323,6 @@ namespace ImageProcessor.Web.Caching return cachedPath; } - /// - /// The rough date time compare. - /// - /// - /// The first. - /// - /// - /// The second. - /// - /// - /// The true if the DateTimes roughly compare; otherwise, false. - /// - private bool RoughDateTimeCompare(DateTime first, DateTime second) - { - if (first.ToString(CultureInfo.InvariantCulture) == second.ToString(CultureInfo.InvariantCulture)) - { - return true; - } - - return false; - } - /// /// Gets a value indicating whether the given images creation date is out with /// the prescribed limit. @@ -431,4 +340,4 @@ namespace ImageProcessor.Web.Caching #endregion #endregion } -} +} \ 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 efcbdc2ed..22c03bef7 100644 --- a/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs +++ b/src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs @@ -415,11 +415,8 @@ namespace ImageProcessor.Web.HttpModules // Store the response type in the context for later retrieval. context.Items[CachedResponseTypeKey] = imageFactory.MimeType; - // Ensure that the LastWriteTime property of the source and cached file match. - Tuple creationAndLastWriteDateTimes = await cache.SetCachedLastWriteTimeAsync(); - // Add to the cache. - cache.AddImageToCache(creationAndLastWriteDateTimes); + cache.AddImageToCache(); // Trim the cache. await cache.TrimCachedFolderAsync(cachedPath); @@ -455,11 +452,8 @@ namespace ImageProcessor.Web.HttpModules // Store the response type in the context for later retrieval. context.Items[CachedResponseTypeKey] = imageFactory.MimeType; - // Ensure that the LastWriteTime property of the source and cached file match. - Tuple creationAndLastWriteDateTimes = await cache.SetCachedLastWriteTimeAsync(); - // Add to the cache. - cache.AddImageToCache(creationAndLastWriteDateTimes); + cache.AddImageToCache(); // Trim the cache. await cache.TrimCachedFolderAsync(cachedPath); diff --git a/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs b/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs index 39c9a7e94..8763d6242 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.6.0")] -[assembly: AssemblyFileVersion("3.2.6.0")] \ No newline at end of file +[assembly: AssemblyVersion("3.2.7.0")] +[assembly: AssemblyFileVersion("3.2.7.0")] \ No newline at end of file diff --git a/src/ImageProcessor/Properties/AssemblyInfo.cs b/src/ImageProcessor/Properties/AssemblyInfo.cs index 8b03506f0..bea6c1401 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.2.0")] -[assembly: AssemblyFileVersion("1.9.2.0")] +[assembly: AssemblyVersion("1.9.3.0")] +[assembly: AssemblyFileVersion("1.9.3.0")] diff --git a/src/TestWebsites/NET4/Test_Website_MVC_NET4.csproj b/src/TestWebsites/NET4/Test_Website_MVC_NET4.csproj index b8d3b29dc..6158a3bce 100644 --- a/src/TestWebsites/NET4/Test_Website_MVC_NET4.csproj +++ b/src/TestWebsites/NET4/Test_Website_MVC_NET4.csproj @@ -70,14 +70,14 @@ - ..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll + ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.IO.dll - ..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll + ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Runtime.dll - ..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll + ..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Threading.Tasks.dll diff --git a/src/TestWebsites/NET4/Web.config b/src/TestWebsites/NET4/Web.config index f1a0ba606..1417ff9bf 100644 --- a/src/TestWebsites/NET4/Web.config +++ b/src/TestWebsites/NET4/Web.config @@ -46,7 +46,7 @@ - + @@ -63,13 +63,13 @@ - + - + - + - + diff --git a/src/TestWebsites/NET4/config/imageprocessor/processing.config b/src/TestWebsites/NET4/config/imageprocessor/processing.config index 654a9fbd6..85283e9f2 100644 --- a/src/TestWebsites/NET4/config/imageprocessor/processing.config +++ b/src/TestWebsites/NET4/config/imageprocessor/processing.config @@ -5,6 +5,7 @@ + diff --git a/src/TestWebsites/NET4/packages.config b/src/TestWebsites/NET4/packages.config index fd0874c23..c7068f590 100644 --- a/src/TestWebsites/NET4/packages.config +++ b/src/TestWebsites/NET4/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file