Save and print (on paper) multiple images


Using this tutorial, I’m able to print images on paper ones they’re saved.

What it does now though, is overwrite the previous existing image everytime.

I would like to save all the images so I’m using this code as reference.

What I can’t seem to figure out is how to tell processing to print the last file instead of the first one.

I know I should add some sort of counter to this sentence printImage("/Users/mithru/Desktop/printDemo/image_to_print.png");
but I’m not experienced enough to figure out what this sentence has to be.


1 Like

Hi @friedadedoncker,

Basically you first save your images using saveFrame() with some pattern like:


// line-00001.png
// line-00002.png
// line-00003.png
// ...

This is exactly what you need to do.

Exercise: make a program that print the above filenames in the console (line-######.png) up to 100 using println(). (hint: how do you add a number to a string? How do you add padding to a number 500005 ?)

Exercise: if you don’t know the exact number of frames you saved, make a program that read files from where you saved the images and print them. (hint: try using sketchPath())

Distinguish between saving and loading.
Both have difficulties.


When saving, do you want to overwrite the old images?
Otherwise, you need to move the old images prior to running the Sketch again. I think that saveFrame() overwrites old images.
When you move old images manually you can always print out the entire folder anyway.
You could also write an enhanced version of saveFrame that checks the highest number of the existing files and starts from there - like 00005 plus 1.


When loading/ printing: when there are still old folders in the Sketch you can store the last file name that you printed and start
printing from this Number: 00005.

Presumably you can also store the time stamp of the file last printed and make a list of all files and sort it by date / time and then print all that are newer than the old datetime stamp

But this seems complicated

1 Like