Browse Source

Refactoring and sense checking

Former-commit-id: 152ad831191fe1413038822f39a0a4fcdcda8ab2
af/merge-core
James South 12 years ago
parent
commit
3053267c3d
  1. 6
      build/Build.bat
  2. 14
      build/NuSpecs/ImageProcessor.Web.Config.nuspec
  3. 4
      build/NuSpecs/ImageProcessor.Web.nuspec
  4. 1
      build/NuSpecs/ImageProcessor.nuspec
  5. 10
      build/content/ImageProcessor.Web.Config/web.config.transform
  6. 4
      build/content/ImageProcessor.Web/web.config.transform
  7. 3
      src/ImageProcessor.Web/NET45/Caching/DiskCache.cs
  8. 2
      src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs
  9. 3
      src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config
  10. 3
      src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs
  11. 2
      src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs
  12. 3
      src/ImageProcessor.Web/NET45/Processors/Crop.cs
  13. 8
      src/ImageProcessor.Web/NET45/Processors/Format.cs
  14. 3
      src/ImageProcessor.Web/NET45/Processors/Resize.cs
  15. 3
      src/ImageProcessor.Web/NET45/Processors/Watermark.cs
  16. 4
      src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs
  17. 3
      src/ImageProcessor/Common/Exceptions/ImageFormatException.cs
  18. 2
      src/ImageProcessor/Common/Exceptions/ImageProcessingException.cs
  19. 2
      src/ImageProcessor/Common/Extensions/DoubleExtensions.cs
  20. 2
      src/ImageProcessor/Common/Extensions/IntegerExtensions.cs
  21. 6
      src/ImageProcessor/Common/Extensions/StringExtensions.cs
  22. 3
      src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs
  23. 3
      src/ImageProcessor/ImageFactory.cs
  24. 10
      src/ImageProcessor/ImageProcessor.csproj
  25. 2
      src/ImageProcessor/Imaging/Convolution.cs
  26. 4
      src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs
  27. 85
      src/ImageProcessor/Imaging/Formats/WebPFormat.cs
  28. 3
      src/ImageProcessor/Processors/Alpha.cs
  29. 3
      src/ImageProcessor/Processors/AutoRotate.cs
  30. 3
      src/ImageProcessor/Processors/BackgroundColor.cs
  31. 3
      src/ImageProcessor/Processors/Brightness.cs
  32. 3
      src/ImageProcessor/Processors/Contrast.cs
  33. 3
      src/ImageProcessor/Processors/Crop.cs
  34. 3
      src/ImageProcessor/Processors/Filter.cs
  35. 3
      src/ImageProcessor/Processors/Flip.cs
  36. 3
      src/ImageProcessor/Processors/Format.cs
  37. 3
      src/ImageProcessor/Processors/GaussianBlur.cs
  38. 3
      src/ImageProcessor/Processors/GaussianSharpen.cs
  39. 3
      src/ImageProcessor/Processors/Quality.cs
  40. 3
      src/ImageProcessor/Processors/Resize.cs
  41. 3
      src/ImageProcessor/Processors/Rotate.cs
  42. 3
      src/ImageProcessor/Processors/RoundedCorners.cs
  43. 3
      src/ImageProcessor/Processors/Saturation.cs
  44. 3
      src/ImageProcessor/Processors/Tint.cs
  45. 3
      src/ImageProcessor/Processors/Vignette.cs
  46. 3
      src/ImageProcessor/Processors/Watermark.cs
  47. 4
      src/ImageProcessor/Properties/AssemblyInfo.cs
  48. 41
      src/TestWebsites/NET4/config/imageprocessor/processing.config
  49. 2
      src/TestWebsites/NET45/Test_Website_NET45/Views/Web.config
  50. 5
      src/TestWebsites/NET45/Test_Website_NET45/Web.config
  51. 2
      src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config
  52. 4
      src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/security.config

6
build/Build.bat

