In my code I try to save 27 images into my downloads folder but when i run the code it only saves a maximum of 10 images into my downloads folder. I logged my results in the console and the code seems to be running correctly. Initially i thought Chrome or the online p5.js Web Editor had a problem with too many save requests being sent at the same time so i tried to put a few seconds of delay after each save but that approach didn't work. Is there a limit to how many downloads Chrome allows from a single site (maybe within a certain amount of time)?
I know the code is not efficient but speed is not important now as I am just testing something and the for loops are structured that way for a specific reason.
let t, w, img, mod, p, dim;
function preload() {
//image loaded
img = loadImage("rose.jpg");
}
function update(pos, a, b, c) {
let i = img.pixels[pos + a];
let j = img.pixels[pos + b];
let k = img.pixels[pos + c];
let l = img.pixels[pos + 3];
return [i, j, k, l];
}
function setup() {
// modified image created and its pixels loaded
image(img, 0, 0, width, height);
mod = createImage(img.width, img.height);
img.loadPixels();
mod.loadPixels();
// 3 for loops make counter for image names
for (let i = 0; i < 3; i++) {
for (let j = 0; j < 3; j++) {
for (let k = 0; k < 3; k++) {
//loop through the pixels of the image
for (let l = 0; l < mod.height * 4; l++) {
//m is incremented by 4 so each set of rgba values can be manipulated by the update function
for (let m = 0; m < mod.width; m += 4) {
//pixel index is calculated and update returns an array of pixel values
w = img.width * l + m;
t = update(w, i, j, k);
for (let n = 0; n < 4; n++) {
mod.pixels[w + n] = t[n];
}
}
}
//canvas is created and image is displayed
mod.updatePixels();
dim = 550;
createCanvas(dim, dim);
image(mod, 0, 0, width, height);
//save request
save(mod, ("edited" + i + j + k + ".jpg"));
}
}
}
}