> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ImageModification Object (IImageModification Interface)

This object is used to store parameters of image modification. Method [IImageDocument::Modify](/fine-reader/engine/api-reference/image-related-objects/imagedocument/modify-method) that is used to modify an image, together with some other methods, takes a reference to this object as an input parameter. The ImageModification allows a wide range of operations upon an image, such as stretching, setting clip regions, inversion regions, paint regions, replace pixels regions, remove garbage regions. The image is modified as follows:

* The color of text and the size of garbage in regions is determined.
* Image part inside the clipping regions is cut.
* "Paint" regions are filled in with the corresponding color.
* Colors inside the "invert" regions are inverted.
* Black dots inside the "replace black pixels" regions are replaced with the dots of the corresponding color.
* White dots inside the "replace white pixels" regions are replaced with the dots of the corresponding color.
* The garbage inside the "remove garbage" regions is cleaned up. This modification can be applied only to the [black-and-white](/fine-reader/engine/guided-tour/advanced-techniques/working-with-images#black-and-white) image plane.
* Image is stretched with the stretch ratio defined by the StretchRatio property.

All regions that are added inside this object should not exceed the bounds of the image rectangle.

The ImageModification object is a persistent object. This means that the object's current state can be written to persistent storage. Later, the object can be re-created by reading the object's state from the persistent storage. The following methods provide persistence of the object:

Linux: [SaveToFile](/fine-reader/engine/api-reference/supplementary-objects-and-methods/savetofile-method), and [LoadFromFile](/fine-reader/engine/api-reference/supplementary-objects-and-methods/loadfromfile-method)

Windows: [SaveToFile](/fine-reader/engine/api-reference/supplementary-objects-and-methods/savetofile-method), [LoadFromFile](/fine-reader/engine/api-reference/supplementary-objects-and-methods/loadfromfile-method), [SaveToMemory](/fine-reader/engine/api-reference/supplementary-objects-and-methods/savetomemory-method), and [LoadFromMemory](/fine-reader/engine/api-reference/supplementary-objects-and-methods/loadfrommemory-method).

## Properties

| Name         | Type                                                                                                                                                                                                          | Description                                                                                                         |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| Application  | [Engine](/fine-reader/engine/api-reference/engine-object-iengine-interface), [read-only](/fine-reader/engine/guided-tour/advanced-techniques/programming-aspects/working-with-properties#readonly_properties) | Returns the Engine object.                                                                                          |
| StretchRatio | [double](/fine-reader/engine/guided-tour/advanced-techniques/programming-aspects/working-with-properties)                                                                                                     | Specifies the stretch ratio to apply to the image. By default, this property is 1.0 that corresponds to no stretch. |

## Methods

| Name                                                                                                                                              | Description                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [AddClipRegion](/fine-reader/engine/api-reference/image-related-objects/imagemodification/addclipregion-method)                                   | Adds new clipping region to the internal array of clipping regions.                               |
| [AddInvertRegion](/fine-reader/engine/api-reference/image-related-objects/imagemodification/addinvertregion-method)                               | Adds new inversion region to the internal array of inversion regions.                             |
| [AddPaintRegion](/fine-reader/engine/api-reference/image-related-objects/imagemodification/addpaintregion-method)                                 | Adds new paint region to the internal array of paint regions.                                     |
| [AddReplaceBlackPixelsRegion](/fine-reader/engine/api-reference/image-related-objects/imagemodification/addreplaceblackpixelsregion-method)       | Adds new "replace black pixels" region to the internal array of "replace black pixels" regions.   |
| [AddReplaceWhitePixelsRegion](/fine-reader/engine/api-reference/image-related-objects/imagemodification/addreplacewhitepixelsregion-method)       | Adds new "replace white pixels" region to the internal array of "replace white pixels" regions.   |
| [ClearClipRegions](/fine-reader/engine/api-reference/image-related-objects/imagemodification/clearclipregions-method)                             | Clears the internal array of clipping regions.                                                    |
| [ClearInvertRegions](/fine-reader/engine/api-reference/image-related-objects/imagemodification/clearinvertregions-method)                         | Clears the internal array of inversion regions.                                                   |
| [ClearPaintRegions](/fine-reader/engine/api-reference/image-related-objects/imagemodification/clearpaintregions-method)                           | Clears the internal array of paint regions.                                                       |
| [ClearReplaceBlackPixelsRegions](/fine-reader/engine/api-reference/image-related-objects/imagemodification/clearreplaceblackpixelsregions-method) | Clears the internal array of "replace black pixels" regions.                                      |
| [ClearReplaceWhitePixelsRegions](/fine-reader/engine/api-reference/image-related-objects/imagemodification/clearreplacewhitepixelsregions-method) | Clears the internal array of "replace white pixels" regions.                                      |
| [CopyFrom](/fine-reader/engine/visual-components-reference/supplementary-objects/spellwordcollection/copyfrom-method)                             | Initializes properties of the current object with values of similar properties of another object. |
| [LoadFromFile](/fine-reader/engine/api-reference/supplementary-objects-and-methods/loadfromfile-method)                                           | Restores the object contents from a file on disk.                                                 |
| [LoadFromMemory](/fine-reader/engine/api-reference/supplementary-objects-and-methods/loadfrommemory-method)                                       | Restores the object contents from the global memory. <Note> *Windows only.*</Note>                |
| [SaveToFile](/fine-reader/engine/api-reference/supplementary-objects-and-methods/savetofile-method)                                               | Saves the object contents into a file on disk.                                                    |
| [SaveToMemory](/fine-reader/engine/api-reference/supplementary-objects-and-methods/savetomemory-method)                                           | Saves the object contents into the global memory. <Note> *Windows only.*</Note>                   |

## Output parameter

This object is the output parameter of the [CreateImageModification](/fine-reader/engine/api-reference/engine-object-iengine-interface/creation-methods/createlessobjectgreater-methods) method of the [Engine](/fine-reader/engine/api-reference/engine-object-iengine-interface) object.

## Input parameter

This object is passed as an input parameter to the following methods:

* [WriteToFile](/fine-reader/engine/api-reference/image-related-objects/image/writetofile-method), [EstimateBitmapSize](/fine-reader/engine/api-reference/image-related-objects/image/estimatebitmapsize-method) (Win), [GetBitmap](/fine-reader/engine/api-reference/image-related-objects/image/getbitmap-method) (Win) of the [Image](/fine-reader/engine/api-reference/image-related-objects/image) object,
* [Modify](/fine-reader/engine/api-reference/image-related-objects/imagedocument/modify-method) of the [ImageDocument](/fine-reader/engine/api-reference/image-related-objects/imagedocument) object.

## Samples

<Accordion title="C# code">
  ```csharp theme={null}
  int splitStartPosition;
  int splitEndPosition;
  bool isVerticalSplit;
  FREngine.IFRDocument frDoc;
  FREngine.IFRPage page;
  // Split the image of a document page in two pages
  // Image dimensions
  int width = page.ImageDocument.ColorImage.Width;
  int height = page.ImageDocument.ColorImage.Height;
  // Duplicate page
  frDoc.AddPage(page);
  FREngine.IFRPage secondPage = frDoc.Pages[frDoc.Pages.Count - 1];
  // Crop first and second pages
  FREngine.IImageModification firstModification = engine.CreateImageModification();
  FREngine.IRegion firstClipRegion = engine.CreateRegion();
  FREngine.IImageModification secondModification = engine.CreateImageModification();
  FREngine.IRegion secondClipRegion = engine.CreateRegion();
  if (isVerticalSplit)
  {
   firstClipRegion.AddRect(0, 0, splitStartPosition, height - 1 );
   secondClipRegion.AddRect(splitEndPosition, 0, width - 1, height - 1);
  }
  else
  {
   firstClipRegion.AddRect(0, 0, width - 1, splitStartPosition);
   secondClipRegion.AddRect(0, splitEndPosition, width - 1, height - 1);
  }
  firstModification.AddClipRegion(firstClipRegion);
  page.ImageDocument.Modify(firstModification);
  secondModification.AddClipRegion(secondClipRegion);
  secondPage.ImageDocument.Modify(secondModification);
  ```
</Accordion>

## See also

[Working with Images](/fine-reader/engine/guided-tour/advanced-techniques/working-with-images)

[Working with Properties](/fine-reader/engine/guided-tour/advanced-techniques/programming-aspects/working-with-properties)
