> For the complete documentation index, see [llms.txt](https://docs.pydraw.graphics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pydraw.graphics/quick-reference/image.md).

# Image

{% hint style="info" %}
Image is a Renderable with some methods modified, add, or removed.

[Renderable Quick Reference](/quick-reference/renderable.md)\
[Image Documentation](https://pydraw.graphics/api/pydraw.html#pydraw.objects.Image)
{% endhint %}

{% hint style="warning" %}
If you have pyDraw installed as the library file in your project directory, you must ensure '[Pillow](https://pillow.readthedocs.io/en/stable/installation.html)' is installed, or you won't be able to resize the image, modify any image attributes, or use image types other than PNG, GIF, and PPM.
{% endhint %}

## Initialization

You can create an image with a similar constructor:

*(Supported image types: PNG, GIF, JPG, and PPM)*

```python
image = Image(screen, image_file, x, y, width, height)
```

{% hint style="info" %}
Again, if you are not using the PIP version of pyDraw, you may need to install '[Pillow](https://pillow.readthedocs.io/en/stable/installation.html)' before passing the width and height into the constructor.
{% endhint %}

## Color

It is still possible to call the `color()` method and colorize the image:

```python
image.color(color)  # Tints the image by the passed Color
```

## Flip

You can flip the image across the X or Y axes ([the plural of axis 😜](https://www.grammar-monster.com/plurals/plural_of_axis.htm)):

```python
image.flip(axis)  # accepts 'x' or 'y'
```

## Animation (GIF)

It is possible to access the individual frames of an animated GIF file by first calling this after initialization:

```python
image.load()
```

Then you can access individual frames via:

```python
image.frame()  # Get the current frame
image.frame(frame)  # Set the current frame
```

Or you can just push the frame forward by one with:

```python
image.next()  # Goes to next frame.
```

{% hint style="info" %}
`next()` will automatically loop back to index 0 when it reaches the last frame.
{% endhint %}

The total number of frames is available too:

```python
image.frames()  # Returns integer number of frames
```


---

# 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.pydraw.graphics/quick-reference/image.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.
