Browse Source

Merging v2 branch

Former-commit-id: eb3a6a13e95738b199275b901f67b420fd5c8d46
af/merge-core
James South 12 years ago
parent
commit
5ec86f60b7
  1. 54
      build/Build.ImageProcessor.Plugins.Cair.proj
  2. 7
      build/Build.bat
  3. 37
      build/NuSpecs/ImageProcessor.Plugins.Cair.nuspec
  4. 60
      build/NuSpecs/ImageProcessor.Plugins.WebP.nuspec
  5. 66
      build/NuSpecs/ImageProcessor.Web.Config.nuspec
  6. 62
      build/NuSpecs/ImageProcessor.Web.nuspec
  7. 50
      build/NuSpecs/ImageProcessor.nuspec
  8. 18
      src/ImageProcessorConsole/Program.cs
  9. 0
      src/ImageProcessorConsole/images/input/night-bridge.png.REMOVED.git-id
  10. 2
      src/ImageProcessorConsole/images/output/2006-citybus.jpg.REMOVED.git-id
  11. 2
      src/ImageProcessorConsole/images/output/2008.jpg.REMOVED.git-id
  12. 2
      src/ImageProcessorConsole/images/output/2012-citybus.jpg.REMOVED.git-id
  13. 2
      src/ImageProcessorConsole/images/output/Arc-de-Triomphe-France.jpg.REMOVED.git-id
  14. 2
      src/ImageProcessorConsole/images/output/Image with gaps.jpg.REMOVED.git-id
  15. 2
      src/ImageProcessorConsole/images/output/arc_de_triomphe_paris_france.jpg.REMOVED.git-id
  16. 2
      src/ImageProcessorConsole/images/output/mountain.jpg.REMOVED.git-id
  17. 2
      src/ImageProcessorConsole/images/output/rotate.jpg.REMOVED.git-id
  18. 2
      src/ImageProcessorConsole/images/output/shutterstock_19173982_Arc_de_triomphe-square1.jpg.REMOVED.git-id
  19. 2
      src/ImageProcessorConsole/images/output/test.jpg.REMOVED.git-id
  20. 47
      src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/CairBootstrapper.cs
  21. 3
      src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/ImageProcessor.Plugins.Cair.csproj
  22. 43
      src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/ContentAwareResizeConvolutionType.cs
  23. 66
      src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/ContentAwareResizeLayer.cs
  24. 53
      src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/OutputType.cs
  25. 76
      src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Processors/ContentAwareResize.cs
  26. 41
      src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Resources/Unmanaged/x86/Usage.txt

54
build/Build.ImageProcessor.Plugins.Cair.proj

@ -0,0 +1,54 @@
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildCommunityTasksPath>.\</MSBuildCommunityTasksPath>
</PropertyGroup>
<Import Project=".\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
<!--
****************************************************
VARIABLES
*****************************************************
-->
<PropertyGroup>
<BuildConfiguration>Release</BuildConfiguration>
<BuildFolder>_BuildOutput\</BuildFolder>
<IncludeSymbols>False</IncludeSymbols>
<BuildFolderAbsolutePath>$(MSBuildProjectDirectory)\$(BuildFolder)</BuildFolderAbsolutePath>
<SolutionBinFolderAbsolutePath>$(BuildFolderAbsolutePath)ImageProcessor.Plugins.Cair\lib\net45</SolutionBinFolderAbsolutePath>
<BuildInputDir>..\src\Plugins\ImageProcessor\ImageProcessor.Plugins.Cair\</BuildInputDir>
</PropertyGroup>
<!--
****************************************************
TARGETS
*****************************************************
-->
<Target Name="Build" DependsOnTargets="BuildImageProcessorPluginsCair">
<Message Text="Build finished" />
</Target>
<Target Name="BuildImageProcessorPluginsCair" DependsOnTargets="SetVersionNumber">
<Message Text="Compiling ImageProcessor.Plugins.Cair project to build\$(BuildFolder)" Importance="High" />
<MSBuild Projects="$(BuildInputDir)\ImageProcessor.Plugins.Cair.csproj" Properties="WarningLevel=0;Configuration=$(BuildConfiguration);PipelineDependsOnBuild=False;OutDir=$(SolutionBinFolderAbsolutePath);" Targets="Clean;Rebuild;" BuildInParallel="False" ToolsVersion="4.0" UnloadProjectsOnCompletion="False" />
<Message Text="Finished compiling project" Importance="High" />
</Target>
<Target Name="SetVersionNumber" Condition="'$(BUILD_RELEASE)'!=''">
<Message Text="Creating Version File: $(BUILD_RELEASE)"/>
<ItemGroup>
<AssemblyFiles Include="$(BuildInputDir)Properties\AssemblyInfo.cs;" />
</ItemGroup>
<FileUpdate Files="@(AssemblyFiles)"
Multiline="true"
Singleline="false"
Regex="(AssemblyVersion|AssemblyFileVersionAttribute|AssemblyFileVersion)\(&quot;([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)?&quot;\)"
ReplacementText="$1(&quot;$(BUILD_RELEASE)&quot;)" />
</Target>
</Project>

