# Background image doesn't load

**URL:** <https://discourse.processing.org/t/background-image-doesnt-load/46654>\
**Category:** Beginners\
**Created:** [July 3, 2025, 10:43am UTC](https://discourse.processing.org/t/background-image-doesnt-load/46654 "2025-07-03T10:43:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![henk\_lamers](https://avatars.discourse-cdn.com/v4/letter/h/c67d28/32.png) [@henk\_lamers](https://discourse.processing.org/u/henk_lamers)\
**Post date:** [July 3, 2025, 10:43am UTC](https://discourse.processing.org/t/background-image-doesnt-load/46654/1 "2025-07-03T10:43:34Z")

</div>

I get the message: background image must be the same size as your application.

The image is 1000 x 1000. Checked that in Photoshop.

```processing
PImage BackgroundGradient;

void setup () {
  size (1000, 1000);
  smooth();
  noStroke ();

  // Load the background image
  BackgroundGradient = loadImage ("gradient.png");
}

void draw() {
  background (BackgroundGradient);
}

```

Working with Processing 4.4.4  
MacStudio 2023  
MacOS Sequoia 15.5

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [July 3, 2025, 12:11pm UTC](https://discourse.processing.org/t/background-image-doesnt-load/46654/2 "2025-07-03T12:11:19Z")

</div>

Hello @henk_lamers ,

Related post here:  
_[Processing Java Background Bug - #2 by glv](https://discourse.processing.org/t/processing-java-background-bug/46644/2)_

Try:

- Displaying image.
- What is _pixelDensity_? Try setting it to 1
- Use _println()_ to display size of image after loading

Report back.

Reference:

- [background() / Reference / Processing.org](https://processing.org/reference/background_.html)
- [pixelDensity() / Reference / Processing.org](https://processing.org/reference/pixelDensity_.html)
- [image() / Reference / Processing.org](https://processing.org/reference/image_.html)
- [println() / Reference / Processing.org](https://processing.org/reference/println_.html)

This works on my W10 PC and loads an image from Wikipedia:

```processing
PImage BackgroundGradient;

void setup () {
  size (1000, 1000);
  smooth();
  noStroke ();

  // Load the background image
  BackgroundGradient = loadImage ("https://upload.wikimedia.org/wikipedia/commons/0/08/1000X1000-01.jpg");
}

void draw() {
  background (BackgroundGradient);
}

```

`:)`

---

<div class="post-metadata">

**Author:** ![henk\_lamers](https://avatars.discourse-cdn.com/v4/letter/h/c67d28/32.png) [@henk\_lamers](https://discourse.processing.org/u/henk_lamers)\
**Post date:** [July 3, 2025, 1:48pm UTC](https://discourse.processing.org/t/background-image-doesnt-load/46654/3 "2025-07-03T13:48:24Z")

</div>

Hello glv

Setting the pixelDensity to 1 solved the problem.  
println (width, height); gives me 1000 1000

Thanks for helping me out!

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [July 4, 2025, 12:18am UTC](https://discourse.processing.org/t/background-image-doesnt-load/46654/4 "2025-07-04T00:18:16Z")

</div>

> [@henk\_lamers](#):
>
> Thanks for helping me out!

You are very welcome!
