Sparragus
Sparragus

Reputation: 913

What is the filename of last saved frame using saveFrame()

In Processing, you can save a frame using saveFrame('output-####.png'). That will save the frame, name it output-0001.png, and place it in the sketch folder. The filename is always different because it follows a sequence, replacing the #### with the next number in the sequence.

However, saveFrame returns void. I wish it returned the String of the filename, but it doesn't.

How can I find out the name of the frame saved with saveFrame(...)

Upvotes: 2

Views: 1079

Answers (1)

Petros Koutsolampros
Petros Koutsolampros

Reputation: 2800

You can always wrap that with a function to tell you the frameCount at that point:

void draw() {
  println(saveFrameAndGetFileName("output-####.png"));
}
String saveFrameAndGetFileName(String fileName) {
  saveFrame(fileName);
  String [] parts = fileName.split("####"); //getting pedantic here...
  return parts[0] + frameCount + parts[1];
}

or even more simply:

void draw() {
  saveFrame("output-####.png");
  println("output-" + frameCount + ".png");
}

EDIT: Fixed to give you the actual filename

Upvotes: 6

Related Questions