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

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

1 Like

Why not use selectOutput() instead and let the user deside the destination path/file?
(I always do whenever I want to get outside the sketch folder)

1 Like

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

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

</> 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

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


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

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

but as @Tiemen tested, also

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

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

1 Like

Hadn’t considered that, thanks for sharing! :slight_smile:

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?

hm, i made a test with literally

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.


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.

1 Like

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.

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
???

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

2 Likes

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…

1 Like

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
Urban Dictionary: Cockpit Trouble

2 Likes

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?

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.

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.

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

possibly releated “available” links:

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

1 Like