Auto margins delete

  • Last Post 05 July 2016
BartoszG posted this 31 May 2016

Hi, How to tell Engine to delete white, blank spaces on scanned page? Or create image for objects located in center of scanned page?

Order By: Standard | Newest | Votes
Ilya Sukhorukov posted this 02 June 2016


There is “CropImage” Method of ImageDocument Object that finds the edges of a document on the image and then crops the image. For more detailed information see “Help → API Reference → Image-Related Objects → ImageDocument”.

Pay attention, that this method works more correct when all four edges of document can be found i.e. the document is completely surrounded by background. In other cases you can crop it manually with “Modify” Method of the ImageDocument Object. This method modifies ImageDocument according to transmitted ImageModification Object. You should add the region that should be clipped into ImageModification through “AddClipRegion” Method.

BartoszG posted this 09 June 2016

Hi, tell me what in what step of processing document, this should be done? I mean, it should be working like this?:

1. frDocument.AddImageFile('page', nil, nil );

2. frDocument.Pages.Item(0).ImageDocument.CropImage;

3. frDocument.Process(processingParams);

4. frDocument.SaveToFolder('page');

If yes, how can i check what goes wrong if my image is not auto-crop?

Ilya Sukhorukov posted this 05 July 2016

Image cropping is useful when the image has already been loaded but hasn’t been processed. This code is technically correct (except missed brackets at the end of the second line) but it is doing quite a strange thing.

1) It adds an image, for instance ‘test.png’, to existing FRDocument object.

2) Then it crops the image inside of FRDocument object.

3) After that it processes the FRDocument object.

4) And finally it saves FRDocument object with a name of image (in our case ‘test.png’). But the file is saved in the internal format of FineReader Engine, which can’t be read by any image viewer.

As I mentioned before autocrop works better when all 4 edges of document can be clearly seen. If application doesn’t crop your image, try another image with perfectly shaped edges. If the latter image is processed correctly, then the issue is in borders of the first document. Otherwise most probably the cause is in Autocrop function application.