7
build/Build.bat

@ -4,8 +4,11 @@ SET version=2.0.1.0
SET webversion=4.0.0.0
SET webconfigversion=2.0.0.0
SET webppluginversion=1.0.1.0
SET cairpluginversion=1.0.0.0
ECHO Building ImageProcessor %version%, ImageProcessor.Web %webversion%, ImageProcessor.Web.Config %webconfigversion%, and ImageProcessor.Plugins.WebP %webppluginversion%
ECHO Building ImageProcessor %version%, ImageProcessor.Web %webversion%, ImageProcessor.Web.Config %webconfigversion%
ECHO Building ImageProcessor.Plugins.WebP %webppluginversion%, ImageProcessor.Plugins.Cair %cairpluginversion%
ECHO Removing _BuildOutput directory so everything is nice and clean
RD _BuildOutput /q /s
@ -13,12 +16,14 @@ RD _BuildOutput /q /s
%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "Build.ImageProcessor.proj" /p:BUILD_RELEASE=%version% /p:BUILD_COMMENT=%comment%
%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "Build.ImageProcessor.Web.proj" /p:BUILD_RELEASE=%webversion% /p:BUILD_COMMENT=%comment%
%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "Build.ImageProcessor.Plugins.WebP.proj" /p:BUILD_RELEASE=%webppluginversion% /p:BUILD_COMMENT=%comment%
%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "Build.ImageProcessor.Plugins.Cair.proj" /p:BUILD_RELEASE=%cairpluginversion% /p:BUILD_COMMENT=%comment%
ECHO Packing the NuGet release files
..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.nuspec -Version %version%
..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.Web.nuspec -Version %webversion%
..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.Web.Config.nuspec -Version %webconfigversion%
..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.Plugins.WebP.nuspec -Version %webppluginversion%
..\src\.nuget\NuGet.exe pack NuSpecs\ImageProcessor.Plugins.Cair.nuspec -Version %cairpluginversion%
PAUSE
IF ERRORLEVEL 1 GOTO :showerror

37
build/NuSpecs/ImageProcessor.Plugins.Cair.nuspec

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>ImageProcessor.Plugins.Cair</id>
<version>1.0.0.0</version>
<title>ImageProcessor.Plugins.Cair</title>
<authors>James South</authors>
<owners>James South</owners>
<projectUrl>http://imageprocessor.org</projectUrl>
<iconUrl>http://raw.githubusercontent.com/JimBobSquarePants/ImageProcessor/master/build/content/imageprocessor.128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>
Adds support to ImageProcessor for Content Aware Image Resizing.
If you use ImageProcessor please get in touch via my twitter @james_m_south
Feedback is always welcome
</description>
<summary>Adds support to ImageProcessor for Content Aware Image Resizing.</summary>
<releaseNotes />
<copyright>James South</copyright>
<language>en-GB</language>
<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 WebP Tiff Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF Cair SeamCarving
</tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="ImageProcessor" version="2.0.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="..\_BuildOutput\ImageProcessor.Plugins.Cair\lib\net45\ImageProcessor.Plugins.Cair.dll" target="lib\net45\ImageProcessor.Plugins.Cair.dll" />
</files>
</package>

60
build/NuSpecs/ImageProcessor.Plugins.WebP.nuspec

@ -1,32 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>ImageProcessor.Plugins.WebP</id>
<version>1.0.0.0</version>
<title>ImageProcessor.Plugins.WebP</title>
<authors>James South</authors>
<owners>James South</owners>
<projectUrl>http://imageprocessor.org</projectUrl>
<iconUrl>http://raw.githubusercontent.com/JimBobSquarePants/ImageProcessor/master/build/content/imageprocessor.128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Adds support to ImageProcessor for the WebP image format.
<metadata>
<id>ImageProcessor.Plugins.WebP</id>
<version>1.0.0.0</version>
<title>ImageProcessor.Plugins.WebP</title>
<authors>James South</authors>
<owners>James South</owners>
<projectUrl>http://imageprocessor.org</projectUrl>
<iconUrl>http://raw.githubusercontent.com/JimBobSquarePants/ImageProcessor/master/build/content/imageprocessor.128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>
Adds support to ImageProcessor for the WebP image format.
If you use ImageProcessor please get in touch via my twitter @james_m_south
If you use ImageProcessor please get in touch via my twitter @james_m_south
Feedback is always welcome</description>
<summary>Adds support to ImageProcessor for the WebP image format.</summary>
<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 WebP Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated</tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="ImageProcessor" version="2.0.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="..\_BuildOutput\ImageProcessor.Plugins.WebP\lib\net45\ImageProcessor.Plugins.WebP.dll" target="lib\net45\ImageProcessor.Plugins.WebP.dll" />
<file src="..\content\ImageProcessor.Plugins.WebP\web.config.transform" target="content\web.config.transform" />
</files>
Feedback is always welcome
</description>
<summary>Adds support to ImageProcessor for the WebP image format.</summary>
<releaseNotes />
<copyright>James South</copyright>
<language>en-GB</language>
<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 WebP Tiff Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF Cair SeamCarving
</tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="ImageProcessor" version="2.0.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="..\_BuildOutput\ImageProcessor.Plugins.WebP\lib\net45\ImageProcessor.Plugins.WebP.dll" target="lib\net45\ImageProcessor.Plugins.WebP.dll" />
<file src="..\content\ImageProcessor.Plugins.WebP\web.config.transform" target="content\web.config.transform" />
</files>
</package>

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

