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

# IImageSource Interface

> IImageSource interface in the ABBYY FineReader Engine API — This is the interface for a custom source of images.

> [!NOTE]
>
> This interface is implemented in FRE for Linux and Windows.

This is the interface for a custom source of images. This interface and all its methods are implemented on the client-side. This interface is used by the Batch Processor (the [BatchProcessor](https://docs.abbyy.com/fine-reader/engine/api-reference/batch-processor/batchprocessor.md) object).

This interface allows you to implement image processing queue in a custom way. Batch Processor requests the next image from this queue using the GetNextImageFile or GetNextImageDocument methods.

> [!WARNING]
>
> All the [ImageDocument](https://docs.abbyy.com/fine-reader/engine/api-reference/image-related-objects/imagedocument.md) objects in the queue must be valid till the end of processing. For correct operation the ImageDocument objects should be created via the [Engine](https://docs.abbyy.com/fine-reader/engine/api-reference/engine-object-iengine-interface.md) object. If they are created via the [FRDocument](https://docs.abbyy.com/fine-reader/engine/api-reference/document-related-objects/frdocument.md) object an error may occur because of the FRDocument object being destroyed during the call to the GetNextImageDocument method.

## Methods

| Name | Description |
| - | - |
| [GetNextImageDocument](https://docs.abbyy.com/fine-reader/engine/api-reference/batch-processor/iimagesource/getnextimagedocument-method.md) | Returns the next image document from the image processing queue of the source. |
| [GetNextImageFile](https://docs.abbyy.com/fine-reader/engine/api-reference/batch-processor/iimagesource/getnextimagefile-method.md) | Returns the next image file from the image processing queue of the source. |
| [IsEmpty](https://docs.abbyy.com/fine-reader/engine/api-reference/batch-processor/iimagesource/isempty-method.md) | Checks if there are any image files in the image processing queue of the source. |

## Input parameter

The [Start](https://docs.abbyy.com/fine-reader/engine/api-reference/batch-processor/batchprocessor/start-method.md) method of the [BatchProcessor](https://docs.abbyy.com/fine-reader/engine/api-reference/batch-processor/batchprocessor.md) object receives a pointer to this interface as an input parameter.

## Samples

> [accordion] C# code
>
> ```csharp theme={null}
> // Sample implementation of a custom image source which maintains a queue of image files
> public class ImageSourceCallback : FREngine.IImageSource
> {
>    public ImageSourceCallback( string imageFilesDirectory )
>    {
>        imageFiles = ImageSourceHelper.LoadFilesNames( imageFilesDirectory );
>        nextFileIndex = 0;
>    }
>    public bool IsEmpty()
>    {
>        return nextFileIndex >= imageFiles.Length;
>    }
>    public FREngine.IFileAdapter GetNextImageFile()
>    {
>        if( !IsEmpty() ) {
>            return new FileAdapterCallback( imageFiles[nextFileIndex++] );
>        }
>        return null;
>    }
>    public FREngine.IImageDocument GetNextImageDocument()
>    {
>        ...
>    }
>    private string[] imageFiles;
>    private int nextFileIndex;
> }
> public class FileAdapterCallback : FREngine.IFileAdapter
> {
>     ...
> }
> public class ImageSourceHelper
> {
>     ...
> }
> ```

The interface is used in the following code samples: [BatchProcessing](https://docs.abbyy.com/fine-reader/engine/guided-tour/samples.md#batchprocessing); and Windows demo tools: [BatchProcessingRecognition](https://docs.abbyy.com/fine-reader/engine/guided-tour/samples.md#batchprocessingrecognition).

## See also

[BatchProcessor](https://docs.abbyy.com/fine-reader/engine/api-reference/batch-processor/batchprocessor.md)
