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

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](/fine-reader/engine/api-reference/batch-processor/batchprocessor) 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](/fine-reader/engine/api-reference/image-related-objects/imagedocument) objects in the queue must be valid till the end of processing. For correct operation the ImageDocument objects should be created via the [Engine](/fine-reader/engine/api-reference/engine-object-iengine-interface) object. If they are created via the [FRDocument](/fine-reader/engine/api-reference/document-related-objects/frdocument) object an error may occur because of the FRDocument object being destroyed during the call to the GetNextImageDocument method.
</Warning>

## Methods

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

## Input parameter

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

## Samples

<Accordion title="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
  {
      ...
  }
  ```
</Accordion>

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

## See also

[BatchProcessor](/fine-reader/engine/api-reference/batch-processor/batchprocessor)