@ -1,35 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>ImageProcessor.Web.Config</id>
<version>1.1.0.0</version>
<title>ImageProcessor.Web.Config</title>
<authors>James South</authors>
<owners>James South</owners>
<projectUrl>http://imageprocessor.org</projectUrl>
<iconUrl>http://raw.githubusercontent.com/JimBobSquarePants/ImageProcessor/master/build/content/imageprocessor.128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Adds configuration to your ImageProcessor.Web solution to allow you to override the default settings.
<metadata>
<id>ImageProcessor.Web.Config</id>
<version>1.1.0.0</version>
<title>ImageProcessor.Web.Config</title>
<authors>James South</authors>
<owners>James South</owners>
<projectUrl>http://imageprocessor.org</projectUrl>
<iconUrl>http://raw.githubusercontent.com/JimBobSquarePants/ImageProcessor/master/build/content/imageprocessor.128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>
Adds configuration to your ImageProcessor.Web solution to allow you to override the default settings.
If you use ImageProcessor please get in touch via my twitter @james_m_south
If you use ImageProcessor please get in touch via my twitter @james_m_south
Feedback is always welcome</description>
<summary>ImageProcessor.Web configuration settings for ASP.NET websites.</summary>
<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 WebP Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated</tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
<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\Configuration\Resources\cache.config" target="content\config\imageprocessor\cache.config" />
<file src="..\..\src\ImageProcessor.Web\Configuration\Resources\processing.config" target="content\config\imageprocessor\processing.config" />
<file src="..\..\src\ImageProcessor.Web\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>
Feedback is always welcome
</description>
<summary>ImageProcessor.Web configuration settings for ASP.NET websites.</summary>
<releaseNotes />
<copyright>James South</copyright>
<language>en-GB</language>
<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 WebP Tiff Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF Cair SeamCarving
</tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
<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\Configuration\Resources\cache.config" target="content\config\imageprocessor\cache.config" />
<file src="..\..\src\ImageProcessor.Web\Configuration\Resources\processing.config" target="content\config\imageprocessor\processing.config" />
<file src="..\..\src\ImageProcessor.Web\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>

62
build/NuSpecs/ImageProcessor.Web.nuspec

@ -1,34 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>ImageProcessor.Web</id>
<version>3.2.0.0</version>
<title>ImageProcessor.Web</title>
<authors>James South</authors>
<owners>James South</owners>
<projectUrl>http://imageprocessor.org</projectUrl>
<iconUrl>http://raw.githubusercontent.com/JimBobSquarePants/ImageProcessor/master/build/content/imageprocessor.128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>ImageProcessor.Web adds a configurable HttpModule to your website which allows on-the-fly processing of image files. The module also comes with a file and browser based cache that can handle millions of images, increasing your processing output and saving precious server memory.
<metadata>
<id>ImageProcessor.Web</id>
<version>3.2.0.0</version>
<title>ImageProcessor.Web</title>
<authors>James South</authors>
<owners>James South</owners>
<projectUrl>http://imageprocessor.org</projectUrl>
<iconUrl>http://raw.githubusercontent.com/JimBobSquarePants/ImageProcessor/master/build/content/imageprocessor.128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>
ImageProcessor.Web adds a configurable HttpModule to your website which allows on-the-fly processing of image files. The module also comes with a file and browser based cache that can handle millions of images, increasing your processing output and saving precious server memory.
Methods include: Resize, Rotate, Rounded Corners, Flip, Crop, Watermark, Filter, Saturation, Brightness, Contrast, Quality, Format, Vignette, Gaussian Blur, Gaussian Sharpen, and Transparency.
Methods include: Resize, Rotate, Rounded Corners, Flip, Crop, Watermark, Filter, Saturation, Brightness, Contrast, Quality, Format, Vignette, Gaussian Blur, Gaussian Sharpen, and Transparency.
If you use ImageProcessor please get in touch via my twitter @james_m_south
If you use ImageProcessor please get in touch via my twitter @james_m_south
Feedback is always welcome</description>
<summary>An extension to ImageProcessor that allows on-the-fly processing of image files in an ASP.NET website</summary>
<releaseNotes />
<copyright>James South</copyright>
<language>en-GB</language>
<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 WebP Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF</tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="ImageProcessor" version="2.0.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="..\content\ImageProcessor.Web\web.config.transform" target="content\web.config.transform" />
<file src="..\_BuildOutput\ImageProcessor.Web\lib\net45\ImageProcessor.Web.dll" target="lib\net45\ImageProcessor.Web.dll" />
</files>
Feedback is always welcome
</description>
<summary>An extension to ImageProcessor that allows on-the-fly processing of image files in an ASP.NET website</summary>
<releaseNotes />
<copyright>James South</copyright>
<language>en-GB</language>
<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 WebP Tiff Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF Cair SeamCarving
</tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="ImageProcessor" version="2.0.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="..\content\ImageProcessor.Web\web.config.transform" target="content\web.config.transform" />
<file src="..\_BuildOutput\ImageProcessor.Web\lib\net45\ImageProcessor.Web.dll" target="lib\net45\ImageProcessor.Web.dll" />
</files>
</package>

