Hello, when I run this code I get this message. There are only 16 images in the sketch and they are in the data/images folder.
loading…
32images loaded!
The file data/images/._04.jpg contains bad image data, or may not be an image.
IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0
int amount = int(random(1, 10));
PGraphics[] layers = new PGraphics[amount];
PGraphics[] masks = new PGraphics[amount];
import java.io.File;
String [] imageFileNames;
StringList images;
void setup() {
size(1200, 900);
java.io.File folder = new java.io.File(dataPath("images"));
imageFileNames = folder.list();
images = new StringList();
println("loading…");
// Load the image-files and push thems to imagess-arrayList
for (int i = 0; i < imageFileNames.length; i++) {
String filename = imageFileNames[I];
if (filename.indexOf("Store") == -1) {
images.push("data/images/"+filename);
}
}
println(images.size() + "images loaded!");
for (int i = 0; i < layers.length; i++) {
layers[i] = createGraphics(width, height);
masks[i] = createGraphics(width, height);
}
}
PGraphics l, m;
PImage img;
void draw() {
amount = int(random(3, 30));
background(0);
//blendMode(SCREEN);
for (int i = 0; i < layers.length; i++) {
l = layers[I];
img = loadImage(images.get(int(random(images.size()))));
img.resize(width, 0);
l.beginDraw();
l.clear();
l.push();
l.image(img, 0, 0);
l.pop();
l.endDraw();
m = masks[I];
m.beginDraw();
m.background(#FFFFFF);
m.noStroke();
m.fill(0);
m.beginShape();
for (int j = 0; j < 12; j++) {
float x = random(-width, width*2);
float y = random(-height, height*2);
m.curveVertex(x, y);
}
m.endShape();
if (random(1) < 0.1) {
m.circle(random(width), random(height), random(width/2));
}
m.endDraw();
l.mask(m);
image(l, 0, 0);
}
// saveFrame("out/###.png");
}