Browse Source

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: 50ec25580a92b47dfb6227ca57aebaf7c814636e
af/merge-core
James South 12 years ago
parent
commit
733d6a22f7
  1. 6
      build/Build.bat
  2. 8
      build/NuSpecs/ImageProcessor.Web.Config.nuspec
  3. 8
      build/NuSpecs/ImageProcessor.Web.nuspec
  4. 2
      build/NuSpecs/ImageProcessor.nuspec
  5. 7
      src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj
  6. 4
      src/ImageProcessor.Web/NET4/app.config
  7. 2
      src/ImageProcessor.Web/NET4/packages.config
  8. 3
      src/ImageProcessor.Web/NET45/Caching/CacheIndexer.cs
  9. 5
      src/ImageProcessor.Web/NET45/Caching/CachedImage.cs
  10. 161
      src/ImageProcessor.Web/NET45/Caching/DiskCache.cs
  11. 10
      src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs
  12. 4
      src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs
  13. 4
      src/ImageProcessor/Properties/AssemblyInfo.cs
  14. 6
      src/TestWebsites/NET4/Test_Website_MVC_NET4.csproj
  15. 10
      src/TestWebsites/NET4/Web.config
  16. 1
      src/TestWebsites/NET4/config/imageprocessor/processing.config
  17. 2
      src/TestWebsites/NET4/packages.config

6
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%

8
build/NuSpecs/ImageProcessor.Web.Config.nuspec

@ -21,12 +21,12 @@ Feedback is always welcome</description>
<tags>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</tags>
<dependencies>
<group targetFramework=".NETFramework4.0">
<dependency id="ImageProcessor" version="1.9.2.0" />
<dependency id="ImageProcessor.Web" version="3.2.5.0" />
<dependency id="ImageProcessor" version="1.9.3.0" />
<dependency id="ImageProcessor.Web" version="3.2.7.0" />
</group>
<group targetFramework=".NETFramework4.5">
<dependency id="ImageProcessor" version="1.9.2.0" />
<dependency id="ImageProcessor.Web" version="3.2.5.0" />
<dependency id="ImageProcessor" version="1.9.3.0" />
<dependency id="ImageProcessor.Web" version="3.2.7.0" />
</group>
</dependencies>
</metadata>

8
build/NuSpecs/ImageProcessor.Web.nuspec

@ -22,15 +22,15 @@ Feedback is always welcome</description>
<releaseNotes />
<copyright>James South</copyright>
<language>en-GB</language>
<tags>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</tags>
<tags>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</tags>
<dependencies>
<group targetFramework=".NETFramework4.0">
<dependency id="Microsoft.Bcl.Async" version="1.0.168" />
<dependency id="Microsoft.Bcl" version="1.1.8" />
<dependency id="ImageProcessor" version="1.9.2.0" />
<dependency id="Microsoft.Bcl" version="1.1.9" />
<dependency id="ImageProcessor" version="1.9.3.0" />
</group>
<group targetFramework=".NETFramework4.5">
<dependency id="ImageProcessor" version="1.9.2.0" />
<dependency id="ImageProcessor" version="1.9.3.0" />
</group>
</dependencies>
</metadata>

2
build/NuSpecs/ImageProcessor.nuspec

@ -21,7 +21,7 @@ Feedback is always welcome.</description>
<releaseNotes />
<copyright>James South</copyright>
<language>en-GB</language>
<tags>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</tags>
<tags>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</tags>
</metadata>
<files>
<file src="..\_BuildOutput\ImageProcessor\lib\ImageProcessor.dll" target="lib\ImageProcessor.dll" />

7
src/ImageProcessor.Web/NET4/ImageProcessor.Web_NET4.csproj

@ -59,15 +59,16 @@
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO">
<HintPath>..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.IO.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Runtime">
<HintPath>..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Threading.Tasks">
<HintPath>..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Data" />

4
src/ImageProcessor.Web/NET4/app.config

@ -4,11 +4,11 @@
<assemblyBinding xmlns:bcl="urn:schemas-microsoft-com:bcl" xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly bcl:name="System.Runtime">
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
<dependentAssembly bcl:name="System.Threading.Tasks">
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

2
src/ImageProcessor.Web/NET4/packages.config

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net40" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
</packages>

3
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
};
}
}

5
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.
/// </summary>
public DateTime CreationTimeUtc { get; set; }
/// <summary>
/// Gets or sets the last write time of the cached image.
/// </summary>
public DateTime LastWriteTimeUtc { get; set; }
}
}

