Skip to main content
Version: Version 1.0.0

[PrepareImageMode] INI file section

The [PrepareImageMode] configuration controls how images are preprocessed before OCR, including rotation, skew correction, resolution handling, contrast enhancement, color binarization, compression, and preview generation.


Main settings

Rotation

KeyTypeDefault
RotationRotationTypeEnumRT_NoRotation

Specifies the rotation angle to apply to the image during preparation.

RotationTypeEnum

The RotationTypeEnum defines the set of possible rotation modes that can be applied to an image during preprocessing, such as 90° clockwise or upside down. It is used to control the Rotation key in OCR configuration profiles.

  • RT_Clockwise: Rotate an image 90° clockwise.
  • RT_Counterclockwise: Rotate an image 90° counterclockwise.
  • RT_NoRotation: Do not rotate an image.
  • RT_Upsidedown: Rotate an image upside down.
  • RT_UnknownRotation: The rotation angle is undefined.

CorrectSkew

KeyTypeDefault
CorrectSkewBooleantrue

Correct skew during image preparation when set to true. The type of skew correction is defined by the CorrectSkewMode property. If this property is set to false, the value of the CorrectSkewMode property is ignored.


CorrectSkewMode

Enum ValueDescription
CSM_DisableSkewCorrectionDo not correct skew.
CSM_CorrectSkewByHorizontalTextCorrect skew using horizontal text.
CSM_CorrectSkewByVerticalTextCorrect skew using vertical text.

Specifies the mode of skew correction. The value of this property is an OR superposition of the CorrectSkewModeEnum constants that denote the types of skew correction. Number 0 means do not correct skew. The value of this property is ignored if the CorrectSkew property is set to false.

CorrectSkewModeEnum

  • CSM_CorrectSkewByBlackSquaresHorizontally: The image skew angle is corrected based on so-called ‘black squares’ (the skew angle is calculated based on the horizontal pairs of squares). Black squares are often placed on forms. We recommend that you use this constant only when working with images of forms; otherwise, you may obtain incorrect results.
  • CSM_CorrectSkewByBlackSquaresVertically: The image skew angle is corrected based on so-called ‘black squares’ (the skew angle is calculated based on the vertical pairs of squares). Black squares are often placed on forms. We recommend that you use this constant only when working with images of forms; otherwise, you may obtain incorrect results.
  • CSM_CorrectSkewByHorizontalLines: The image skew angle is corrected based on horizontal lines. Use this constant only when working with images that contain horizontal lines (for example, invoices, price lists, or other documents that contain tables with visible borders); otherwise, you may get incorrect results.
  • CSM_CorrectSkewByHorizontalText: The image skew angle is corrected based on horizontal text lines.
  • CSM_CorrectSkewByVerticalLines: The image skew angle is corrected based on vertical lines. We recommend that you use this constant only when working with images that contain vertical lines (for example, invoices, price lists, or other documents that contain tables with visible borders); otherwise, you may obtain incorrect results.
  • CSM_CorrectSkewByVerticalText: The image skew angle is corrected based on vertical text lines. The constant may be useful when working with documents in languages such as Chinese, Japanese, or Korean, or if page orientation is incorrect.

BackgroundFillingColor

KeyTypeDefault
BackgroundFillingColorInteger-1

Specifies the color used for filling the areas that are added to the image after skew correction. The default value of this property is -1, which means that the color is determined by the Pdftools OCR Service automatically.

note

The integer value is calculated from the RGB triplet using the formula: (red value) + (256 × green value) + (65536 × blue value) where:

  • Red value is the first triplet component.
  • Green value is the second triplet component.
  • blue value is the third triplet

Hence, the integer value of the color white equals 16777215.


InvertImage

KeyTypeDefault
InvertImageBooleanfalse

When set to true, the Pdftools OCR Service inverts the colors of the prepared image.


MirrorImage

KeyTypeDefault
MirrorImageBooleanfalse

When set to true, the Pdftools OCR Service mirrors the prepared image around its vertical axis.


EnhanceLocalContrast

KeyTypeDefault
EnhanceLocalContrastBooleanfalse

Specifies whether the local contrast of the image should be increased. Such preprocessing may increase the quality of recognition.

info

Setting this property to true is meaningful for color and gray images only.


