> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/gum/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/gum/cli/cli/screenshot.md).

# screenshot

```
gumcli screenshot <project.gumx> <element> [--output <path>] [--width <px>] [--height <px>] [--backend <name>] [--background <hex>]
```

Renders a Gum Screen or Component to a PNG file. The element is laid out and drawn using the same backend a shipped game would use, so the output is pixel-accurate and suitable for visual regression testing, documentation screenshots, or asset pipelines.

## Arguments

* `<project.gumx>` — Path to the `.gumx` project file.
* `<element>` — Name of the Screen or Component to render (for example, `MainMenu` or `Controls/Button`).

## Options

* `--output` — Path for the output PNG file. Defaults to `<element>.png` in the current directory.
* `--width` — Width of the output image in pixels. Defaults to the project canvas width.
* `--height` — Height of the output image in pixels. Defaults to the project canvas height.
* `--backend` — Rendering backend to use: `monogame` (default, DesktopGL) or `raylib`.
* `--background` — Background color to clear to before rendering, as 6-digit (`RRGGBB`) or 8-digit (`RRGGBBAA`) hex, with or without a leading `#`. Defaults to fully transparent.

## Examples

```
gumcli screenshot MyProject/MyProject.gumx MainMenu
gumcli screenshot MyProject/MyProject.gumx Controls/Button --output button.png
gumcli screenshot MyProject/MyProject.gumx MainMenu --width 1920 --height 1080
gumcli screenshot MyProject/MyProject.gumx MainMenu --backend raylib
gumcli screenshot MyProject/MyProject.gumx MainMenu --background 1E2A38
```

Output on success:

```
Screenshot written to: /full/path/to/MainMenu.png
```

## Notes

* Works cross-platform — the default `monogame` backend uses DesktopGL, not a Windows-specific rendering path.
* Any fonts referenced by the element must already exist in the project's `FontCache/` folder. Run [`gumcli fonts`](/gum/cli/cli/fonts.md) first if fonts are missing.
* Bitmap content (sprites, nine-slices, text) is rasterized into the PNG at the requested resolution.
* To compare the two backends' output for every element in a project at once, see [`diff-screenshots`](/gum/cli/cli/diff-screenshots.md).
* Rendering against the default transparent background can make some visual differences (a semi-transparent panel or border, for example) hard to see once the image is opened in isolation. Use `--background` to composite against an opaque color, ideally the same clear color your game actually uses, for a more representative comparison.

## Exit Codes

| Code | Meaning                                                                                                       |
| ---- | ------------------------------------------------------------------------------------------------------------- |
| 0    | Screenshot written successfully                                                                               |
| 1    | Rendering failed (for example, the named element does not exist)                                              |
| 2    | Project file not found, `--backend` is not `monogame` or `raylib`, or `--background` is not a valid hex color |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flatredball.com/gum/cli/cli/screenshot.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
