Class ImageReader

java.lang.Object
io.agentscope.core.rag.reader.ImageReader
All Implemented Interfaces:
Reader

public class ImageReader extends Object implements Reader
Image reader implementation that reads image files.

This reader supports various image formats and can optionally extract text from images using OCR (if enabled). The reader creates Document objects with image content that can be used in multimodal RAG systems.

Example usage:


 ImageReader reader = new ImageReader(false);
 ReaderInput input = ReaderInput.fromString("path/to/image.jpg");
 List<Document> documents = reader.read(input).block();
 
  • Constructor Details

    • ImageReader

      public ImageReader()
      Creates a new ImageReader with OCR disabled.
    • ImageReader

      public ImageReader(boolean enableOCR)
      Creates a new ImageReader with the specified OCR setting.
      Parameters:
      enableOCR - true to enable OCR text extraction from images
  • Method Details

    • read

      public reactor.core.publisher.Mono<List<io.agentscope.core.rag.model.Document>> read(ReaderInput input)
      Description copied from interface: Reader
      Reads a document and returns a list of chunked Document objects.

      Errors during reading are propagated through the Mono via Mono.error().

      Specified by:
      read in interface Reader
      Parameters:
      input - the input to read (text, file path, URL, etc.)
      Returns:
      a Mono that emits a list of Document objects, or an error signal on failure
    • getSupportedFormats

      public List<String> getSupportedFormats()
      Description copied from interface: Reader
      Gets the list of file formats supported by this reader.
      Specified by:
      getSupportedFormats in interface Reader
      Returns:
      a list of supported file extensions (e.g., "txt", "md", "pdf")
    • isOcrEnabled

      public boolean isOcrEnabled()
      Checks if OCR is enabled.
      Returns:
      true if OCR is enabled