diff --git a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs
index 88ffe7d48..9ec0fb696 100644
--- a/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs
+++ b/src/ImageProcessor.Web/NET45/Caching/DiskCache.cs
@@ -14,9 +14,9 @@ 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;
@@ -51,7 +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(ImageProcessorConfiguration.Instance.VirtualCachePath);
///
/// The request for the image.
@@ -171,8 +171,7 @@ namespace ImageProcessor.Web.Caching
if (cachedImage != null)
{
- // Can't check the last write time so check to see if the cached image is set to expire
- // or if the max age is different.
+ // Can't check the filestream so check to see if the cached image is set to expire.
if (this.IsExpired(cachedImage.CreationTimeUtc))
{
CacheIndexer.Remove(path);
@@ -286,14 +285,11 @@ namespace ImageProcessor.Web.Caching
{
// 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);
- }
- }
+
+ // Checking the stream itself is far too processor intensive so we make a best guess.
+ string creation = imageFileInfo.CreationTimeUtc.ToString(CultureInfo.InvariantCulture);
+ string length = imageFileInfo.Length.ToString(CultureInfo.InvariantCulture);
+ streamHash = string.Format("{0}{1}", creation, length);
}
}
}
@@ -304,7 +300,7 @@ namespace ImageProcessor.Web.Caching
// 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.
+ // The characters of that hash as sub-folders.
string parsedExtension = ImageHelpers.GetExtension(this.fullPath);
string fallbackExtension = this.imageName.Substring(this.imageName.LastIndexOf(".", StringComparison.Ordinal) + 1);
string encryptedName = (streamHash + this.fullPath).ToSHA1Fingerprint();
@@ -340,4 +336,4 @@ namespace ImageProcessor.Web.Caching
#endregion
#endregion
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs
index dbad66309..aa62aab75 100644
--- a/src/ImageProcessor/ImageFactory.cs
+++ b/src/ImageProcessor/ImageFactory.cs
@@ -17,8 +17,6 @@ namespace ImageProcessor
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
- using System.Linq;
-
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Imaging;
using ImageProcessor.Imaging.Filters;
@@ -333,7 +331,7 @@ namespace ImageProcessor
if (this.ShouldProcess)
{
AutoRotate autoRotate = new AutoRotate();
- this.ApplyProcessor(autoRotate.ProcessImage);
+ this.CurrentImageFormat.ApplyProcessor(autoRotate.ProcessImage, this);
}
return this;
@@ -846,19 +844,6 @@ namespace ImageProcessor
{
if (this.ShouldProcess)
{
- // 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 = Path.GetExtension(filePath).TrimStart('.');
- string fallback = this.CurrentImageFormat.DefaultExtension;
-
- if (extension != fallback && !this.CurrentImageFormat.FileExtensions.Contains(extension))
- {
- filePath = length == -1
- ? string.Format("{0}.{1}", filePath, fallback)
- : filePath.Substring(0, length + 1) + fallback;
- }
-
// ReSharper disable once AssignNullToNotNullAttribute
DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(filePath));
if (!directoryInfo.Exists)