# Trying to use save() to save an image to absolute path folder

**URL:** https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293
**Category:** Beginners
**Created:** [August 10, 2019, 3:17pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293 "2019-08-10T15:17:13Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![jeffmarc](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jeffmarc](https://discourse.processing.org/u/jeffmarc)
#### Post date: [August 10, 2019, 3:17pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/1 "2019-08-10T15:17:13Z")

</div>

save(“C:/myfolder/image.png”);

It doesn’t get written to the C:/myfolder directory.

After searching C:/ it appears in Windows recent folder

save() description says it is saved by default in the sketch folder.  
If i don’t give path it does indeed appear in that folder OK.  
But description says that an absolute path can be used instead.

What gives? Does this just not work ?

Thanks  
Jeff Marc

---

<div class="post-metadata">

### Author: ![LuckSmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lucksmith/32/5805_2.png) [@LuckSmith](https://discourse.processing.org/u/LuckSmith)
#### Post date: [August 10, 2019, 3:22pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/2 "2019-08-10T15:22:52Z")

</div>

Why not use [selectOutput()](https://processing.org/reference/selectOutput_.html) instead and let the user deside the destination path/file?  
(I always do whenever I want to get outside the sketch folder)

---

<div class="post-metadata">

### Author: ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)
#### Post date: [August 10, 2019, 10:57pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/3 "2019-08-10T22:57:16Z")

</div>

Apparently you’re using curly quotes instead of straight quotes. Replacing these quotes worked for me and the image was written to _C:/myfolder/image.png_

 ![jeffmarc](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7e9d93e0f1e136f7ef529a2b03acacf10ffea38b.png)

---

<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: [August 11, 2019, 12:53am UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/4 "2019-08-11T00:53:15Z")

</div>

hi @Tiemen,  
i not think OP uses that  
curly quotes

it is just happening ( by the forum topic editor ) when you post code here  
“test”  
instead inside

```auto
</> code tag

```

`"test"`

* * *

@jeffmarc at first, processing is a project structured IDE  
so it supports firstly a relative file read and save.  
they wanted to make it very smart so the  
read operations use the sketch path AND its sub dir /data/  
write can obviously only use one, here the sketchpath

so i recommend following coding

```auto
String outfile = "data/test.png";
void setup(){}
void draw(){}
void keyPressed() {
  save(outfile); 
  println("saved to "+outfile);
}

```

the /data/ dir is created automatically  
and please use IDE // File / save as / first

warning: there are libs what do not support that same handling…

to know more about processing settings use [this](https://discourse.processing.org/t/p3d-background-refresh-issue/13237/4)

* * *

now for a absolute path,  
esp in case you use also WIN 10 & Processing 3.5.3 can use

```auto
String outfile = "c:\\Users\\Public\\Pictures\\test.png";

```

but as @Tiemen tested, also

```auto
String outfile = "c:/Users/Public/Pictures/test.png";

```

works.  
please note keyPressed needs a mouseclick on the CANVAS ( get focus ) first.

---

<div class="post-metadata">

### Author: ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)
#### Post date: [August 11, 2019, 10:48am UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/5 "2019-08-11T10:48:34Z")

</div>

> [@kll](#):
>
> it is just happening ( by the forum topic editor ) when you post code here  
> “test”

Hadn’t considered that, thanks for sharing! 🙂

---

<div class="post-metadata">

### Author: ![jeffmarc](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jeffmarc](https://discourse.processing.org/u/jeffmarc)
#### Post date: [August 11, 2019, 4:12pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/6 "2019-08-11T16:12:43Z")

</div>

Neither of these methods give any error, however , the file does not appear in the directory.  
Could it be a Windows setting that is not allowing it to be written?

---

<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: [August 11, 2019, 4:24pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/7 "2019-08-11T16:24:59Z")

</div>

hm, i made a test with literally

```auto
String outfile = "c:/myfolder/test.png";

```

and that folder was created and the file was written,  
but i am on Win 10 as usual admin user ( but was not asked for permission )  
( a linux OS would never allow to write there without “sudo” )

is it possible that you are login as a user with reduced privileges?  
Windows might prevent you from writing there.  
you should test that manually from file manager first.

* * *

anyhow back to default, you did confirm that writing to  
sketchbook path (or its /data/ ) path works fine?  
anyhow it would also confirm that processing installation is OK  
and  
JAVA execution not blocked by windows defender.

* * *

> [@jeffmarc](#):
>
> After searching C:/ it appears in Windows recent folder

what / where is that? and does that still happen?  
again, if windows is in a condition ( like hard disk error… )  
a manual test to create folder and file would check on that.

---

<div class="post-metadata">

### Author: ![jeffmarc](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jeffmarc](https://discourse.processing.org/u/jeffmarc)
#### Post date: [August 11, 2019, 8:20pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/8 "2019-08-11T20:20:16Z")

</div>

Yes , if i just use  
save(“test.jpg”) it appears in the sketch folder

I am using win 10 pro signed in as admin  
only account on PC no one else  
I use PC for development only  
I regularly copy files from one dir to another and create dir from thumb drives  
no problem

I just wanted to confirm with someone it does work

I don’t understand why it doesn’t either.  
will try on another PC and see what happens.

---

<div class="post-metadata">

### Author: ![jeffmarc](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jeffmarc](https://discourse.processing.org/u/jeffmarc)
#### Post date: [August 11, 2019, 8:39pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/9 "2019-08-11T20:39:45Z")

</div>

Tested OK on my Win 8.1 laptop.  
saved to the C:/avsufa directory OK  
So must be a windows thing on win 10 pro but I don’t know what.  
I am signed in as admin , what else do you need to write to any directory?  
Using Processing 2.2.1  
Works fine with Win 8.1  
???

---

<div class="post-metadata">

### Author: ![jeffmarc](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jeffmarc](https://discourse.processing.org/u/jeffmarc)
#### Post date: [August 11, 2019, 8:48pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/10 "2019-08-11T20:48:02Z")

</div>

Got it. Cockpit error, my fault.

Code I was using deleted file if it existed before rewriting so i never saw it appear

All is well. sorry

---

<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: [August 12, 2019, 1:06am UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/11 "2019-08-12T01:06:11Z")

</div>

> [@jeffmarc](#):
>
> Cockpit error

sorry, i am new to win 10  
please what is that?

possibly “reboot or even cold restart” would have been a good tip?  
as recently i read here about, that many open?running java’s give processing a hard time…

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [August 13, 2019, 2:58pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/12 "2019-08-13T14:58:26Z")

</div>

> [@kll](#):
>
> i am new to win 10  
> please what is that?

It is a phrase, like “pilot error”, that is a funny way of saying “the person in the cockpit in charge of flying / operating (me) was the source of the error, not the plane / machine / code” [Pilot error - Wikipedia](https://en.wikipedia.org/wiki/Pilot_error)  
[Urban Dictionary: Cockpit Trouble](https://www.urbandictionary.com/define.php?term=Cockpit%20Trouble)

---

<div class="post-metadata">

### Author: ![jeffmarc](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jeffmarc](https://discourse.processing.org/u/jeffmarc)
#### Post date: [August 15, 2019, 6:53pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/13 "2019-08-15T18:53:34Z")

</div>

Programmer error.  
Now I have new issue.  
camavailable() is true for one image grab then will not grab again, goes to false and stays that way.

I have another program that grabs an image in the draw loop and it works fine.  
Both on the same computer , same camera .  
I run one and it works grabbing continuous images  
the other grabs one and stops

Any clue would have that effect? there are no camStop() commands in either program.

Both start the camera in the setup section then the draw loop

I can’t find anything that should cause a disconnect once camStart() issued is setup.

Any ideas?

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [August 15, 2019, 7:06pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/14 "2019-08-15T19:06:01Z")

</div>

Two programs, same libraries and same camera, one works and the other doesn’t?

I’d suggest starting by stripping down your broken program until you get down to just the image grab and display – nothing else. At some point, you will might remove something “unrelated” and be surprised when it start working.

---

<div class="post-metadata">

### Author: ![jeffmarc](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jeffmarc](https://discourse.processing.org/u/jeffmarc)
#### Post date: [August 15, 2019, 7:14pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/15 "2019-08-15T19:14:10Z")

</div>

OK , i know i can do that , just wondered if anybody had a clue what might cause this.  
I have put test code in draw() loop to grab an image every 10 frames.  
It counts up to 10 grabs a frame and then never gets reset by camavailable() true .  
But it never goes true again so its just looping doing nothing and i get one image grabbed and displayed  
its a simple loop: if framecount=10 and camavailable=true then camread, display image , reset frame count to 0, increment framecount in draw loop

I’ll start stripping it down.

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [August 15, 2019, 7:17pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/16 "2019-08-15T19:17:10Z")

</div>

I can’t think of anything – maybe @neilcsmith might have seen this before?

possibly releated “available” links:

> <https://github.com/processing/processing-video/issues/32>

- [https://forum.processing.org/two/discussion/20902/processing-camera-while-cam-available-question](https://forum.processing.org/two/discussion/20902/processing-camera-while-cam-available-question)

---

<div class="post-metadata">

### Author: ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)
#### Post date: [August 16, 2019, 1:29pm UTC](https://discourse.processing.org/t/trying-to-use-save-to-save-an-image-to-absolute-path-folder/13293/17 "2019-08-16T13:29:29Z")

</div>

Sorry, no idea, not a mind reader - no code, no answer! 😄
