> ## Documentation Index
> Fetch the complete documentation index at: https://jetxl.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Images

> Place logos, diagrams and generated charts on a sheet

Images anchor to a rectangle of cells. Give a path or raw bytes, plus the corners.

```python theme={null}
jet.write_sheet_arrow(
    df.to_arrow(),
    "report.xlsx",
    images=[{
        "path": "company_logo.png",
        "from_col": 0, "from_row": 0,
        "to_col": 2,   "to_row": 4,
    }],
)
```

<Note>
  Image coordinates are 0-based on both axes, unlike cell styles and tables where rows are 1-based.
</Note>

## From a file

<ParamField path="path" type="str" required>Path to the image on disk.</ParamField>
<ParamField path="from_col" type="int" required>0-based left column.</ParamField>
<ParamField path="from_row" type="int" required>0-based top row.</ParamField>
<ParamField path="to_col" type="int" required>0-based right column.</ParamField>
<ParamField path="to_row" type="int" required>0-based bottom row.</ParamField>

## From bytes

Use this when the image never touches disk, whether downloaded, read from a database, or generated in the same script.

<ParamField path="data" type="bytes" required>Raw image bytes.</ParamField>
<ParamField path="extension" type="str" required>Format, such as `"png"`. Required, since there's no filename to infer from.</ParamField>

```python theme={null}
import matplotlib.pyplot as plt
import io

fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4], [10, 20, 15, 25])

buffer = io.BytesIO()
fig.savefig(buffer, format="png", dpi=150, bbox_inches="tight")
plt.close(fig)

jet.write_sheet_arrow(
    df.to_arrow(),
    "report.xlsx",
    images=[{
        "data": buffer.getvalue(),
        "extension": "png",
        "from_col": 5, "from_row": 1,
        "to_col": 15,  "to_row": 20,
    }],
)
```

<Tip>
  This is the practical route to chart types Jetxl doesn't offer natively. Render it with matplotlib or plotly and embed the PNG. The trade-off is that the result is a picture, so it won't update when the underlying cells change the way a native [chart](/guides/charts) does.
</Tip>

## Formats

| Format | Extensions      | Best for                                               |
| ------ | --------------- | ------------------------------------------------------ |
| PNG    | `.png`          | Logos and screenshots. Lossless, supports transparency |
| JPEG   | `.jpg`, `.jpeg` | Photographs. Smaller, no transparency                  |
| GIF    | `.gif`          | Simple graphics, limited palette                       |
| BMP    | `.bmp`          | Uncompressed Windows bitmaps                           |
| TIFF   | `.tiff`, `.tif` | Print-quality source images                            |

## Sizing

The rectangle you give determines the displayed size, so aspect ratio is yours to manage. A wide anchor around a square logo stretches it.

<AccordionGroup>
  <Accordion title="Logos and icons" icon="star">
    Roughly 2 to 4 columns by 5 to 8 rows.
  </Accordion>

  <Accordion title="Photographs" icon="camera">
    Roughly 4 to 6 columns by 8 to 12 rows.
  </Accordion>

  <Accordion title="Charts and diagrams" icon="chart-area">
    Roughly 6 to 10 columns by 12 to 20 rows.
  </Accordion>
</AccordionGroup>

<Warning>
  Jetxl embeds images whole. A handful of multi-megabyte photographs produces a workbook that's slow to open and awkward to email, so resize before embedding.
</Warning>