50
build/NuSpecs/ImageProcessor.nuspec

@ -1,28 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>ImageProcessor</id>
<version>1.9.0.0</version>
<title>ImageProcessor</title>
<authors>James South</authors>
<owners>James South</owners>
<projectUrl>http://imageprocessor.org</projectUrl>
<iconUrl>http://raw.githubusercontent.com/JimBobSquarePants/ImageProcessor/master/build/content/imageprocessor.128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Image Processor is an easy to use and extend processing library written in C#. Its fluent API makes common imaging tasks very simple to perform.
<metadata>
<id>ImageProcessor</id>
<version>1.9.0.0</version>
<title>ImageProcessor</title>
<authors>James South</authors>
<owners>James South</owners>
<projectUrl>http://imageprocessor.org</projectUrl>
<iconUrl>http://raw.githubusercontent.com/JimBobSquarePants/ImageProcessor/master/build/content/imageprocessor.128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>
Image Processor is an easy to use and extend processing library written in C#. Its fluent API makes common imaging tasks very simple to perform.
Methods include; Resize, Rotate, Rounded Corners, Flip, Crop, Watermark, Filter, Saturation, Brightness, Contrast, Quality, Format, Vignette, Gaussian Blur, Gaussian Sharpen, and Transparency.
Methods include; Resize, Rotate, Rounded Corners, Flip, Crop, Watermark, Filter, Saturation, Brightness, Contrast, Quality, Format, Vignette, Gaussian Blur, Gaussian Sharpen, and Transparency.
If you use ImageProcessor please get in touch on my twitter @james_m_south.
If you use ImageProcessor please get in touch on my twitter @james_m_south.
Feedback is always welcome.</description>
<summary>A library for manipulating image files written in C#.</summary>
<releaseNotes />
<copyright>James South</copyright>
<language>en-GB</language>
<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 WebP Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF</tags>
</metadata>
<files>
<file src="..\_BuildOutput\ImageProcessor\lib\net45\ImageProcessor.dll" target="lib\net45\ImageProcessor.dll" />
</files>
Feedback is always welcome.
</description>
<summary>A library for manipulating image files written in C#.</summary>
<releaseNotes />
<copyright>James South</copyright>
<language>en-GB</language>
<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 WebP Tiff Fluent GDI Gaussian Blur Sharpen Tint Quantizer Animated EXIF Cair SeamCarving
</tags>
</metadata>
<files>
<file src="..\_BuildOutput\ImageProcessor\lib\net45\ImageProcessor.dll" target="lib\net45\ImageProcessor.dll" />
</files>
</package>

18
src/ImageProcessorConsole/Program.cs

@ -12,11 +12,13 @@ namespace ImageProcessorConsole
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using ImageProcessor;
using ImageProcessor.Plugins.Cair;
using ImageProcessor.Plugins.Cair.Imaging;
/// <summary>
/// The program.
@ -48,6 +50,11 @@ namespace ImageProcessorConsole
{
byte[] photoBytes = File.ReadAllBytes(fileInfo.FullName);
Console.WriteLine("Processing: " + fileInfo.Name);
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
// ImageProcessor
using (MemoryStream inStream = new MemoryStream(photoBytes))
{
@ -55,15 +62,24 @@ namespace ImageProcessorConsole
{
Size size = new Size(800, 0);
ContentAwareResizeLayer layer = new ContentAwareResizeLayer(size)
{
ConvolutionType = ConvolutionType.Sobel
};
// Load, resize, set the format and quality and save an image.
imageFactory.Load(inStream)
//.BackgroundColor(Color.White)
//.Resize(new Size((int)(size.Width * 1.1), 0))
.ContentAwareResize(size)
.ContentAwareResize(layer)
//.Constrain(size)
.Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name)));
stopwatch.Stop();
}
}
Console.WriteLine("Processed: " + fileInfo.Name + " in " + stopwatch.ElapsedMilliseconds + "ms");
}
}