@ -1,7 +1,7 @@
@ECHO OFF
SET version=1.9.3.0
SET webversion=3.2.7.0
SET webconfigversion=1.1.2.0
SET version=2.0.0.0
SET webversion=4.0.0.0
SET webconfigversion=2.0.0.0
ECHO Building ImageProcessor %version%, ImageProcess.Web %webversion% and ImageProcess.Web.Config %webconfigversion%

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

@ -21,19 +21,19 @@ 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.3.0" />
<dependency id="ImageProcessor.Web" version="3.2.7.0" />
<dependency id="ImageProcessor" version="2.0.0.0" />
<dependency id="ImageProcessor.Web" version="4.0.0.0" />
</group>
<group targetFramework=".NETFramework4.5">
<dependency id="ImageProcessor" version="1.9.3.0" />
<dependency id="ImageProcessor.Web" version="3.2.7.0" />
<dependency id="ImageProcessor" version="2.0.0.0" />
<dependency id="ImageProcessor.Web" version="4.0.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="..\..\src\ImageProcessor.Web\NET45\Config\Resources\cache.config" target="content\config\imageprocessor\cache.config" />
<file src="..\..\src\ImageProcessor.Web\NET45\Config\Resources\processing.config" target="content\config\imageprocessor\processing.config" />
<file src="..\..\src\ImageProcessor.Web\NET45\Config\Resources\security.config" target="content\config\imageprocessor\security.config" />
<file src="..\..\src\ImageProcessor.Web\NET45\Configuration\Resources\cache.config" target="content\config\imageprocessor\cache.config" />
<file src="..\..\src\ImageProcessor.Web\NET45\Configuration\Resources\processing.config" target="content\config\imageprocessor\processing.config" />
<file src="..\..\src\ImageProcessor.Web\NET45\Configuration\Resources\security.config" target="content\config\imageprocessor\security.config" />
<file src="..\content\ImageProcessor.Web.Config\web.config.transform" target="content\web.config.transform" />
</files>
</package>

4
build/NuSpecs/ImageProcessor.Web.nuspec

@ -27,10 +27,10 @@ Feedback is always welcome</description>
<group targetFramework=".NETFramework4.0">
<dependency id="Microsoft.Bcl.Async" version="1.0.168" />
<dependency id="Microsoft.Bcl" version="1.1.9" />
<dependency id="ImageProcessor" version="1.9.3.0" />
<dependency id="ImageProcessor" version="2.0.0.0" />
</group>
<group targetFramework=".NETFramework4.5">
<dependency id="ImageProcessor" version="1.9.3.0" />
<dependency id="ImageProcessor" version="2.0.0.0" />
</group>
</dependencies>
</metadata>

1
build/NuSpecs/ImageProcessor.nuspec

@ -25,5 +25,6 @@ Feedback is always welcome.</description>
</metadata>
<files>
<file src="..\_BuildOutput\ImageProcessor\lib\ImageProcessor.dll" target="lib\ImageProcessor.dll" />
<file src="..\_BuildOutput\ImageProcessor\lib\libwebp.dll" target="lib\libwebp.dll" />
</files>
</package>

10
build/content/ImageProcessor.Web.Config/web.config.transform

@ -2,9 +2,9 @@
<configuration>
<configSections>
<sectionGroup name="imageProcessor">
<section name="security" requirePermission="false" type="ImageProcessor.Web.Config.ImageSecuritySection, ImageProcessor.Web" />
<section name="processing" requirePermission="false" type="ImageProcessor.Web.Config.ImageProcessingSection, ImageProcessor.Web" />
<section name="cache" requirePermission="false" type="ImageProcessor.Web.Config.ImageCacheSection, ImageProcessor.Web" />
<section name="security" requirePermission="false" type="ImageProcessor.Web.Configuration.ImageSecuritySection, ImageProcessor.Web"/>
<section name="processing" requirePermission="false" type="ImageProcessor.Web.Configuration.ImageProcessingSection, ImageProcessor.Web"/>
<section name="cache" requirePermission="false" type="ImageProcessor.Web.Configuration.ImageCacheSection, ImageProcessor.Web"/>
</sectionGroup>
</configSections>
@ -13,8 +13,4 @@
<cache configSource="config\imageprocessor\cache.config" />
<processing configSource="config\imageprocessor\processing.config" />
</imageProcessor>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

