---
slug: "dougbots-pi-image-loader"
source_type: "readme"
source_url: "https://cdn.jsdelivr.net/gh/sdougbrown/pi-image-loader@main/README.md"
repo: "https://github.com/sdougbrown/pi-image-loader"
source_file: "README.md"
branch: "main"
---
# @dougbots/pi-image-loader

Image-to-base64 tool for pi — lets image-capable models see local image files from the filesystem.

## What it does

Registers an `image_to_base64` tool that:
- Reads an image file from disk (png, jpg, jpeg, gif, webp, svg, bmp, tif, tiff)
- Converts it to a base64 image content block with the correct MIME type
- Returns the image in the top-level `ImageContent` shape that pi/provider adapters expect

## Install

```bash
# As a pi package (recommended)
pi install git:github.com/sdougbrown/pi-image-loader

# Local development
pi install /path/to/pi-image-loader
```

## Usage

Once installed, the `image_to_base64` tool is available in your pi sessions. Pass it a file path and it returns the image as pi image content backed by base64 data:

```
image_to_base64(filePath: "/path/to/image.png")
```

Supported formats: png, jpg, jpeg, gif, webp, svg, bmp, tif, tiff.

## Response

The tool returns:
- A text confirmation of the conversion
- An `image` content block with top-level `data` and `mimeType` fields
- Metadata in `details` (mimeType, fileSize, resolved path)

## Dependencies

- **pi** — the extension runtime