0
src/ImageProcessorConsole/images/input/night-bridge.jpg.REMOVED.git-id → src/ImageProcessorConsole/images/input/night-bridge.png.REMOVED.git-id

2
src/ImageProcessorConsole/images/output/2006-citybus.jpg.REMOVED.git-id

@ -1 +1 @@
33f7e25da5675197f18bb2fa2c9fe5fa366e84ec
c6cb11afaf9fdb9181772246e5c873d8f7d1b99c

2
src/ImageProcessorConsole/images/output/2008.jpg.REMOVED.git-id

@ -1 +1 @@
f24f17627804b11d823240d49c91ec17fb7fd55d
10b48cac44776a023df7585ba2c68c3f51b0f803

2
src/ImageProcessorConsole/images/output/2012-citybus.jpg.REMOVED.git-id

@ -1 +1 @@
def19dd7469cf2eba1f595e7263d9d48fda85825
e631eb3491496bb83f99cd41a752f79c9d7f6830

2
src/ImageProcessorConsole/images/output/Arc-de-Triomphe-France.jpg.REMOVED.git-id

@ -1 +1 @@
8cf61b55acca1a3d1a69177ddc439685ee0ba192
782056919992bb7e453eeee5d9c0034e03b57506

2
src/ImageProcessorConsole/images/output/Image with gaps.jpg.REMOVED.git-id

@ -1 +1 @@
629284a6f834f5d1cf185e3603a50c484dd9121a
1d9ded0201edcd248140b4ec02f69ccdb4b539e5

2
src/ImageProcessorConsole/images/output/arc_de_triomphe_paris_france.jpg.REMOVED.git-id

@ -1 +1 @@
3d652e0628f2042e7aca0751384ba21f1182ef5f
2880457cc09cd2897b5f9f377807ec22f8f83013

2
src/ImageProcessorConsole/images/output/mountain.jpg.REMOVED.git-id

@ -1 +1 @@
1c48519b2675b9dd90e8e95d6421148b25b8c317
34dcced6c7c3e4dd6fae239eba8eddef6234028d

2
src/ImageProcessorConsole/images/output/rotate.jpg.REMOVED.git-id

@ -1 +1 @@
a0aa8338f74f3539c2531f43fa9027a3ce0a39fb
de6754762f7705f9109ea364f42ca128e454e853

2
src/ImageProcessorConsole/images/output/shutterstock_19173982_Arc_de_triomphe-square1.jpg.REMOVED.git-id

@ -1 +1 @@
04f6093d3345a4c8b48333c32972753dd0949730
24db72130626e81b9a4262c891dd28e6d97e5a96

2
src/ImageProcessorConsole/images/output/test.jpg.REMOVED.git-id

@ -1 +1 @@
f7b1543810ada7598773d6ee31bc7c0c20afaa9f
4885438f0b97e3aae59d6e214b5ec455358ae225

47
src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/CairBootstrapper.cs