4
build/content/ImageProcessor.Web/web.config.transform

@ -7,6 +7,10 @@
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<staticContent>
<remove fileExtension=".webp"/>
<mimeMap fileExtension=".webp" mimeType="image/webp" />
</staticContent>
<modules>
<add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web"/>
</modules>

3
src/ImageProcessor.Web/NET45/Caching/DiskCache.cs

@ -19,7 +19,8 @@ namespace ImageProcessor.Web.Caching
using System.Threading.Tasks;
using System.Web;
using System.Web.Hosting;
using ImageProcessor.Core.Common.Extensions;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Web.Configuration;
using ImageProcessor.Web.Helpers;
#endregion

2
src/ImageProcessor.Web/NET45/Configuration/ImageCacheSection.cs

@ -15,7 +15,7 @@ namespace ImageProcessor.Web.Configuration
using System.IO;
using System.Xml;
using ImageProcessor.Core.Common.Extensions;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Web.Helpers;
#endregion

3
src/ImageProcessor.Web/NET45/Configuration/Resources/processing.config

@ -4,12 +4,13 @@
<plugins autoLoadPlugins="true">
<plugin name="Alpha" type="ImageProcessor.Web.Processors.Alpha, ImageProcessor.Web"/>
<plugin name="AutoRotate" type="ImageProcessor.Web.Processors.AutoRotate, ImageProcessor.Web"/>
<plugin name="BackgroundColor" type="ImageProcessor.Web.Processors.BackgroundColor, ImageProcessor.Web"/>
<plugin name="Brightness" type="ImageProcessor.Web.Processors.Brightness, ImageProcessor.Web"/>
<plugin name="Contrast" type="ImageProcessor.Web.Processors.Contrast, ImageProcessor.Web"/>
<plugin name="Crop" type="ImageProcessor.Web.Processors.Crop, ImageProcessor.Web"/>
<plugin name="Filter" type="ImageProcessor.Web.Processors.Filter, ImageProcessor.Web"/>
<plugin name="Flip" type="ImageProcessor.Web.Processors.Flip, ImageProcessor.Web"/>
<plugin name="Format" type="ImageProcessor.Web.Processors.Format, ImageProcessor.Web"/>
<plugin name="Format" type="ImageProcessor.Web.Processors.Format, ImageProcessor.Web"/>
<plugin name="GaussianBlur" type="ImageProcessor.Web.Processors.GaussianBlur, ImageProcessor.Web">
<settings>
<setting key="MaxSize" value="22"/>

3
src/ImageProcessor.Web/NET45/Helpers/CommonParameterParserUtility.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Web.Helpers
using System.Drawing;
using System.Globalization;
using System.Text.RegularExpressions;
using ImageProcessor.Core.Common.Extensions;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Imaging;
/// <summary>

2
src/ImageProcessor.Web/NET45/HttpModules/ImageProcessingModule.cs

@ -29,7 +29,7 @@ namespace ImageProcessor.Web.HttpModules
using System.Web.Hosting;
using System.Web.Security;
using ImageProcessor.Core.Common.Extensions;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Web.Caching;
using ImageProcessor.Web.Configuration;
using ImageProcessor.Web.Helpers;

3
src/ImageProcessor.Web/NET45/Processors/Crop.cs

