# loadImage() and image()

### Example

<figure><img src="/files/X5oBzRZheDOLQCBtu7Cl" alt=""><figcaption></figcaption></figure>

```python
def setup():
    ...
    loadImage("http://donkeyImage.png",'donkey')

def draw():
    ...
    image(assets['donkey'],50,50,300,300)
```

### Syntax

```python
def setup():
    ...
    loadImage("sourceURL",'NAME')

def draw():
    ...
    image(assets['NAME'],x,y,w,h)
```

| Input     | Description                                  |
| --------- | -------------------------------------------- |
| sourceURL | web or local URL of **image** to be loaded   |
| NAME      | name for **variable** of image in code       |
| x         | x co-ordinate of bottom left corner of image |
| y         | y co-ordinate of bottom left corner of image |
| w         | width of image                               |
| h         | height of image                              |

### Description

Loads an image into memory from an external source so that it can be used in code. The **sourceURL** can be a web address (for example **"<http://donkeyImage.png>"**) - this is the usual situation - or the local address if the file is stored with the rest of your code.&#x20;

Once an image is loaded, **image(assets\['NAME'], x, y, w, h)** can be called to draw the image at position **(x, y)** with width **w** and height **h**

{% hint style="info" %}
Find these documents helpful? Let the people who made them help your child learn to code at [**Strivemath**](https://www.strivemath.com/)<mark style="color:blue;">**!**</mark>

We'd love to hear your Feedback/Comments [here](https://docs.google.com/forms/d/e/1FAIpQLSeqorBAGTya-YBRI-VFjJxtgQtCz3ucGDI96K96sNyuaGuvdw/viewform?usp=sf_link).
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://learnpython.strivemath.com/p5-python-web/reference/images-and-audio/loadimage-and-image.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
