Bug 1124 : PImage.save() does not create parent directories
Last modified: 2009-02-20 06:54




Status:
RESOLVED
Resolution:
INVALID -
Priority:
P2
Severity:
normal

 

Reporter:
fjen
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2009-01-17 00:46
PImage.save() will not create parent directories (contrary to saveFrame()) when provided with a full path which will lead to an FileNotFoundException saying the image file can not be found (and is highlighting the wrong line).

java.io.FileNotFoundException: /Users/fjenett/Documents/Processing/faces/faces_001/saves/20090117/093445_361_12160x9120.tif
(No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
at processing.core.PImage.save(PImage.java:2695)
at faces_001.threaded(faces_001.java:83)
at faces_001$1.run(faces_001.java:44)


simple example:

PImage i = new PImage( 100, 100, ARGB );
i.save( sketchPath( "faa/foo.tif" ) );


thanks!
F
Additional Comment #1 From fjen 2009-01-17 00:47
(thanks meaning thanks for looking into it ... not thanks for the err!)
Additional Comment #2 From fry 2009-02-20 06:51
Ah, I should have looked at your example more closely. Never use "new
PImage()", only createImage(). This is noted in the createImage() reference
(we don't even cover new PImage() in the PImage reference).
Additional Comment #3 From fry 2009-02-20 06:54
Also, some further clarification. When using createImage(), you don't need
to use sketchPath() anymore, and intermediate folders will be created.

When using an absolute path (not in the sketch folder), we can't create the
intermediate folders, because there's no way to discern between a bad
(non-absolute) path being passed in, and subfolders in an arbitrary
location that don't exist that need to be created.