diff --git a/src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/ContentAwareResizeLayer.cs b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/ContentAwareResizeLayer.cs
index c7a48a30e..c8b5dc02f 100644
--- a/src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/ContentAwareResizeLayer.cs
+++ b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Imaging/ContentAwareResizeLayer.cs
@@ -53,11 +53,6 @@ namespace ImageProcessor.Plugins.Cair.Imaging
this.Size = size;
}
- ///
- /// Gets or sets the size.
- ///
- public Size Size { get; set; }
-
///
/// Gets or sets the content aware resize convolution type (Default ContentAwareResizeConvolutionType.Prewitt).
///
@@ -106,6 +101,23 @@ namespace ImageProcessor.Plugins.Cair.Imaging
}
}
+ ///
+ /// Gets or sets the size.
+ ///
+ public Size Size { get; set; }
+
+ ///
+ /// 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.
+ ///
+ /// The following colors define weight guidance.
+ ///
- Protect the weight.
+ ///
- Remove the weight.
+ ///
- No weight.
+ ///
+ ///
+ public string WeightPath { get; set; }
+
///
/// Gets or sets a value indicating whether to assign multiple threads to the resizing method.
/// (Default true)
@@ -165,7 +177,8 @@ namespace ImageProcessor.Plugins.Cair.Imaging
&& this.EnergyFunction == resizeLayer.EnergyFunction
&& this.OutputType == resizeLayer.OutputType
&& this.Parallelize == resizeLayer.Parallelize
- && this.Timeout == resizeLayer.Timeout;
+ && this.Timeout == resizeLayer.Timeout
+ && this.WeightPath == resizeLayer.WeightPath;
}
///
@@ -181,7 +194,8 @@ namespace ImageProcessor.Plugins.Cair.Imaging
this.EnergyFunction.GetHashCode() +
this.OutputType.GetHashCode() +
this.Parallelize.GetHashCode() +
- this.Timeout.GetHashCode();
+ this.Timeout.GetHashCode() +
+ this.WeightPath.GetHashCode();
}
}
}
diff --git a/src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Processors/ContentAwareResize.cs b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Processors/ContentAwareResize.cs
index 533b86fe1..2f34eca57 100644
--- a/src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Processors/ContentAwareResize.cs
+++ b/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;
@@ -76,9 +75,6 @@ namespace ImageProcessor.Plugins.Cair.Processors
ContentAwareResizeLayer layer = (ContentAwareResizeLayer)this.DynamicParameter;
int width = layer.Size.Width;
int height = layer.Size.Height;
- ConvolutionType convolutionType = layer.ConvolutionType;
- EnergyFunction energyFunction = layer.EnergyFunction;
- bool parallelize = layer.Parallelize;
int timeout = layer.Timeout > 0 ? layer.Timeout : 60000;
int defaultMaxWidth;
@@ -120,14 +116,20 @@ namespace ImageProcessor.Plugins.Cair.Processors
// 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);
+ (int)layer.EnergyFunction,
+ layer.Parallelize ? Math.Min(4, Environment.ProcessorCount) : 1,
+ (int)layer.OutputType);
+
+ if (!string.IsNullOrWhiteSpace(layer.WeightPath))
+ {
+ arguments = string.Format("{0} -W {1}", arguments, layer.WeightPath);
+ }
bool success = this.ProcessCairImage(arguments, timeout);
diff --git a/src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Resources/Unmanaged/x86/Usage.txt b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Resources/Unmanaged/x86/Usage.txt
new file mode 100644
index 000000000..a6b19bcef
--- /dev/null
+++ b/src/Plugins/ImageProcessor/ImageProcessor.Plugins.Cair/Resources/Unmanaged/x86/Usage.txt
@@ -0,0 +1,41 @@
+CAIR CLI Usage:
+
+cair -I
+
+Other options:
+ -O
+ Default: Dependent on operation
+ -W
+ Bitmap with: Black- no weight
+ Green- Protect weight
+ Red- Remove weight
+ Default: Weights are all zero
+ -S
+ Default: 100,000
+ -X
+ Default: Source image width
+ -Y
+ Default: Source image height
+ -R
+ CAIR: 0
+ Grayscale: 1
+ Edge: 2
+ Vertical Energy: 3
+ Horizontal Energy: 4
+ Removal: 5
+ CAIR_HD: 6
+ Default: CAIR
+ -C
+ Prewitt: 0
+ V1: 1
+ V_SQUARE: 2
+ Sobel: 3
+ Laplacian: 4
+ Default: Prewitt
+
+ -E
+ Backward: 0
+ Forward: 1
+ Default: Backward
+ -T
+ Default : CAIR_NUM_THREADS (4)