# I can\`t load an Image as background

**URL:** https://discourse.processing.org/t/i-can-t-load-an-image-as-background/14849
**Category:** Coding Questions
**Created:** [October 21, 2019, 8:18am UTC](https://discourse.processing.org/t/i-can-t-load-an-image-as-background/14849 "2019-10-21T08:18:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![CyberDodo](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@CyberDodo](https://discourse.processing.org/u/CyberDodo)
#### Post date: [October 21, 2019, 8:18am UTC](https://discourse.processing.org/t/i-can-t-load-an-image-as-background/14849/1 "2019-10-21T08:18:56Z")

</div>

I can`t load an Image as background.

Exception in thread “Thread-212”

```auto
void setup() {
  size( 1366, 768);
    PImage bg;
bg = loadImage("qrC6FvL.jpg");
}
void draw() {

  background(bg);
  fill(0, 255, 0);
  rect (300, 300, 300, 300);
  textSize(32);
  fill(0, 51, 0);
  text("WAHR", 400, 450);

  fill(255, 0, 0);
  rect (700, 300, 300, 300);
  textSize(32);
  fill( 128, 0, 0);
  text("FALSCH", 800, 450);
}

```

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [October 21, 2019, 8:32am UTC](https://discourse.processing.org/t/i-can-t-load-an-image-as-background/14849/2 "2019-10-21T08:32:16Z")

</div>

-a- the variable bg should be global declared, above setup()  
( but loaded in setup() ( correct ) )

-b- be sure that the picture size fits to the canvas size or

```auto
background(bg);

```

will not work.  
can use resize();

* * *

look here first,  
[https://processing.org/reference/image\_.html](https://processing.org/reference/image_.html)

---

<div class="post-metadata">

### Author: ![CyberDodo](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@CyberDodo](https://discourse.processing.org/u/CyberDodo)
#### Post date: [October 21, 2019, 8:46am UTC](https://discourse.processing.org/t/i-can-t-load-an-image-as-background/14849/3 "2019-10-21T08:46:21Z")

</div>

this doesnt work either: @kll

```auto
PImage bg;
void setup() {
size( 1366, 768);
bg = loadImage("qrC6FvL.jpg");
}
void draw() {

  background(bg);
  fill(0, 255, 0);
  rect (300, 300, 300, 300);
  textSize(32);
  fill(0, 51, 0);
  text("WAHR", 400, 450);

  fill(255, 0, 0);
  rect (700, 300, 300, 300);
  textSize(32);
  fill( 128, 0, 0);
  text("FALSCH", 800, 450);
}

```

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 21, 2019, 9:41am UTC](https://discourse.processing.org/t/i-can-t-load-an-image-as-background/14849/4 "2019-10-21T09:41:44Z")

</div>

This code looks good to me

What doesn’t work exactly?

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [October 21, 2019, 9:54am UTC](https://discourse.processing.org/t/i-can-t-load-an-image-as-background/14849/5 "2019-10-21T09:54:32Z")

</div>

i asked you to check the size / or much better /

- instead with `background(bg)`
- start with `image(bg,0,0);`

to see what you got
