diff --git a/build/NuSpecs/ImageProcessor.Web.PostProcessor.nuspec b/build/NuSpecs/ImageProcessor.Web.PostProcessor.nuspec
new file mode 100644
index 000000000..206ba449a
--- /dev/null
+++ b/build/NuSpecs/ImageProcessor.Web.PostProcessor.nuspec
@@ -0,0 +1,32 @@
+
+
+
+ ImageProcessor.Web.PostProcessor
+ 1.0.0.0
+ ImageProcessor.Web.PostProcessor
+ James South
+ James South
+ http://imageprocessor.org
+ http://imageprocessor.org/assets/ico/apple-touch-icon-144x144.png
+ false
+ Applies various image compression tools to further optimize cached .png, .gif, and .jpg images.
+
+If you use ImageProcessor please get in touch via my twitter @james_m_south
+
+Feedback is always welcome
+ ImageProcessor.Web PostProcessor for ASP.NET websites.
+
+ James South
+ en-GB
+ Image Resize Crop Rotate Quality Watermark Gif Jpg Jpeg Bitmap Png Tiff ASP Cache EXIF
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/NuSpecs/ImageProcessor.Web.nuspec b/build/NuSpecs/ImageProcessor.Web.nuspec
index 653501346..8e0c2af5f 100644
--- a/build/NuSpecs/ImageProcessor.Web.nuspec
+++ b/build/NuSpecs/ImageProcessor.Web.nuspec
@@ -2,7 +2,7 @@
ImageProcessor.Web
- 4.1.3.0
+ 4.1.4.0
ImageProcessor.Web
James South
James South
diff --git a/build/build.xml b/build/build.xml
index 97687cb97..bebc352fb 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -13,7 +13,7 @@
ImageProcessor Web
- 4.1.3.0
+ 4.1.4.0
..\src\ImageProcessor.Web
ImageProcessor.Web.csproj
@@ -22,6 +22,17 @@
ImageProcessor.Web.nuspec
+
+ ImageProcessor Web PostProcessor
+ 1.0.0.0
+ ..\src\ImageProcessor.Web.PostProcessor
+ ImageProcessor.Web.PostProcessor.csproj
+
+
+
+ ImageProcessor.Web.PostProcessor.nuspec
+
+
ImageProcessor Web.config sample
2.1.0.0
diff --git a/src/ImageProcessor.Web.PostProcessor/ApplicationEvents.cs b/src/ImageProcessor.Web.PostProcessor/ApplicationEvents.cs
index 27162b32e..f272fb32a 100644
--- a/src/ImageProcessor.Web.PostProcessor/ApplicationEvents.cs
+++ b/src/ImageProcessor.Web.PostProcessor/ApplicationEvents.cs
@@ -1,10 +1,10 @@
// --------------------------------------------------------------------------------------------------------------------
-//
+//
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
//
//
-// PostProcesses any image requests within the web application.
+// Binds the PostProcessor to process any image requests within the web application.
// Many thanks to Azure Image Optimizer
//
// --------------------------------------------------------------------------------------------------------------------
@@ -12,25 +12,38 @@
using System.Web;
[assembly: PreApplicationStartMethod(typeof(ImageProcessor.Web.PostProcessor.ApplicationEvents), "Start")]
+
namespace ImageProcessor.Web.PostProcessor
{
using ImageProcessor.Web.Helpers;
using ImageProcessor.Web.HttpModules;
///
- /// PostProcesses any image requests within the web application.
+ /// Binds the PostProcessor to process any image requests within the web application.
/// Many thanks to Azure Image Optimizer
///
public static class ApplicationEvents
{
+ ///
+ /// The initial startup method.
+ ///
public static void Start()
{
- ImageProcessingModule.OnPostProcessing += PostProcess;
+ ImageProcessingModule.OnPostProcessing += PostProcessAsync;
}
- private static async void PostProcess(object sender, PostProcessingEventArgs e)
+ ///
+ /// Asynchronously post-processes cached images.
+ ///
+ ///
+ /// The source of the event.
+ ///
+ ///
+ /// An EventArgs that contains the event data.
+ ///
+ private static async void PostProcessAsync(object sender, PostProcessingEventArgs e)
{
- await PostProcessor.PostProcessImage(e.CachedImagePath);
+ await PostProcessor.PostProcessImageAsync(e.CachedImagePath);
}
}
}
diff --git a/src/ImageProcessor.Web.PostProcessor/PostProcessingResultEventArgs.cs b/src/ImageProcessor.Web.PostProcessor/PostProcessingResultEventArgs.cs
index eb019872e..6f58686f6 100644
--- a/src/ImageProcessor.Web.PostProcessor/PostProcessingResultEventArgs.cs
+++ b/src/ImageProcessor.Web.PostProcessor/PostProcessingResultEventArgs.cs
@@ -45,27 +45,27 @@ namespace ImageProcessor.Web.PostProcessor
}
///
- /// Gets the original file size in bytes.
+ /// Gets or sets the original file size in bytes.
///
public long OriginalFileSize { get; set; }
///
- /// Gets the original file name.
+ /// Gets or sets the original file name.
///
public string OriginalFileName { get; set; }
///
- /// Gets the result file size in bytes.
+ /// Gets or sets the result file size in bytes.
///
public long ResultFileSize { get; set; }
///
- ///
+ /// Gets or sets the result file name.
///
public string ResultFileName { get; set; }
///
- /// Gets the difference in filesize in bytes.
+ /// Gets the difference in file size in bytes.
///
public long Saving
{
@@ -73,13 +73,13 @@ namespace ImageProcessor.Web.PostProcessor
}
///
- /// Gets the difference in filesize as a percentage.
+ /// Gets the difference in file size as a percentage.
///
public double Percent
{
get
{
- return Math.Round(100 - this.ResultFileSize / (double)this.OriginalFileSize * 100, 1);
+ return Math.Round(100 - ((this.ResultFileSize / (double)this.OriginalFileSize) * 100), 1);
}
}
@@ -95,7 +95,7 @@ namespace ImageProcessor.Web.PostProcessor
stringBuilder.AppendLine("Optimized " + Path.GetFileName(this.OriginalFileName));
stringBuilder.AppendLine("Before: " + this.OriginalFileSize + " bytes");
stringBuilder.AppendLine("After: " + this.ResultFileSize + " bytes");
- stringBuilder.AppendLine("Saving: " + this.Saving + " bytes / " + Percent + "%");
+ stringBuilder.AppendLine("Saving: " + this.Saving + " bytes / " + this.Percent + "%");
return stringBuilder.ToString();
}
diff --git a/src/ImageProcessor.Web.PostProcessor/PostProcessor.cs b/src/ImageProcessor.Web.PostProcessor/PostProcessor.cs
index 7508c3dcf..9d3a2be70 100644
--- a/src/ImageProcessor.Web.PostProcessor/PostProcessor.cs
+++ b/src/ImageProcessor.Web.PostProcessor/PostProcessor.cs
@@ -23,10 +23,19 @@ namespace ImageProcessor.Web.PostProcessor
///
internal static class PostProcessor
{
- public async static Task PostProcessImage(string sourceFile)
+ ///
+ /// Post processes the image asynchronously.
+ ///
+ ///
+ /// The source file.
+ ///
+ ///
+ /// The .
+ ///
+ public static async Task PostProcessImageAsync(string sourceFile)
{
string targetFile = Path.GetTempFileName();
- PostProcessingResultEventArgs result = await RunProcessAsync(sourceFile, targetFile);
+ PostProcessingResultEventArgs result = await RunProcess(sourceFile, targetFile);
if (result != null && result.Saving > 0 && result.ResultFileSize > 0)
{
@@ -39,7 +48,19 @@ namespace ImageProcessor.Web.PostProcessor
}
}
- private static Task RunProcessAsync(string sourceFile, string targetFile)
+ ///
+ /// Runs the process to optimize the images.
+ ///
+ ///
+ /// The source file.
+ ///
+ ///
+ /// The target file.
+ ///
+ ///
+ /// The containing post-processing information.
+ ///
+ private static Task RunProcess(string sourceFile, string targetFile)
{
TaskCompletionSource tcs = new TaskCompletionSource();
ProcessStartInfo start = new ProcessStartInfo("cmd")
@@ -74,6 +95,18 @@ namespace ImageProcessor.Web.PostProcessor
return tcs.Task;
}
+ ///
+ /// Gets the correct arguments to pass to the post-processor.
+ ///
+ ///
+ /// The source file.
+ ///
+ ///
+ /// The target file.
+ ///
+ ///
+ /// The containing the correct command arguments.
+ ///
private static string GetArguments(string sourceFile, string targetFile)
{
if (!Uri.IsWellFormedUriString(sourceFile, UriKind.RelativeOrAbsolute) && !File.Exists(sourceFile))
@@ -105,6 +138,7 @@ namespace ImageProcessor.Web.PostProcessor
case ".gif":
return string.Format(CultureInfo.CurrentCulture, "/c gifsicle --crop-transparency --no-comments --no-extensions --no-names --optimize=3 --batch \"{0}\" --output=\"{1}\"", sourceFile, targetFile);
}
+
return null;
}
}
diff --git a/src/ImageProcessor.Web.PostProcessor/Properties/AssemblyInfo.cs b/src/ImageProcessor.Web.PostProcessor/Properties/AssemblyInfo.cs
index cd5035c52..7b3e6c9e5 100644
--- a/src/ImageProcessor.Web.PostProcessor/Properties/AssemblyInfo.cs
+++ b/src/ImageProcessor.Web.PostProcessor/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-using System.Reflection;
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -6,11 +6,11 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ImageProcessor.Web.PostProcessor")]
-[assembly: AssemblyDescription("")]
+[assembly: AssemblyDescription("Post-processes cached images to further reduce file size.")]
[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
+[assembly: AssemblyCompany("James South")]
[assembly: AssemblyProduct("ImageProcessor.Web.PostProcessor")]
-[assembly: AssemblyCopyright("Copyright © 2014")]
+[assembly: AssemblyCopyright("Copyright © James South")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
//
// 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: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]