# \[SOLVED\] Downloading image, saving to specific folder

**URL:** <https://discourse.processing.org/t/solved-downloading-image-saving-to-specific-folder/11784>\
**Category:** Coding Questions\
**Created:** [June 2, 2019, 7:42pm UTC](https://discourse.processing.org/t/solved-downloading-image-saving-to-specific-folder/11784 "2019-06-02T19:42:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SoulT](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@SoulT](https://discourse.processing.org/u/SoulT)\
**Post date:** [June 2, 2019, 7:42pm UTC](https://discourse.processing.org/t/solved-downloading-image-saving-to-specific-folder/11784/1 "2019-06-02T19:42:35Z")

</div>

Howdy guys,

I’m trying to set up a basic script that will download an image, and then save the image as a transparent PNG to a specific folder. Here’s what I have so far (I’ve replaced the url, for privacy sake. The actual URL can be accessed and the program will display the image, if I remove the entire if statement):

```auto
boolean saved = false;
PImage spr1; 
PGraphics sprOut;

void setup()
{
  spr1 = loadImage("URL HERE");
  surface.setSize(spr1.width, spr1.height);
  sprOut = createGraphics(width, height);
}

void draw()
{
  image(spr1, 0, 0);
  
  if (saved == false)
  {
    sprOut.save("C:/PetStuff/Pet0/test.png");
    saved = true;
  }
}

```

This throws a null pointer exception, and I cannot for the life of my figure out why. Any help would be greatly appreciated.

Fixed the issue by going about things a different way.

It was incredibly simple, and it saves as a transparent PNG.

```auto
PImage spr1; 

void setup()
{
  spr1 = loadImage("MY URL");
  image(spr1, 0, 0);
  spr1.save("C:/PetStuff/Pet0/test.png");
}

```