@ -32,12 +32,12 @@ namespace ImageProcessor.Plugins.Cair
/// <summary>
/// Gets the cair path.
/// </summary>
public static string CairPath { get; private set; }
public static string CairExecutablePath { get; private set; }
/// <summary>
/// Gets the cair image path.
/// Gets the cair base path.
/// </summary>
public static string CairImagePath { get; private set; }
public static string CairPath { get; private set; }
/// <summary>
/// Registers the embedded CAIR executable.
@ -47,12 +47,17 @@ namespace ImageProcessor.Plugins.Cair
// None of the tools used here are called using dllimport so we don't go through the normal registration channel.
string folder = ImageProcessorBootstrapper.Instance.NativeBinaryFactory.Is64BitEnvironment ? "x64" : "x86";
Assembly assembly = Assembly.GetExecutingAssembly();
string targetBasePath = new Uri(assembly.Location).LocalPath;
string multithreaderTargetPath = Path.GetFullPath(Path.Combine(targetBasePath, "..\\" + folder + "\\" + "pthreadVSE2.dll"));
CairPath = Path.GetFullPath(Path.Combine(new Uri(assembly.Location).LocalPath, "..\\" + folder + "\\imageprocessor.cair\\"));
CairExecutablePath = Path.Combine(CairPath, "CAIR.exe");
string multithreaderTargetPath = Path.Combine(CairPath, "pthreadVSE2.dll");
// Set the global variable.
CairPath = Path.GetFullPath(Path.Combine(targetBasePath, "..\\" + folder + "\\" + "CAIR.exe"));
CairImagePath = Path.GetFullPath(Path.Combine(targetBasePath, "..\\" + folder + "\\" + "cairimages\\"));
// Create the folder for storing temporary images.
// ReSharper disable once AssignNullToNotNullAttribute
DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(CairPath));
if (!directoryInfo.Exists)
{
directoryInfo.Create();
}
// Get the resources and copy them across.
const string CairResourcePath = "ImageProcessor.Plugins.Cair.Resources.Unmanaged.x86.CAIR.exe";
@ -64,13 +69,6 @@ namespace ImageProcessor.Plugins.Cair
{
if (resourceStream != null)
{
// ReSharper disable once AssignNullToNotNullAttribute
DirectoryInfo threaderDirectoryInfo = new DirectoryInfo(Path.GetDirectoryName(multithreaderTargetPath));
if (!threaderDirectoryInfo.Exists)
{
threaderDirectoryInfo.Create();
}
using (FileStream fileStream = File.OpenWrite(multithreaderTargetPath))
{
resourceStream.CopyTo(fileStream);
@ -83,27 +81,12 @@ namespace ImageProcessor.Plugins.Cair
{
if (resourceStream != null)
{
// ReSharper disable once AssignNullToNotNullAttribute
DirectoryInfo cairDirectoryInfo = new DirectoryInfo(Path.GetDirectoryName(CairPath));
if (!cairDirectoryInfo.Exists)
{
cairDirectoryInfo.Create();
}
using (FileStream fileStream = File.OpenWrite(CairPath))
using (FileStream fileStream = File.OpenWrite(CairExecutablePath))
{
resourceStream.CopyTo(fileStream);
}
}
}
// Lastly create the image folder for storing temporary images.
// ReSharper disable once AssignNullToNotNullAttribute
DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(CairImagePath));
if (!directoryInfo.Exists)
{
directoryInfo.Create();
}
}
}
}
}

3
src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/ImageProcessor.Plugins.Cair.csproj

@ -45,9 +45,10 @@
<ItemGroup>
<Compile Include="CairBootstrapper.cs" />
<Compile Include="ImageFactoryExtensions.cs" />
<Compile Include="Imaging\ContentAwareResizeConvolutionType.cs" />
<Compile Include="Imaging\ContentAwareResizeLayer.cs" />
<Compile Include="Imaging\ConvolutionType.cs" />
<Compile Include="Imaging\EnergyFunction.cs" />
<Compile Include="Imaging\OutputType.cs" />
<Compile Include="Processors\ContentAwareResize.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

43
src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/ContentAwareResizeConvolutionType.cs

@ -1,43 +0,0 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ContentAwareResizeConvolutionType.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Provides enumeration of the content aware resize convolution types.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Plugins.Cair.Imaging
{
/// <summary>
/// Provides enumeration of the content aware resize convolution types.
/// </summary>
public enum ContentAwareResizeConvolutionType
{
/// <summary>
/// The Prewitt kernel convolution type.
/// </summary>
Prewitt = 0,
/// <summary>
/// The V1 kernel convolution type.
/// </summary>
V1 = 1,
/// <summary>
/// The VSquare kernel convolution type.
/// </summary>
VSquare = 2,
/// <summary>
/// The Sobel kernel convolution type.
/// </summary>
Sobel = 3,
/// <summary>
/// The Laplacian kernel convolution type.
/// </summary>
Laplacian = 4
}
}

66
src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/ContentAwareResizeLayer.cs

