# Code to image

Turn source code into a shareable picture with syntax highlighting, a window frame and a choice of themes.

Colours the code by language, then draws it in a monospaced font inside a rounded window with a soft shadow. Nothing is loaded from outside: the code you send is the only input.

- Endpoint: `POST https://setget.net/v1/tools/code-image` with JSON `{"input": {...}}` (add `"wait": 30` to hold the reply until the job finishes)
- MCP: `run_tool` with `slug` = `code-image`
- Page: https://setget.net/tools/code-image

## Files in, files out

This is a file tool. Its file inputs take file references, not file contents and not web addresses.

- Get a reference by uploading: `curl -T FILE https://setget.net/drop/` prints a line `ref  <id>/f1`. Or `POST https://setget.net/v1/drops` with `{"files":[{"name","size"}]}`, PUT the bytes to the returned `upload.url` with the listed headers, and use the file's `ref`. Over MCP use the `drop` tool. A file under about 700 KB can also be sent in place as a `data:<type>;base64,<content>` URI.
- Uploads are at most 100 MB per file, are readable by anyone with the link, and expire (one hour by default). Programs are refused.
- The tool runs as a job. The reply is `{"tool", "ms", "result", "files", "job"}`: `result` is JSON, and every result file comes back in `files` as `{"name", "size", "content_type", "kind", "url", "ref"}`. Download it from `url`, or pass `ref` as the input of another file tool.
- A job still running when the wait ends answers 202 with `job`. Follow it with `GET https://setget.net/v1/jobs/<id>?wait=30`, or stream progress from `GET https://setget.net/v1/jobs/<id>/events` (over MCP: the `job` tool). A person can watch it at `job.url`.

## Inputs

- `code` (required, string): The source code to draw. Up to 200 lines.
- `language` (optional, string, default `"auto"`): The language, such as python, javascript, sql or bash. "auto" detects common languages; "text" turns colouring off.
- `theme` (optional, string, one of `one-dark`, `dracula`, `monokai`, `nord`, `github-dark`, `solarized-dark`, `light`, `solarized-light`, `gruvbox-light`, `xcode`, default `"one-dark"`): Colour theme. The first six are dark, the last four are light.
- `font_size` (optional, integer, default `16`, range 8..40): Text size in pixels, before scaling.
- `padding` (optional, integer, default `32`, range 0..128): Width of the coloured border around the window, in pixels. 0 removes the border.
- `background` (optional, string, default `"#abb8c3"`): Colour of the border: hex such as #abb8c3, a basic colour name, or "transparent".
- `line_numbers` (optional, boolean, default `false`): Show line numbers on the left.
- `window` (optional, boolean, default `true`): Show a title bar with three window buttons.
- `title` (optional, string): Text for the title bar, such as a file name.
- `wrap` (optional, integer, default `100`, range 40..200): Lines longer than this many characters continue on the next row.
- `scale` (optional, integer, default `2`, range 1..2): Pixel density: 2 gives a sharp picture for high-resolution screens, 1 a smaller file.
- `format` (optional, string, one of `png`, `webp`, `jpg`, default `"png"`): Picture format.

## Example 1: Python in a dark window

```json
{"input":{"code":"def greet(name):\n    return f\"Hello, {name}!\"\n\nprint(greet(\"world\"))","language":"python","title":"greet.py"},"wait":30}
```

## Example 2: SQL with line numbers, light theme, no border

```json
{"input":{"code":"SELECT name, COUNT(*) AS orders\nFROM customers\nJOIN orders USING (customer_id)\nGROUP BY name\nORDER BY orders DESC\nLIMIT 10;","theme":"light","line_numbers":true,"window":false,"padding":0,"scale":1},"wait":30}
```

## Example 3: Detected JavaScript as WebP

```json
{"input":{"code":"const total = items\n  .filter((item) => item.inStock)\n  .reduce((sum, item) => sum + item.price, 0);","theme":"dracula","background":"#bd93f9","format":"webp"},"wait":30}
```

**Which languages are supported?** Several hundred, including Python, JavaScript, TypeScript, HTML, CSS, SQL, Bash, Go, Rust, Java, C, C++, C#, PHP, Ruby, YAML, JSON and Markdown. Auto-detection covers the common ones; name the language for anything else.

**What happens to long lines and tabs?** Tabs become four spaces. Lines longer than the "wrap" setting continue on the next row, and with line numbers on, the continued row has no number.

**What are the limits?** Up to 20,000 characters and 200 lines. For longer files, share the part that matters.

**Why is the picture twice as large as I expected?** Scale 2 doubles the pixels so the text stays sharp on phones and high-resolution screens. Choose scale 1 for the plain size.
