induwara.lk
induwara.lkAI · Image

AI Image to Prompt — reverse prompt generator

Drop any image and get copy-ready prompts for Midjourney, Stable Diffusion, and DALL·E 3. The exact aspect ratio and colour palette are worked out in your browser; a free BLIP caption suggests the subject. No signup, no watermark.

By Induwara AshinsanaUpdated Jul 11, 2026
Image to promptreverse-prompt generator
Sources cited

What this does

Drop a reference image above. You instantly get its exact aspect ratio (for the Midjourney --ar parameter) and dominant colour palette — both computed offline in your browser. BLIP then suggests the subject, and you pick medium, style, lighting, and quality tags to build a copy-ready prompt for Midjourney, Stable Diffusion, or DALL·E 3.

Aspect-ratio math and palette extraction run entirely in your browser. The subject caption is the only network call: image bytes go once to the BLIP model on the Hugging Face Inference API and are not stored. This tool reconstructs a plausible prompt from pixels — it cannot recover the exact prompt someone else used to generate an image.

How it works

Most "image to prompt" sites push your picture to a private API and hand back a black-box string. This page is transparent about which parts are exact maths and which part is a learned model, and it keeps the heavy lifting in your browser. Four layers combine into one prompt.

1. Aspect ratio — exact integer maths

The tool reads your image's real pixel dimensions and divides both by their greatest common divisor using Euclid's algorithm. A 1920×1080 image reduces to 16:9. When the reduced ratio is unwieldy — either side larger than 32, as with an odd 1000×1237 crop — it snaps to the nearest standard ratio (1:1, 4:3, 3:2, 16:9, 9:16, 3:4, 2:3, 21:9) by the smallest difference in the width-to-height decimal. That value becomes the Midjourney --ar parameter. This step is deterministic and never leaves your browser.

2. Colour palette — client-side quantisation

The image is drawn to a small canvas (longest side ≤ 100 px), and each pixel is quantised into a fixed 216-bucket colour grid (six levels per RGB channel). The buckets are ranked by how many pixels they hold, and each dominant bucket is mapped to the nearest named colour from a curated vocabulary by squared Euclidean distance in sRGB. The share-weighted warm-versus-cool balance decides whether the palette reads warm or cool. These colour terms feed straight into the prompt — also entirely offline.

3. Subject caption — BLIP on the Hugging Face Inference API

The one learned step. The image bytes are POSTed once to a server-only route that forwards them to Salesforce/blip-image-captioning-base on the free Hugging Face Inference API (Li et al., ICML 2022). The returned caption becomes the editable subject. Running BLIP in the browser would mean downloading a 150–250 MB model to every phone, so it runs server-side; if the service is not configured, you simply type the subject yourself and the rest of the tool is unaffected.

4. Style vocabulary and assembly

The medium, style, lighting, composition, quality, and artist chips follow the clip-interrogator vocabulary. The selected phrases are joined in a fixed, readable order — subject, medium, style, lighting, colour, composition, quality, artist — then formatted per target: Midjourney appends the --ar / --stylize / --v parameters, SDXL adds a default negative-prompt block, and DALL·E 3 receives a single descriptive sentence because it prefers prose. The assembly is deterministic: the same image and the same selections always produce the same prompt.

Worked examples

The aspect-ratio maths is exact and reproducible. Each example below is cross-checked live against the same detectAspectRatio() function the tool uses.

1920 × 1080 — Full HD landscape

16:9

  1. gcd(1920, 1080): 1920 = 1·1080 + 840; 1080 = 1·840 + 240; 840 = 3·240 + 120; 240 = 2·120 + 0 → gcd = 120
  2. Reduce: 1920/120 : 1080/120 = 16 : 9
  3. Both terms ≤ 32 → no snap needed
  4. Cross-check: 16 ÷ 9 = 1.7778 = 1920 ÷ 1080 ✓
  5. Midjourney parameter → --ar 16:9

Live cross-check: detectAspectRatio() returns 16:9 — matches ✓

1000 × 1500 — portrait photo

2:3

  1. gcd(1000, 1500) = 500
  2. Reduce: 1000/500 : 1500/500 = 2 : 3
  3. Both terms ≤ 32 → no snap needed
  4. Cross-check: 2 ÷ 3 = 0.6667 = 1000 ÷ 1500 ✓
  5. Midjourney parameter → --ar 2:3

Live cross-check: detectAspectRatio() returns 2:3 — matches ✓

1000 × 1237 — odd crop, snapped

3:4(snapped)

  1. gcd(1000, 1237) = 1 → reduced ratio is 1000 : 1237
  2. A term exceeds 32, so the raw ratio is unwieldy → snap
  3. W ÷ H = 0.8085; nearest common ratio is 3:4 (0.75), difference 0.0585
  4. No other common ratio is closer (2:3 is 0.667, diff 0.1415)
  5. Snapped Midjourney parameter → --ar 3:4

Live cross-check: detectAspectRatio() returns 3:4 — matches ✓

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

A prompt the tool keeps getting wrong, or a style tag you wish it had?

Email me at [email protected] — most fixes ship within 24 hours.