@ -20,7 +20,7 @@ namespace ImageProcessor.Plugins.Cair.Imaging
/// <summary>
/// The convolution type to apply to the layer.
/// </summary>
private ContentAwareResizeConvolutionType convolutionType = ContentAwareResizeConvolutionType.Prewitt;
private ConvolutionType convolutionType = ConvolutionType.Prewitt;
/// <summary>
/// The energy function to apply to the layer.
@ -28,14 +28,14 @@ namespace ImageProcessor.Plugins.Cair.Imaging
private EnergyFunction energyFunction = EnergyFunction.Forward;
/// <summary>
/// Whether to assign multiple threads to the resizing method.
/// The expected output type.
/// </summary>
private bool parallelize = true;
private OutputType outputType = OutputType.Cair;
/// <summary>
/// Whether to pre-scale the image to reduce errors in the output.
/// Whether to assign multiple threads to the resizing method.
/// </summary>
private bool prescale = true;
private bool parallelize = true;
/// <summary>
/// The timeout in milliseconds to attempt to resize for.
@ -53,15 +53,10 @@ namespace ImageProcessor.Plugins.Cair.Imaging
this.Size = size;
}
/// <summary>
/// Gets or sets the size.
/// </summary>
public Size Size { get; set; }
/// <summary>
/// Gets or sets the content aware resize convolution type (Default ContentAwareResizeConvolutionType.Prewitt).
/// </summary>
public ContentAwareResizeConvolutionType ConvolutionType
public ConvolutionType ConvolutionType
{
get
{
@ -91,36 +86,52 @@ namespace ImageProcessor.Plugins.Cair.Imaging
}
/// <summary>
/// Gets or sets a value indicating whether to assign multiple threads to the resizing method.
/// (Default true)
/// Gets or sets the expected output type.
/// </summary>
public bool Parallelize
public OutputType OutputType
{
get
{
return this.parallelize;
return this.outputType;
}
set
{
this.parallelize = value;
this.outputType = value;
}
}
/// <summary>
/// Gets or sets a value indicating whether to pre-scale the image to reduce errors in the output.
/// Gets or sets the size.
/// </summary>
public Size Size { get; set; }
/// <summary>
/// Gets or sets the the file path to a bitmap file that provides weight indicators specified using
/// color to guide preservation of image portions during carving.
/// <remarks>
/// The following colors define weight guidance.
/// &#10; <see cref="Color.Green"/> - Protect the weight.
/// &#10; <see cref="Color.Red"/> - Remove the weight.
/// &#10; <see cref="Color.Black"/> - No weight.
/// </remarks>
/// </summary>
public string WeightPath { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to assign multiple threads to the resizing method.
/// (Default true)
/// </summary>
public bool PreScale
public bool Parallelize
{
get
{
return this.prescale;
return this.parallelize;
}
set
{
this.prescale = value;
this.parallelize = value;
}
}
@ -162,7 +173,12 @@ namespace ImageProcessor.Plugins.Cair.Imaging
}
return this.Size == resizeLayer.Size
&& this.ConvolutionType == resizeLayer.ConvolutionType;
&& this.ConvolutionType == resizeLayer.ConvolutionType
&& this.EnergyFunction == resizeLayer.EnergyFunction
&& this.OutputType == resizeLayer.OutputType
&& this.Parallelize == resizeLayer.Parallelize
&& this.Timeout == resizeLayer.Timeout
&& this.WeightPath == resizeLayer.WeightPath;
}
/// <summary>
@ -173,7 +189,13 @@ namespace ImageProcessor.Plugins.Cair.Imaging
/// </returns>
public override int GetHashCode()
{
return this.Size.GetHashCode() + this.ConvolutionType.GetHashCode();
return this.Size.GetHashCode() +
this.ConvolutionType.GetHashCode() +
this.EnergyFunction.GetHashCode() +
this.OutputType.GetHashCode() +
this.Parallelize.GetHashCode() +
this.Timeout.GetHashCode() +
this.WeightPath.GetHashCode();
}
}
}

53
src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/OutputType.cs

@ -0,0 +1,53 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="OutputType.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Enumerates the output type to produce.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Plugins.Cair.Imaging
{
/// <summary>
/// Enumerates the output type to produce.
/// </summary>
public enum OutputType
{
/// <summary>
/// Output the result as a carved image. The default action.
/// </summary>
Cair = 0,
/// <summary>
/// Output the result as a greyscale image.
/// </summary>
Grayscale = 1,
/// <summary>
/// Output the result highlighting the detected edges.
/// </summary>
Edge = 2,
/// <summary>
/// Output the result highlighting the vertical energy patterns.
/// </summary>
VerticalEnergy = 3,
/// <summary>
/// Output the result highlighting the vertical energy patterns.
/// </summary>
HorizontalEnergy = 4,
/// <summary>
/// Appears to do nothing.
/// </summary>
Removal = 5,
/// <summary>
/// Output the result as a carved image with the focus on high quality output over speed.
/// </summary>
CairHighDefinition = 6
}
}

76
src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Processors/ContentAwareResize.cs

