ClearImage .NET API
AutoCrop Method (ImageEditor)
Example 





Inlite.ClearImageNet Namespace > ImageEditor Class : AutoCrop Method
New left margin in pixels
New top margin in pixels
New right margin in pixels
New bottom margin in pixels
Set image margins
Syntax
'Declaration
 
Public Sub AutoCrop( _
   ByVal leftMargin As System.Integer, _
   ByVal topMargin As System.Integer, _
   ByVal rightMargin As System.Integer, _
   ByVal bottomMargin As System.Integer _
) 
'Usage
 
Dim instance As ImageEditor
Dim leftMargin As System.Integer
Dim topMargin As System.Integer
Dim rightMargin As System.Integer
Dim bottomMargin As System.Integer
 
instance.AutoCrop(leftMargin, topMargin, rightMargin, bottomMargin)
public void AutoCrop( 
   System.int leftMargin,
   System.int topMargin,
   System.int rightMargin,
   System.int bottomMargin
)
public procedure AutoCrop( 
    leftMargin: System.Integer;
    topMargin: System.Integer;
    rightMargin: System.Integer;
    bottomMargin: System.Integer
); 
public function AutoCrop( 
   leftMargin : System.int,
   topMargin : System.int,
   rightMargin : System.int,
   bottomMargin : System.int
);
public:
void AutoCrop( 
   System.int leftMargin,
   System.int topMargin,
   System.int rightMargin,
   System.int bottomMargin
) 

Parameters

leftMargin
New left margin in pixels
topMargin
New top margin in pixels
rightMargin
New right margin in pixels
bottomMargin
New bottom margin in pixels
Remarks

The margin is a distance from the image edge to the image pixel nearest to that edge. 
This method changes the size of the image.

Example
void RepairMethods(string imageFile, string imageFileOut)
{
    ImageEditor editor = new ImageEditor();
    try
    {
        // Open image file
        editor.Image.Open(imageFile, 1);
        // Do Processing
        editor.AutoDeskew();                // Use AutoDeskew before AutoRotate
        editor.AutoRotate();
        // editor.AutoCrop(10, 10, 10, 10); // Do not use AutoCrop with AutoRegister or BorderExtract
        // editor.AutoRegister(100, 100);   // Do not use AutoRegister with AutoCrop or BorderExtract
        editor.AdvancedBinarize();
        editor.BorderExtract(BorderExtractMode.deskewCrop);
        editor.RemovePunchHoles();
        editor.SmoothCharacters();
        editor.CleanNoise(3);              // Remove only black pixels.  Use CleanNoiseExt to remove white noise
        // editor.CleanNoise(CleanNoiseFlags.black | CleanNoiseFlags.white, 3, 3, 10);
        editor.lineCurvature = LineCurvature.low;
        editor.lineMaxAngle = 5;
        editor.lineMaxGap = 5;
        editor.lineMinLength = 200;
        editor.DeleteLinesAndRepair(LineDirection.horzAndVert);
        //  Save processed image
       editor.Image.SaveAs(imageFileOut, Inlite.ClearImage.EFileFormat.ciEXT);
    }
    catch (ClearImageException ex)
    { Console.WriteLine(ex.Message); }
    finally
    {editor.Dispose(); }  // ClearImage V9 and later
}
See Also

Reference

ImageEditor Class
ImageEditor Members