# loadImage() and image()

### Example

<figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2F8HKVUvxnHMwNTWzm4uvy%2Funtitled.png?alt=media&#x26;token=914069b9-e09d-450f-bb34-6b5dfa8aecb1" 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 %}
