Blending random images


Hello all, I am hoping to get some advice on a problem I have. What I want to do is to randomly take images from a folder and blend them together. I’m not a programmer, I’m into photography, so the learning curve is very steep for me! However I have made some progress.

This is what I’ve got so far:

PImage frame0, frame1, frame2, frame3, frame4, frame5, frame6;
PImage [] images = new PImage [7];
int num = 7;

//images declared, array setup, num setup

void setup () {
  size (720, 480);
  for (int i = 0; i < images.length; i++) {
   images[i] = loadImage("frame"+i+".png");
//screen size, load images in to sketch
 for (int i = 0; i < images.length; i++) {
    int index = int(random(0, images.length));

//display images randomly

void draw () {
 for (int i = 0; i < images.length; i++) {
    int index = int(random(0, images.length));

I know the part in void draw is a crude way to cycle through the images on screen and it’s not a great approach, but coupled with framerate was the best I could currently do. However, I haven’t implemented any blending here so far. I’ve seen other examples online where people simply used image.blend, such as this one:

void setup(){
  //copy of one
  //combine part of two with part of the copy of one

void draw(){
  //blended image

So far I just can’t seem to integrate these two. Can anyone through some light on the way forward? Should I be looking at creating a Class to do the blending?


When you say “blend them together” – do you mean a series of cross-fades over time, like an animation? Or do you mean transparent compositing is your goal – you want all seven, each drawn at 1/7th transparency, creating a final still image?

Should the sequence be ordered (e.g. by filename) or random?

Will it always be seven images, or do you want to load all of the (jpg, png, whatever) files in a directory?


Hi Jeremy, thanks for your reply! Apologies it took so long to get back to you, I appreciate your response as it encourages my thinking about my approach. I was hoping to using blend modes at random. However I have not had much success so far, I have seen people use syntax like blend. I know there is blend () and blendMode () which could be used.

It would be done at random, and I am thinking some kind of timer would be necessary or some instance of framerate acting as a timer. The images would be png and stored in the data folder of the Processing sketch.

I hope to look at some tips a very nice person gave me and tomorrow will follow up with my efforts and reply again here, college has been quite busy at the moment but I’d like to make headway in this!