原始内容
@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
ImageContentshape that pi/provider adapters expect
Install
# 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
imagecontent block with top-leveldataandmimeTypefields - Metadata in
details(mimeType, fileSize, resolved path)
Dependencies
- pi — the extension runtime