imgify-pi

extensionmaintained

pi extension: convert a written prompt into an image and send it to the chat model

by · v0.1.0 · published 3w ago

$ pi install npm:imgify-pi
downloads/mo
193
stars
0
last push
3w ago
open issues
0

Signals

license: MITtestspi manifest: missinginstall size: —deps: 0peer deps: 0

Download trend

193 downloads · last 12 weeks (weekly)

README

imgify (pi extension)

Convert a written prompt/message into an image and send that image to the chat model. The chat model must be vision-capable (image in its input types) to actually "see" the image.

The image is generated locally — the prompt text is rendered onto a PNG with no AI image model and no API key. (The only AI model in the loop is the chat model that receives the image.)

Install

As a published pi package (recommended):

pi install npm:imgify-pi

From this repo (local development):

cd pi
npm install          # pulls @napi-rs/canvas for local text rendering

# register it as a project-local package (writes .pi/settings.json -> packages)
pi install ./pi -l

This repo's .pi/settings.json already lists ../pi under packages, so running pi in the repo root loads the extension automatically (after the project is trusted). After editing, run /reload (or restart pi) to pick up changes.

Alternative manual methods (also work):

# symlink/copy into the auto-discovered project-local extensions dir
ln -sfn ../../pi .pi/extensions/imgify
cp -r pi .pi/extensions/imgify

# or run it ad-hoc for one session
pi -e ./pi/index.ts

Usage

Three entry points:

  1. Prefix trigger (input transform). With the default config, a message starting with imgify is converted and the image is attached to the message before the agent sees it:

    imgify Draw a cat wearing a hat
    

    Note: the trigger uses no @ because pi reserves @<path> for attaching files. Set IMAGIFY_TRIGGER=always to convert every message.

  2. Slash command:

    /imgify Explain this diagram
    
  3. Tool — the LLM can call imgify to generate an image and reason about it.

Configuration (environment variables)

VariableDefaultMeaning
IMAGIFY_TRIGGERprefixprefix or always
IMAGIFY_PREFIXimgify Trigger prefix in prefix mode
IMAGIFY_COMMANDimgifySlash command name
IMAGIFY_OUTPUT_DIR<cwd>/.imgifyWhere generated PNGs are also saved
IMAGIFY_RENDER_BG#0d1117Render background color
IMAGIFY_RENDER_FG#e6edf3Render text color
IMAGIFY_RENDER_FONT_SIZE36Render font size (px)
IMAGIFY_RENDER_PADDING40Render padding (px)
IMAGIFY_RENDER_MAX_WIDTH900Render canvas width (px)
IMAGIFY_RENDER_FONT_FAMILYautoExplicit font family (else auto-detected)

How images are generated

The prompt text is rendered onto a PNG locally using @napi-rs/canvas. No AI image model and no API key are required. A system font is auto-detected via fontconfig. The resulting image literally contains the prompt text, which a vision chat model can then read back.

Files

  • index.ts — extension entry (input transform, command, tool)
  • image-gen.ts — local text rendering
  • config.ts — environment-based configuration