DeepsetFileToBase64Image
Convert image files from disk into base64-encoded images for use in visual question answering pipelines.
This component is deprecated. Use ImageFileToImageContent from Haystack instead. Existing pipelines that use this component continue to work for now.
Key Features
- Reads image files from local disk and converts them to
Base64Imageobjects. - Supports PNG, JPG, JPEG, and GIF file formats.
- Accepts documents with
file_pathmetadata or direct file sources. - Configurable image detail level for vision model input sizing.
Configuration
- Drag the
DeepsetFileToBase64Imagecomponent onto the canvas from the Component Library. - Click the component to open the configuration panel.
- Set
detailto control how the image is resized before encoding.
Connections
DeepsetFileToBase64Image accepts documents with file_path metadata or direct sources as input. It outputs documents and base64_images.
Connect DeepsetFileDownloader to provide documents with local file paths. Connect the base64_images output to a visual Generator such as DeepsetOpenAIVisionGenerator or Base64ImageJoiner.
Usage Example
This example converts downloaded image files to base64 for a vision Generator:
components:
image_downloader:
type: deepset_cloud_custom_nodes.augmenters.deepset_file_downloader.DeepsetFileDownloader
init_parameters:
file_extensions:
- .png
- .jpg
- .jpeg
sources_target_type: str
max_cache_size: 100
file_to_image:
type: deepset_cloud_custom_nodes.converters.file_to_image.DeepsetFileToBase64Image
init_parameters:
detail: auto
connections:
- sender: image_downloader.documents
receiver: file_to_image.documents
Parameters
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | Optional[List[Document]] | None | Documents with file_path in metadata pointing to image files. |
| sources | Optional[List[Union[str, Path, ByteStream]]] | None | Direct file paths or byte streams to convert. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | List[Document] | Documents that had convertible image files. | |
| base64_images | List[Base64Image] | Base64-encoded images ready for vision Generators. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
| detail | Literal["auto", "low", "high"] | auto | Controls how the image is resized before encoding. See the OpenAI vision documentation for details. |
Run Method Parameters
These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | Optional[List[Document]] | None | Documents with file_path in metadata. |
| sources | Optional[List[Union[str, Path, ByteStream]]] | None | Direct file paths or byte streams to convert. |
Was this page helpful?