PhotoProcessingMode

KeyTypeDefault
PhotoProcessingModePhotoProcessingModeEnumPPM_Auto

Specifies whether the processing image should be treated as a photo. If a photo is processed, the Pdftools OCR Service uses special algorithms for such image on different stages of image processing.

PhotoProcessingModeEnum

  • PPM_Auto: Pdftools OCR Service automatically determines whether the image is a photo.
  • PPM_TreatAsPhoto: The image is treated as a photo.
  • PPM_TreatAsNonPhoto: The image should not be treated as a photo.

Resolution overwriting

AutoOverwriteResolution

KeyTypeDefault
AutoOverwriteResolutionBooleantrue

Specifies whether the resolution of the prepared image should be automatically overwritten. The property is only available if the value of the OverwriteResolution property is false. If the value of AutoOverwriteResolution is true, Pdftools OCR Service automatically detects and overwrites image resolution.

info

If you set this property to false and the resolution of the prepared image is too low (less than 50 DPI), too high (more than 3200 DPI), or undefined, you should set the correct values of the XResolutionToOverwrite and YResolutionToOverwrite properties; otherwise, an error is returned.


OverwriteResolution

KeyTypeDefault
OverwriteResolutionBooleanfalse

Allows you to overwrite resolution of the prepared image. The resolution is overwritten depending on the values of the XResolutionToOverwrite and YResolutionToOverwrite properties.
In this case, the new resolution will be used for image preprocessing (for example in binarization, deskewing). Image resolution can be automatically overwritten (review the description of the AutoOverwriteResolution property).


XResolutionToOverwrite

KeyTypeDefault
XResolutionToOverwriteInteger300

Specifies the horizontal resolution of the original image in DPI. This value is used to overwrite the resolution of the prepared image when the resolution of the original image is not specified or incorrect, and only if the OverwriteResolution property is set to true.

The Pdftools OCR Service works with the prepared image, assuming horizontal and vertical resolutions are equal.
Therefore, the program stretches the image so that the horizontal and vertical resolutions of the prepared image are identical and equal to the maximum of XResolutionToOverwrite and YResolutionToOverwrite.


YResolutionToOverwrite

KeyTypeDefault
YResolutionToOverwriteInteger300

Specifies the vertical resolution of the original image in DPI.
This value is used to overwrite the resolution of the prepared image when the resolution of the original image is not specified or incorrect, and only if the OverwriteResolution property is set to true.

The Pdftools OCR Service works with the prepared image, assuming horizontal and vertical resolutions are equal. Therefore, the program stretches the image so that the horizontal and vertical resolutions of the prepared image are identical and equal to the maximum of XResolutionToOverwrite and YResolutionToOverwrite.


Creating image planes

DiscardColorImage

KeyTypeDefault
DiscardColorImageBooleanfalse

When set to true, the Pdftools OCR Service leaves only black-and-white planes in the prepared image.
In this case, image binarization is performed during image preparation.


UseFastBinarization

KeyTypeDefault
UseFastBinarizationBooleanfalse

This property set to true will speed up binarization, however its quality may deteriorate.

If this property is true the Pdftools OCR Service will use algorithms for fast image binarization.
Binarization is performed either when the image is loaded (if DiscardColorImage is true during preparation), or later when a black-and-white image is necessary.


ImageCompression

KeyTypeDefault
ImageCompressionImageCompressionEnumIC_Auto

This property specifies how an image should be compressed during conversion to the internal format.

ImageCompressionEnum

Enum ValueDescription
IC_AutoAutomatic mode. Pdftools OCR Service automatically determines whether to compress temporary images or not.
IC_CompressCompress images with ZIP compression.
IC_NoCompressionKeep images uncompressed.

CreatePreview

KeyTypeDefault
CreatePreviewBooleanfalse

Create a preview page for the prepared image when set to true.


PreviewHeight

KeyTypeDefault
PreviewHeightInteger90

Specifies the height in pixels of the preview page.
This property is valid only if the CreatePreview property is true, otherwise it is ignored.


PreviewWidth

KeyTypeDefault
PreviewWidthInteger64

Specifies the width of the preview page in pixels.
This property is valid only if the CreatePreview property is true, otherwise it is ignored.