@ -12,7 +12,8 @@ namespace ImageProcessor.Web.Processors
{
using System.Text;
using System.Text.RegularExpressions;
using ImageProcessor.Core.Common.Extensions;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Imaging;
using ImageProcessor.Processors;

8
src/ImageProcessor.Web/NET45/Processors/Format.cs

@ -11,9 +11,12 @@
namespace ImageProcessor.Web.Processors
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using ImageProcessor.Configuration;
using ImageProcessor.Imaging.Formats;
using ImageProcessor.Processors;
@ -135,13 +138,14 @@ namespace ImageProcessor.Web.Processors
identifier = identifier.ToLowerInvariant();
string finalIdentifier = identifier.Equals("png8") ? "png" : identifier;
ISupportedImageFormat newFormat = null;
ISupportedImageFormat format = ImageProcessorBootstrapper.Instance.SupportedImageFormats
.FirstOrDefault(f => f.FileExtensions.Any(e => e.Equals(finalIdentifier, StringComparison.InvariantCultureIgnoreCase)));
List<ISupportedImageFormat> formats = ImageProcessorBootstrapper.Instance.SupportedImageFormats.ToList();
ISupportedImageFormat format = formats.FirstOrDefault(f => f.FileExtensions.Any(e => e.Equals(finalIdentifier, StringComparison.InvariantCultureIgnoreCase)));
if (format != null)
{
// Return a new instance as we want to use instance properties.
newFormat = Activator.CreateInstance(format.GetType()) as ISupportedImageFormat;
if (newFormat != null)
{
// I wish this wasn't hard-coded but there's no way I can

3
src/ImageProcessor.Web/NET45/Processors/Resize.cs

@ -16,7 +16,8 @@ namespace ImageProcessor.Web.Processors
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using ImageProcessor.Core.Common.Extensions;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Imaging;
using ImageProcessor.Processors;

3
src/ImageProcessor.Web/NET45/Processors/Watermark.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Web.Processors
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using ImageProcessor.Core.Common.Extensions;
using ImageProcessor.Common.Extensions;
using ImageProcessor.Imaging;
using ImageProcessor.Processors;
using ImageProcessor.Web.Helpers;

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

3
src/ImageProcessor/Core/Common/Exceptions/ImageFormatException.cs → src/ImageProcessor/Common/Exceptions/ImageFormatException.cs

@ -8,10 +8,9 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Core.Common.Exceptions
namespace ImageProcessor.Common.Exceptions
{
using System;
using System.Runtime.Serialization;
/// <summary>
/// The exception that is thrown when loading the supported image format types has failed.

2
src/ImageProcessor/Core/Common/Exceptions/ImageProcessingException.cs → src/ImageProcessor/Common/Exceptions/ImageProcessingException.cs

@ -8,7 +8,7 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Core.Common.Exceptions
namespace ImageProcessor.Common.Exceptions
{
using System;

2
src/ImageProcessor/Core/Common/Extensions/DoubleExtensions.cs → src/ImageProcessor/Common/Extensions/DoubleExtensions.cs

@ -8,7 +8,7 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Core.Common.Extensions
namespace ImageProcessor.Common.Extensions
{
/// <summary>
/// Encapsulates a series of time saving extension methods to the <see cref="T:System.Double"/> class.

2
src/ImageProcessor/Core/Common/Extensions/IntegerExtensions.cs → src/ImageProcessor/Common/Extensions/IntegerExtensions.cs

@ -8,7 +8,7 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Core.Common.Extensions
namespace ImageProcessor.Common.Extensions
{
using System.Globalization;

6
src/ImageProcessor/Core/Common/Extensions/StringExtensions.cs → src/ImageProcessor/Common/Extensions/StringExtensions.cs

@ -8,10 +8,8 @@
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Core.Common.Extensions
namespace ImageProcessor.Common.Extensions
{
#region Using
using System;
using System.Globalization;
using System.Linq;
@ -19,8 +17,6 @@ namespace ImageProcessor.Core.Common.Extensions
using System.Text;
using System.Text.RegularExpressions;
#endregion
/// <summary>
/// Encapsulates a series of time saving extension methods to the <see cref="T:System.String"/> class.
/// </summary>

3
src/ImageProcessor/Configuration/ImageProcessorBootstrapper.cs

@ -13,7 +13,8 @@ namespace ImageProcessor.Configuration
using System;
using System.Collections.Generic;
using System.Linq;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging.Formats;
/// <summary>

3
src/ImageProcessor/ImageFactory.cs

@ -17,7 +17,8 @@ namespace ImageProcessor
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging;
using ImageProcessor.Imaging.Filters;
using ImageProcessor.Imaging.Formats;

10
src/ImageProcessor/ImageProcessor.csproj

@ -60,12 +60,12 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\ImageProcessorBootstrapper.cs" />
<Compile Include="Core\Common\Exceptions\ImageProcessingException.cs" />
<Compile Include="Core\Common\Extensions\DoubleExtensions.cs" />
<Compile Include="Common\Exceptions\ImageProcessingException.cs" />
<Compile Include="Common\Extensions\DoubleExtensions.cs" />
<Compile Include="Imaging\Formats\GifInfo.cs" />
<Compile Include="Core\Common\Extensions\IntegerExtensions.cs" />
<Compile Include="Core\Common\Extensions\StringExtensions.cs" />
<Compile Include="Core\Common\Exceptions\ImageFormatException.cs" />
<Compile Include="Common\Extensions\IntegerExtensions.cs" />
<Compile Include="Common\Extensions\StringExtensions.cs" />
<Compile Include="Common\Exceptions\ImageFormatException.cs" />
<Compile Include="ImageFactory.cs" />
<Compile Include="Imaging\AnchorPosition.cs" />
<Compile Include="Imaging\ExifPropertyTagType.cs" />

2
src/ImageProcessor/Imaging/Convolution.cs

@ -15,7 +15,7 @@ namespace ImageProcessor.Imaging
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using ImageProcessor.Core.Common.Extensions;
using ImageProcessor.Common.Extensions;
/// <summary>
/// Provides methods for applying blurring and sharpening effects to an image..

4
src/ImageProcessor/Imaging/Filters/ComicMatrixFilter.cs

@ -17,7 +17,9 @@ namespace ImageProcessor.Imaging.Filters
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using ImageProcessor.Core.Common.Extensions;
using ImageProcessor.Common.Extensions;
#endregion
/// <summary>

85
src/ImageProcessor/Imaging/Formats/WebPFormat.cs

@ -21,7 +21,7 @@ namespace ImageProcessor.Imaging.Formats
using System.Runtime.InteropServices;
using System.Text;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
/// <summary>
/// Provides the necessary information to support webp images.
@ -163,6 +163,10 @@ namespace ImageProcessor.Imaging.Formats
memoryStream.Position = stream.Position = 0;
}
}
else
{
throw new ImageFormatException("Unable to encode WebP image.");
}
return image;
}
@ -183,36 +187,52 @@ namespace ImageProcessor.Imaging.Formats
IntPtr ptrData = pinnedWebP.AddrOfPinnedObject();
uint dataSize = (uint)webpData.Length;
Bitmap bitmap = null;
BitmapData bitmapData = null;
IntPtr outputBuffer = IntPtr.Zero;
int width;
int height;
if (WebPGetInfo(ptrData, dataSize, out width, out height) != 1)
{
throw new ImageFormatException("WebP image is corrupted.");
throw new ImageFormatException("WebP image header is corrupted.");
}
// Create a BitmapData and Lock all pixels to be written
Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat);
try
{
// Create a BitmapData and Lock all pixels to be written
bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat);
// Allocate memory for uncompress image
int outputBufferSize = bitmapData.Stride * height;
IntPtr outputBuffer = Marshal.AllocHGlobal(outputBufferSize);
// Allocate memory for uncompress image
int outputBufferSize = bitmapData.Stride * height;
outputBuffer = Marshal.AllocHGlobal(outputBufferSize);
// Uncompress the image
outputBuffer = WebPDecodeBGRAInto(ptrData, dataSize, outputBuffer, outputBufferSize, bitmapData.Stride);
// Uncompress the image
outputBuffer = WebPDecodeBGRAInto(ptrData, dataSize, outputBuffer, outputBufferSize, bitmapData.Stride);
// Write image to bitmap using Marshal
byte[] buffer = new byte[outputBufferSize];
Marshal.Copy(outputBuffer, buffer, 0, outputBufferSize);
Marshal.Copy(buffer, 0, bitmapData.Scan0, outputBufferSize);
if (bitmapData.Scan0 != outputBuffer)
{
throw new ImageFormatException("Failed to decode WebP image with error " + (long)outputBuffer);
}
// Unlock the pixels
bitmap.UnlockBits(bitmapData);
// Write image to bitmap using Marshal
byte[] buffer = new byte[outputBufferSize];
Marshal.Copy(outputBuffer, buffer, 0, outputBufferSize);
Marshal.Copy(buffer, 0, bitmapData.Scan0, outputBufferSize);
}
finally
{
// Unlock the pixels
if (bitmap != null)
{
bitmap.UnlockBits(bitmapData);
}
// Free memory
pinnedWebP.Free();
Marshal.FreeHGlobal(outputBuffer);
// Free memory
pinnedWebP.Free();
Marshal.FreeHGlobal(outputBuffer);
}
return bitmap;
}
@ -235,29 +255,34 @@ namespace ImageProcessor.Imaging.Formats
private static bool EncodeLossly(Bitmap bitmap, int quality, out byte[] webpData)
{
webpData = null;
BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
IntPtr unmanagedData = IntPtr.Zero;
bool encoded;
try
{
BitmapData bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
IntPtr unmanagedData;
// Attempt to lossy encode the image.
int size = WebPEncodeBGRA(bmpData.Scan0, bitmap.Width, bitmap.Height, bmpData.Stride, quality, out unmanagedData);
// Copy image compress data to output array
webpData = new byte[size];
Marshal.Copy(unmanagedData, webpData, 0, size);
encoded = true;
}
catch
{
encoded = false;
}
finally
{
// Unlock the pixels
bitmap.UnlockBits(bmpData);
// Free memory
WebPFree(unmanagedData);
return true;
}
catch
{
return false;
}
return encoded;
}
/// <summary>
@ -335,13 +360,13 @@ namespace ImageProcessor.Imaging.Formats
/// <summary>
/// Frees the unmanaged memory.
/// </summary>
/// <param name="p">
/// <param name="pointer">
/// The pointer.
/// </param>
/// <returns>
/// 1 if success, otherwise error code returned in the case of (a) error(s).
/// </returns>
[DllImport("libwebp.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern int WebPFree(IntPtr p);
private static extern int WebPFree(IntPtr pointer);
}
}

3
src/ImageProcessor/Processors/Alpha.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
/// <summary>
/// Encapsulates methods to change the alpha component of the image to effect its transparency.

3
src/ImageProcessor/Processors/AutoRotate.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Processors
using System;
using System.Collections.Generic;
using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging;
/// <summary>

3
src/ImageProcessor/Processors/BackgroundColor.cs

@ -13,7 +13,8 @@ namespace ImageProcessor.Processors
using System;
using System.Collections.Generic;
using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
/// <summary>
/// Changes the background color of an image.

3
src/ImageProcessor/Processors/Brightness.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
/// <summary>
/// Encapsulates methods to change the brightness component of the image.

3
src/ImageProcessor/Processors/Contrast.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
/// <summary>
/// Encapsulates methods to change the contrast component of the image.

3
src/ImageProcessor/Processors/Crop.cs

@ -15,7 +15,8 @@ namespace ImageProcessor.Processors
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging;
/// <summary>

3
src/ImageProcessor/Processors/Filter.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging.Filters;
/// <summary>

3
src/ImageProcessor/Processors/Flip.cs

@ -13,7 +13,8 @@ namespace ImageProcessor.Processors
using System;
using System.Collections.Generic;
using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
/// <summary>
/// Flips an image horizontally or vertically.

3
src/ImageProcessor/Processors/Format.cs

@ -13,7 +13,8 @@ namespace ImageProcessor.Processors
using System;
using System.Collections.Generic;
using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging.Formats;
/// <summary>

3
src/ImageProcessor/Processors/GaussianBlur.cs

@ -13,7 +13,8 @@ namespace ImageProcessor.Processors
using System;
using System.Collections.Generic;
using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging;
/// <summary>

3
src/ImageProcessor/Processors/GaussianSharpen.cs

@ -13,7 +13,8 @@ namespace ImageProcessor.Processors
using System;
using System.Collections.Generic;
using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging;
/// <summary>

3
src/ImageProcessor/Processors/Quality.cs

@ -13,7 +13,8 @@ namespace ImageProcessor.Processors
using System;
using System.Collections.Generic;
using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
/// <summary>
/// Encapsulates methods to change the quality component of the image.

3
src/ImageProcessor/Processors/Resize.cs

@ -17,7 +17,8 @@ namespace ImageProcessor.Processors
using System.Drawing.Imaging;
using System.Globalization;
using System.Linq;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging;
/// <summary>

3
src/ImageProcessor/Processors/Rotate.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
/// <summary>
/// Encapsulates methods to rotate an image.

3
src/ImageProcessor/Processors/RoundedCorners.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging;
/// <summary>

3
src/ImageProcessor/Processors/Saturation.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
/// <summary>
/// Encapsulates methods to change the saturation component of the image.

3
src/ImageProcessor/Processors/Tint.cs

@ -15,7 +15,8 @@ namespace ImageProcessor.Processors
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
/// <summary>
/// Tints an image with the given color.

3
src/ImageProcessor/Processors/Vignette.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
/// <summary>
/// Encapsulates methods with which to add a vignette image effect to an image.

3
src/ImageProcessor/Processors/Watermark.cs

@ -14,7 +14,8 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Text;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging;
/// <summary>

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.3.0")]
[assembly: AssemblyFileVersion("1.9.3.0")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]

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

@ -4,41 +4,42 @@
<!--<preset name="demo" value="width=300&#038;height=150&#038;bgcolor=transparent"/>-->
</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"/>
<plugin name="Filter" type="ImageProcessor.Processors.Filter, ImageProcessor"/>
<plugin name="Flip" type="ImageProcessor.Processors.Flip, ImageProcessor"/>
<plugin name="Format" type="ImageProcessor.Processors.Format, ImageProcessor"/>
<plugin name="GaussianBlur" type="ImageProcessor.Processors.GaussianBlur, ImageProcessor">
<plugin name="Alpha" type="ImageProcessor.Web.Processors.Alpha, ImageProcessor.Web"/>
<plugin name="AutoRotate" type="ImageProcessor.Web.Processors.AutoRotate, ImageProcessor.Web"/>
<plugin name="BackgroundColor" type="ImageProcessor.Web.Processors.BackgroundColor, ImageProcessor.Web"/>
<plugin name="Brightness" type="ImageProcessor.Web.Processors.Brightness, ImageProcessor.Web"/>
<plugin name="Contrast" type="ImageProcessor.Web.Processors.Contrast, ImageProcessor.Web"/>
<plugin name="Crop" type="ImageProcessor.Web.Processors.Crop, ImageProcessor.Web"/>
<plugin name="Filter" type="ImageProcessor.Web.Processors.Filter, ImageProcessor.Web"/>
<plugin name="Flip" type="ImageProcessor.Web.Processors.Flip, ImageProcessor.Web"/>
<plugin name="Format" type="ImageProcessor.Web.Processors.Format, ImageProcessor.Web"/>
<plugin name="GaussianBlur" type="ImageProcessor.Web.Processors.GaussianBlur, ImageProcessor.Web">
<settings>
<setting key="MaxSize" value="22"/>
<setting key="MaxSigma" value="5.1"/>
<setting key="MaxThreshold" value="100"/>
</settings>
</plugin>
<plugin name="GaussianSharpen" type="ImageProcessor.Processors.GaussianSharpen, ImageProcessor">
<plugin name="GaussianSharpen" type="ImageProcessor.Web.Processors.GaussianSharpen, ImageProcessor.Web">
<settings>
<setting key="MaxSize" value="22"/>
<setting key="MaxSigma" value="5.1"/>
<setting key="MaxThreshold" value="100"/>
</settings>
</plugin>
<plugin name="Quality" type="ImageProcessor.Processors.Quality, ImageProcessor"/>
<plugin name="Resize" type="ImageProcessor.Processors.Resize, ImageProcessor">
<plugin name="Quality" type="ImageProcessor.Web.Processors.Quality, ImageProcessor.Web"/>
<plugin name="Resize" type="ImageProcessor.Web.Processors.Resize, ImageProcessor.Web">
<settings>
<setting key="MaxWidth" value="3000"/>
<setting key="MaxHeight" value="3000"/>
<!--<setting key="RestrictTo" value="width=300height=300,width=300height=300"/>-->
<setting key="MaxWidth" value="5000"/>
<setting key="MaxHeight" value="5000"/>
</settings>
</plugin>
<plugin name="Rotate" type="ImageProcessor.Processors.Rotate, ImageProcessor"/>
<plugin name="RoundedCorners" type="ImageProcessor.Processors.RoundedCorners, ImageProcessor"/>
<plugin name="Saturation" type="ImageProcessor.Processors.Saturation, ImageProcessor"/>
<plugin name="Vignette" type="ImageProcessor.Processors.Vignette, ImageProcessor"/>
<plugin name="Watermark" type="ImageProcessor.Processors.Watermark, ImageProcessor"/>
<plugin name="Rotate" type="ImageProcessor.Web.Processors.Rotate, ImageProcessor.Web"/>
<plugin name="RoundedCorners" type="ImageProcessor.Web.Processors.RoundedCorners, ImageProcessor.Web"/>
<plugin name="Saturation" type="ImageProcessor.Web.Processors.Saturation, ImageProcessor.Web"/>
<plugin name="Tint" type="ImageProcessor.Web.Processors.Tint, ImageProcessor.Web"/>
<plugin name="Vignette" type="ImageProcessor.Web.Processors.Vignette, ImageProcessor.Web"/>
<plugin name="Watermark" type="ImageProcessor.Web.Processors.Watermark, ImageProcessor.Web"/>
</plugins>
</processing>

2
src/TestWebsites/NET45/Test_Website_NET45/Views/Web.config

@ -45,11 +45,11 @@
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />

5
src/TestWebsites/NET45/Test_Website_NET45/Web.config

@ -44,10 +44,15 @@
<httpModules>
<add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<staticContent>
<remove fileExtension=".webp"/>
<mimeMap fileExtension=".webp" mimeType="image/webp" />
</staticContent>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />

2
src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config

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

4
src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/security.config

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<security allowRemoteDownloads="true" timeout="300000" maxBytes="524288" remotePrefix="/remote.axd">
<whiteList>
<add url="http://images.mymovies.net"/>
<add url="images.mymovies.net"/>
<add url="http://maps.googleapis.com" extensionLess="true" imageFormat=".png"/>
<add url="https://fbcdn-profile-"/>
<add url="fbcdn"/>
<add url="http://fbcdn-profile-"/>
<add url="https://profile."/>
<add url="http://profile."/>

Loading…
Cancel
Save