imgenv0.3.1

CASOON Open Source

Images from the command line.

imgen sends a prompt to any image model on Replicate, waits for the prediction and saves the result as PNG or WebP. It reads each model's schema to send the size the way that model expects, and runs whole batches from one JSON file.

curl -fsSL https://raw.githubusercontent.com/casoon/imgen/master/install.sh | sh
cargo install --git https://github.com/casoon/imgen
MITv0.3.1Rust CLImacOS + Linux
Terminal: imgen --version prints imgen 0.3.1. cat jobs.json shows a prompt file with two jobs, the second without an out field. With a placeholder token exported, imgen --prompt-file jobs.json stops with Failed to parse prompt file jobs.json, caused by missing field out, before any API request. echo $? prints 1.
ways to send the image size, picked from the model schema
3
prompt-file formats: plain array or defaults + jobs
2
retries on HTTP 429, honouring Retry-After
5
prebuilt release targets
4

Made with imgen

All examples →
  • Isometric 3D illustration of a laptop on a glowing platform with a terminal window on the screen and colourful ribbons, bubbles and particles bursting out behind it, on a dark grid. At the top the glowing headline “Ki-Bilder per Kommandozeile”.
  • Isometric 3D server rack under a holographic globe showing Europe, with glowing cables running from two clouds on the left and right and white arrows pointing at the rack, dark background with blue and red light. At the top the headline “RAUS AUS DER CLOUD?” in glowing white capitals.
  • 3D staircase built from blue and green blocks rising to the right, with floating code windows, shield icons and padlocks beside it, on a dark grid floor. At the top the headline “SECURITY ALS KARRIEREPFAD” in glowing white capitals with a green glow.
  • Isometric grid of rounded UI component tiles – cards, buttons and groups of coloured dots in red, cyan, yellow and grey – on a dark grid, framed by a neon line fading from cyan to purple. At the top the headline “Design Systems rechnen Sich” in glowing white letters.

Made with imgen and ideogram-ai/ideogram-v3-quality. Generated once and committed, because generation needs a Replicate token; each image's prompt and command are in the showcase.

examples/gallery/

What it does

How it works

Image models on Replicate do not agree on how they take a size. imgen does not keep a list of models: it reads the input schema of the model you name and sends exact pixels, the closest allowed aspect ratio, or plain width and height, whichever the model accepts.

Then it creates the prediction, polls until the image is ready and saves it. With--webp, models that can deliver WebP do so directly; for all others imgen converts the download locally.

How imgen turns a prompt into an imageYou pass a prompt and a model. imgen resolves the model's latest version on Replicate and reads its input schema. From the schema it decides how to send the size: exact width and height through a custom aspect ratio, the closest allowed aspect ratio, or plain width and height. It then creates a prediction, polls until it has finished, downloads the image and saves it as PNG or WebP.How imgen turns a prompt into an imagePrompt → Model schemaModel schema → Fit the sizeFit the size → PredictionPrediction → DownloadDownload → Image savedPrompt – argument or prompt filePromptargument or prompt fileModel schema – latest version on ReplicateModel schemalatest version on ReplicateFit the size – pixels, ratio or width/heightFit the sizepixels, ratio or width/heightPrediction – created, then polledPredictioncreated, then polledDownloadDownloadImage saved – PNG or WebPImage savedPNG or WebP
How imgen turns a prompt into an imageYou pass a prompt and a model. imgen resolves the model's latest version on Replicate and reads its input schema. From the schema it decides how to send the size: exact width and height through a custom aspect ratio, the closest allowed aspect ratio, or plain width and height. It then creates a prediction, polls until it has finished, downloads the image and saves it as PNG or WebP.How imgen turns a prompt into an imagePrompt → Model schemaModel schema → Fit the sizeFit the size → PredictionPrediction → DownloadDownload → Image savedPrompt – argument or prompt filePromptargument or prompt fileModel schema – latest version on ReplicateModel schemalatest version on ReplicateFit the size – pixels, ratio or width/heightFit the sizepixels, ratio or width/heightPrediction – created, then polledPredictioncreated, then polledDownloadDownloadImage saved – PNG or WebPImage savedPNG or WebP
How imgen turns a prompt into an imageYou pass a prompt and a model. imgen resolves the model's latest version on Replicate and reads its input schema. From the schema it decides how to send the size: exact width and height through a custom aspect ratio, the closest allowed aspect ratio, or plain width and height. It then creates a prediction, polls until it has finished, downloads the image and saves it as PNG or WebP.How imgen turns a prompt intoan imagePrompt → Model schemaModel schema → Fit the sizeFit the size → PredictionPrediction → DownloadDownload → Image savedPrompt – argument or prompt filePromptargument orprompt fileModel schema – latest version on ReplicateModel schemalatest version onReplicateFit the size – pixels, ratio or width/heightFit the sizepixels, ratio orwidth/heightPrediction – created, then polledPredictioncreated, thenpolledDownloadDownloadImage saved – PNG or WebPImage savedPNG or WebP
How imgen turns a prompt into an imageYou pass a prompt and a model. imgen resolves the model's latest version on Replicate and reads its input schema. From the schema it decides how to send the size: exact width and height through a custom aspect ratio, the closest allowed aspect ratio, or plain width and height. It then creates a prediction, polls until it has finished, downloads the image and saves it as PNG or WebP.How imgen turns a prompt intoan imagePrompt → Model schemaModel schema → Fit the sizeFit the size → PredictionPrediction → DownloadDownload → Image savedPrompt – argument or prompt filePromptargument orprompt fileModel schema – latest version on ReplicateModel schemalatest version onReplicateFit the size – pixels, ratio or width/heightFit the sizepixels, ratio orwidth/heightPrediction – created, then polledPredictioncreated, thenpolledDownloadDownloadImage saved – PNG or WebPImage savedPNG or WebP

Quickstart

Three steps from install to a saved image. The documentation covers models, schema detection and batch files.

  1. Install imgen with the install script, a release archive or Cargo.
  2. Export your Replicate token as REPLICATE_API_TOKEN.
  3. Run imgen with a prompt, or with --prompt-file for a batch.
terminalShell
# Token from replicate.com/account/api-tokens
export REPLICATE_API_TOKEN="r8_your_token_here"

# One image with the default model (FLUX 1.1 Pro)
imgen "A sunset over the ocean" --out sunset.png

# Many images from a JSON file
imgen --prompt-file prompts.json

New in v0.3.1

Changelog →

Frequently asked questions

Is imgen still maintained?

imgen is feature-complete and no longer actively developed. It works as documented against the Replicate API; issues and pull requests may not be answered.

Which platforms are supported?

The install script and prebuilt release binaries cover macOS and Linux (x86_64 and arm64). There is no Windows build, but "cargo install --git https://github.com/casoon/imgen" builds imgen from source on any platform Rust supports.

How does imgen handle Replicate rate limits?

On HTTP 429 responses, imgen respects the Retry-After header (falling back to 10 seconds) and retries up to 5 times before giving up. Each image generation then polls for up to 120 seconds, checking every 2 seconds.

Is imgen on crates.io?

No. The crate named "imgen" on crates.io is a different project. Install the binary with the install script or build it from source with Cargo.