I'm running my processingjs sketch locally and I'm trying to save a PNG of my canvas but I can't get the regular commands saveCanvas("image", 'jpg'); and save("diagonal.tif"); to work.
Does anyone have a tip on how to get this done?
Cheers, Thales
I'm running my processingjs sketch locally and I'm trying to save a PNG of my canvas but I can't get the regular commands saveCanvas("image", 'jpg'); and save("diagonal.tif"); to work.
Does anyone have a tip on how to get this done?
Cheers, Thales
Questions like these are best answered by looking in the reference.
Take a look at the documentation for save()
and saveFrame()
. I'm not sure where saveCanvas()
is coming from, but I don't see it in the Processing.js reference. Are you thinking of P5.js?
Anyway, the documentation says:
These files are saved to the sketch's folder, which may be opened by selecting "Show sketch folder" from the "Sketch" menu.
This makes me suspicious that these were only designed to be used from the Processing editor.
Take a look in your developer tools to check the JavaScript console for errors. What do you see when you try to call the save()
or saveFrame()
functions?
I'd also recommend googling "processing.js save image" for a ton of results, including:
If you still can't get it working, please link to a CodePen or JSFiddle with a simplified MCVE that demonstrates the problem.