@ -19,7 +19,6 @@ namespace ImageProcessor.Plugins.Cair.Processors
using System.IO;
using ImageProcessor.Common.Exceptions;
using ImageProcessor.Imaging;
using ImageProcessor.Plugins.Cair.Imaging;
using ImageProcessor.Processors;
@ -69,17 +68,14 @@ namespace ImageProcessor.Plugins.Cair.Processors
string fileName = Guid.NewGuid().ToString();
// Use bmp's as the temporary files since they are lossless and support transparency.
string sourcePath = Path.Combine(CairBootstrapper.CairImagePath, fileName + ".bmp");
string resizedPath = Path.Combine(CairBootstrapper.CairImagePath, fileName + "-r.bmp");
string sourcePath = Path.Combine(CairBootstrapper.CairPath, fileName + ".bmp");
string resizedPath = Path.Combine(CairBootstrapper.CairPath, fileName + "-r.bmp");
// Gather the parameters.
int width = this.DynamicParameter.Size.Width ?? 0;
int height = this.DynamicParameter.Size.Height ?? 0;
ContentAwareResizeConvolutionType convolutionType = this.DynamicParameter.ConvolutionType;
EnergyFunction energyFunction = this.DynamicParameter.EnergyFunction;
bool prescale = this.DynamicParameter.PreScale;
bool parallelize = this.DynamicParameter.Parallelize;
int timeout = this.DynamicParameter.Timeout ?? 60000;
ContentAwareResizeLayer layer = (ContentAwareResizeLayer)this.DynamicParameter;
int width = layer.Size.Width;
int height = layer.Size.Height;
int timeout = layer.Timeout > 0 ? layer.Timeout : 60000;
int defaultMaxWidth;
int defaultMaxHeight;
@ -115,48 +111,28 @@ namespace ImageProcessor.Plugins.Cair.Processors
if (width > 0 && height > 0 && width <= maxWidth && height <= maxHeight)
{
if (prescale)
{
if (width < image.Width || height < image.Height)
{
int preWidth = Math.Min(image.Width, width + 50); //(int)Math.Ceiling(width * 1.25));
ResizeLayer layer = new ResizeLayer(new Size(preWidth, 0));
Dictionary<string, string> resizeSettings = new Dictionary<string, string>
{
{
"MaxWidth", image.Width.ToString("G")
},
{
"MaxHeight", image.Height.ToString("G")
}
};
Resize resize = new Resize { DynamicParameter = layer, Settings = resizeSettings };
image = resize.ProcessImage(factory);
}
}
// Save the temporary bitmap.
image.Save(sourcePath, ImageFormat.Bmp);
// Process the image using the CAIR executable.
string arguments = string.Format(
" -I \"{0}\" -O \"{1}\" -C {2} -X {3} -Y {4} -E {5} -T {6}",
" -I \"{0}\" -O \"{1}\" -C {2} -X {3} -Y {4} -E {5} -T {6} -R {7}",
sourcePath,
resizedPath,
(int)convolutionType,
(int)layer.ConvolutionType,
width,
height,
(int)energyFunction,
parallelize ? Math.Min(4, Environment.ProcessorCount) : 1);
bool success = this.ProcessCairImage(arguments, timeout);
(int)layer.EnergyFunction,
layer.Parallelize ? Math.Min(4, Environment.ProcessorCount) : 1,
(int)layer.OutputType);
if (!success)
if (!string.IsNullOrWhiteSpace(layer.WeightPath))
{
throw new ImageProcessingException(
"Error processing image with " + this.GetType().Name + " due to timeout.");
arguments = string.Format("{0} -W {1}", arguments, layer.WeightPath);
}
this.ProcessCairImage(arguments, timeout);
// Assign the new image.
newImage = new Bitmap(resizedPath);
newImage.MakeTransparent();
@ -202,13 +178,10 @@ namespace ImageProcessor.Plugins.Cair.Processors
/// <param name="timeout">
/// The time in milliseconds to attempt to resize the image for.
/// </param>
/// <returns>
/// The <see cref="bool"/>.
/// </returns>
private bool ProcessCairImage(string arguments, int timeout)
private void ProcessCairImage(string arguments, int timeout)
{
// Set up and start a new process to resize the image.
ProcessStartInfo start = new ProcessStartInfo(CairBootstrapper.CairPath, arguments)
ProcessStartInfo start = new ProcessStartInfo(CairBootstrapper.CairExecutablePath, arguments)
{
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
@ -222,18 +195,21 @@ namespace ImageProcessor.Plugins.Cair.Processors
{
if (process != null)
{
bool result = process.WaitForExit(timeout);
if (!result)
if (!process.WaitForExit(timeout))
{
process.Kill();
throw new ImageProcessingException("Error processing image with " + this.GetType().Name + " due to timeout.");
}
return result;
string output = string.Format(" {0} {1}", process.StandardError.ReadToEnd(), process.StandardOutput.ReadToEnd());
if (process.ExitCode != 0)
{
throw new ImageProcessingException("Error processing image with " + this.GetType().Name + output);
}
}
}
return false;
}
}
}

41
src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Resources/Unmanaged/x86/Usage.txt

@ -0,0 +1,41 @@
CAIR CLI Usage:
cair -I <input_file>
Other options:
-O <output_file>
Default: Dependent on operation
-W <weight_file>
Bitmap with: Black- no weight
Green- Protect weight
Red- Remove weight
Default: Weights are all zero
-S <weight_scale>
Default: 100,000
-X <goal_x>
Default: Source image width
-Y <goal_y>
Default: Source image height
-R <expected_result>
CAIR: 0
Grayscale: 1
Edge: 2
Vertical Energy: 3
Horizontal Energy: 4
Removal: 5
CAIR_HD: 6
Default: CAIR
-C <convoluton_type>
Prewitt: 0
V1: 1
V_SQUARE: 2
Sobel: 3
Laplacian: 4
Default: Prewitt
-E <energy_type>
Backward: 0
Forward: 1
Default: Backward
-T <thread_count>
Default : CAIR_NUM_THREADS (4)
Loading…
Cancel
Save