> ## 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.

# WriteToFile Method of the Image Object

This method saves a copy of the current image plane into an image file in the specified format.

## Syntax

```vb Visual Basic .NET theme={null}
Sub WriteToFile( _
  FileName As String, _
  Format As ImageFileFormatEnum, _
  Modification As ImageModification, _
  CompressionType As ImageCompressionTypeEnum, _
  extendedParams As Object _
)
```

```cpp C++ theme={null}
HRESULT WriteToFile(
  BSTR                     FileName,
  ImageFileFormatEnum      Format,
  ImageModification*       Modification,
  ImageCompressionTypeEnum CompressionType,
  IUnknown*                extendedParams
);
```

## Parameters

**FileName**

\[in] This parameter contains the full path to the image file where the image is saved. For example, "C:\MyPic.bmp". If a file in this path already exists, it is overwritten without prompt.

**Format**

\[in] A variable of the [**ImageFileFormatEnum**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagefileformatenum.md) type that specifies the format of the output file. Not all formats defined by this enumeration are supported for writing. *Format* and *CompressionType* parameters are related. See the list of supported combinations [below](https://docs.abbyy.com/flexi-capture/sdk/api-reference/image-writetofile.md#format-compressiontype-combinations).

**Modification**

\[in] This parameter of the [**ImageModification**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagemodification.md) type defines modifications that are performed upon image before writing it into file. This parameter is optional and may be 0, in which case no modifications are performed upon image.

**CompressionType**

\[in] A variable of the [**ImageCompressionTypeEnum**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagecompressiontypeenum.md) type that specifies the compression type of the output file. *Format* and *CompressionType* parameters are related. For all image formats except TIFF ([IFF\_Tif](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagefileformatenum.md)), set this parameter to ICT\_Default; compression type will then be selected automatically. See the [table below](https://docs.abbyy.com/flexi-capture/sdk/api-reference/image-writetofile.md#format-compressiontype-combinations) for information about compression types supported for TIFF images.

**extendedParams**

\[in] This variable may refer to the [**JpegExtendedParams**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/jpegextendedparams.md) or [**PngExtendedParams**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/pngextendedparams.md) object that defines parameters for saving the image to JPEG or PNG format. This parameter is optional and may be 0. In this case the JPEG image is saved with lossless JPEG 2000 compression, or the PNG image is saved with the default parameters.

## Return values

This method returns **E\_INVALIDARG** if the saving format is black-and-white while the format of the image is gray or color. It may also return [standard return values of ABBYY FlexiCapture SDK functions](https://docs.abbyy.com/flexi-capture/sdk/api-reference/errorcodes.md).

## Remarks

The table below describes the possible values of the *CompressionType* parameter for TIFF images ([IFF\_Tif](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagefileformatenum.md)). The compression depends on the color type of the saving image ([**IImage::ImageColorType**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/image.md#imagecolortype)).

| **Image color type** | **CompressionType** |
| - | - |
| Black-and-white image ([ICT\_BlackWhite](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagecolortypeenum.md#ict-blackwhite)) | ICT\_Uncompressed ICT\_CcittGroup4 ICT\_PackBits ICT\_Lzw ICT\_Zip |
| Color image ([ICT\_Color](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagecolortypeenum.md#ict-color)), gray image ([ICT\_Gray](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagecolortypeenum.md#ict-gray)) | ICT\_Uncompressed ICT\_PackBits ICT\_Jpeg ICT\_Lzw ICT\_Zip |

## See also

[**Image**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/image.md)