161
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
/// <summary>
/// The absolute path to virtual cache path on the server.
/// </summary>
private static readonly string AbsoluteCachePath =
HostingEnvironment.MapPath(ImageProcessorConfig.Instance.VirtualCachePath);
private static readonly string AbsoluteCachePath = HostingEnvironment.MapPath(ImageProcessorConfig.Instance.VirtualCachePath);
/// <summary>
/// The request for the image.
@ -142,18 +140,14 @@ namespace ImageProcessor.Web.Caching
/// <summary>
/// Adds an image to the cache.
/// </summary>
/// <param name="creationAndLastWriteDateTimes">
/// The creation and last write times.
/// </param>
internal void AddImageToCache(Tuple<DateTime, DateTime> 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;
}
/// <summary>
/// Gets the <see cref="T:System.DateTime"/> set to the last write time of the file.
/// </summary>
/// <returns>
/// The last write time of the file.
/// </returns>
internal async Task<DateTime> GetLastWriteTimeAsync()
{
DateTime dateTime = DateTime.UtcNow;
CachedImage cachedImage = await CacheIndexer.GetValueAsync(this.CachedPath);
if (cachedImage != null)
{
dateTime = cachedImage.LastWriteTimeUtc;
}
return dateTime;
}
/// <summary>
/// Sets the LastWriteTime of the cached file to match the original file.
/// </summary>
/// <returns>
/// The <see cref="T:System.DateTime"/> set to the last write time of the file.
/// </returns>
internal async Task<Tuple<DateTime, DateTime>> SetCachedLastWriteTimeAsync()
{
// Create Action delegate for SetCachedLastWriteTime.
return await TaskHelpers.Run(() => this.SetCachedLastWriteTime());
}
/// <summary>
/// Trims a cached folder ensuring that it does not exceed the maximum file count.
/// </summary>
@ -273,46 +216,6 @@ namespace ImageProcessor.Web.Caching
#endregion
#region Private
/// <summary>
/// Sets the LastWriteTime of the cached file to match the original file.
/// </summary>
/// <returns>
/// The <see cref="T:System.DateTime"/> of the original and cached file.
/// </returns>
private Tuple<DateTime, DateTime> 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<DateTime, DateTime>(creationTime, lastWriteTime);
}
/// <summary>
/// Trims a cached folder ensuring that it does not exceed the maximum file count.
/// </summary>
@ -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;
}
/// <summary>
/// The rough date time compare.
/// </summary>
/// <param name="first">
/// The first.
/// </param>
/// <param name="second">
/// The second.
/// </param>
/// <returns>
/// The <see cref="bool"/> true if the DateTimes roughly compare; otherwise, false.
/// </returns>
private bool RoughDateTimeCompare(DateTime first, DateTime second)
{
if (first.ToString(CultureInfo.InvariantCulture) == second.ToString(CultureInfo.InvariantCulture))
{
return true;
}
return false;
}
/// <summary>
/// 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
}
}
}

10
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<DateTime, DateTime> 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<DateTime, DateTime> creationAndLastWriteDateTimes = await cache.SetCachedLastWriteTimeAsync();
// Add to the cache.
cache.AddImageToCache(creationAndLastWriteDateTimes);
cache.AddImageToCache();
// Trim the cache.
await cache.TrimCachedFolderAsync(cachedPath);

4
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")]
[assembly: AssemblyVersion("3.2.7.0")]
[assembly: AssemblyFileVersion("3.2.7.0")]

4
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")]

6
src/TestWebsites/NET4/Test_Website_MVC_NET4.csproj

@ -70,14 +70,14 @@
</Reference>
<Reference Include="System.Data.Entity" />
<Reference Include="System.IO">
<HintPath>..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.IO.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Runtime">
<HintPath>..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks">
<HintPath>..\..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />

10
src/TestWebsites/NET4/Web.config

@ -46,7 +46,7 @@
</namespaces>
</pages>
<httpModules>
<add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web"/>
<add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web" />
</httpModules>
<!--Set the trust level.-->
<!--<trust level="Medium"/>-->
@ -63,13 +63,13 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<dependentAssembly name="System.Runtime">
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
<dependentAssembly>
<dependentAssembly name="System.Threading.Tasks">
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

1
src/TestWebsites/NET4/config/imageprocessor/processing.config

@ -5,6 +5,7 @@
</presets>
<plugins autoLoadPlugins="true">
<plugin name="Alpha" type="ImageProcessor.Processors.Alpha, ImageProcessor"/>
<plugin name="AutoRotate" type="ImageProcessor.Processors.AutoRotate, ImageProcessor"/>
<plugin name="Brightness" type="ImageProcessor.Processors.Brightness, ImageProcessor"/>
<plugin name="Contrast" type="ImageProcessor.Processors.Contrast, ImageProcessor"/>
<plugin name="Crop" type="ImageProcessor.Processors.Crop, ImageProcessor"/>

2
src/TestWebsites/NET4/packages.config

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net40" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
</packages>
Loading…
Cancel
Save