0

I am working on generative art in Processing with Java, I am looking to create a large batch of abstracts, and then curate them down to the best examples. currently, I am doing this sort of manually by running the script that has a save function, saving a numbered image as a JPG, but each time it makes one image and I have to manually change the number and go again. this is extremely tedious.

What I would like to do is add some code that would run a loop where an image would be created based on the rules I've set, then save it sequentially (if possible, random alphanumeric names would be fine as I could batch rename them later).

I am certainly open to other arrangements like doing this in python or some other language but then id likely have to rewrite the code for the drawing and I'm sort of hotwiring this thing.

talk to me like I am a total novice because I am not much further along than that.

Nayana Chandran
  • 1,416
  • 1
  • 16
  • 30
mVZ
  • 1

1 Answers1

0

saveFrame()'s got you covered: use the # character as a placeholder for a frame number digit and that's it!

For example:

saveFrame("abstract-frame-######.png");

will save the first frame it's called as abstract-frame-000001.png, the seocnd as abstract-frame-000002.png, etc.

If you're not happy with this format you can make your own, for example using a timestamp (e.g. date functions such as day(), month(), year() ,etc.) paired with a number format function (e.g. nf(), nfc(), nfp(), etc.) and pass the final string to save()

e.g.

save("abstract-frame"+nf(day(),2)+"-"+nf(month(),2)+"-"+nf(year(),4)+"-"+nf(hour(), 2)+"-"+nf(minute(),2)+"-"+nf(second(),2)+"-"+nf(millis(),3)+".png");

You shouldn't need to rename anything later. As long you know what your naming rule is and play with strings a bit you should be able to put together the filename you want.

One last tip is you might want to save frames to a separate folder. e.g.

saveFrame("session1/frames/abstract-frame-######.png");

This would make keep image files separate from the source code and it would make easy to separate different "runs" with potentially different parameters. Again, you could use parameter values to make up the folder name and therefore have some hints to what parameters produced each particular folder for images.

George Profenza
  • 50,687
  • 19
  • 144
  • 218