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

# GetNextImageFile Method of the IImageSource Interface

<Note>
  This method is implemented in FRE for Linux and Windows.
</Note>

This method is implemented on the client-side. The method returns the next image file from the image processing queue of the source.

<Note>
  For Windows, if you work with images that were already loaded into memory (for example, you use the [OpenBitmap](/fine-reader/engine/api-reference/engine-object-iengine-interface/processing-methods/openbitmap-method) or [OpenDib](/fine-reader/engine/api-reference/engine-object-iengine-interface/processing-methods/opendib-method) methods of the [Engine](/fine-reader/engine/api-reference/engine-object-iengine-interface) object), implement [GetNextImageDocument](/fine-reader/engine/api-reference/batch-processor/iimagesource/getnextimagedocument-method).
</Note>

An implementation of the GetNextImageFile method may include time to wait for the next image file. However, we do not recommend implementing long waiting times, as FineReader Engine is not multithreaded. While waiting for the next file, the Engine will not be able to process messages from the recognition processes and receive notifications that certain pages have been processed. If you do need to specify a long waiting time, the GetNextImageFile method may return 0. In this case, the Engine will continue processing messages from the recognition processes and providing recognized images and after a while will check if the image queue is empty. If the queue is not empty (i.e., if [IImageSource::IsEmpty](/fine-reader/engine/api-reference/batch-processor/iimagesource/isempty-method) returns FALSE), the Engine will call the GetNextImageFile method again. However, if the GetNextImageFile method returns 0 and there are no more pages to process, FineReader Engine will return control to the user: the [IBatchProcessor::GetNextProcessedPage](/fine-reader/engine/api-reference/batch-processor/batchprocessor/getnextprocessedpage-method) method will return 0.

## Syntax

### C++

```cpp theme={null}
HRESULT GetNextImageFile( IFileAdapter** Result );
```

### C\#

```csharp theme={null}
IFileAdapter GetNextImageFile();
```

### Visual Basic .NET

```vb theme={null}
Function GetNextImageFile() As IFileAdapter
```

## Parameters

Result

\[out, retval] A pointer to [IFileAdapter](/fine-reader/engine/api-reference/batch-processor/ifileadapter)\* pointer variable that provides access to the next image file in the queue.

## Return values

\[C++ only] If this method returns a value other than S\_OK, it indicates that an error occurred on the client-side.

## Remarks

* The client implementation of this method must assure that all exceptions thrown inside the method are caught and handled and no exceptions are propagated outside the method. Propagation of an exception outside the method may lead to unpredictable results (such as program termination).
* If your license includes the [Office Formats Opening](/fine-reader/engine/licensing/modules#officeformatsopening) module, you may also use this method to open digital documents of [supported formats](/fine-reader/engine/specifications/supported-digital-document-input-formats).

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

## See also

[IImageSource](/fine-reader/engine/api-reference/batch-processor/iimagesource)

[GetNextImageDocument](/fine-reader/engine/api-reference/batch-processor/iimagesource/getnextimagedocument-method)

[IsEmpty](/fine-reader/engine/api-reference/batch-processor/iimagesource/isempty-method)

[IFileAdapter](/fine-reader/engine/api-reference/batch-processor/ifileadapter)
