<cfscript>
original_image = imageRead("./example.jpg");
original_image_width = imageGetWidth(original_image);
original_image_height = imageGetHeight(original_image);
number_of_squares = 100;
square_width = original_image_width / sqr(number_of_squares);
square_height = original_image_height / sqr(number_of_squares);
square_array = arrayNew(1);
new_image = imageNew("", original_image_width, original_image_height, "rgb", "FFFFFF");
i = 1;
for (y = 0; y < original_image_height; y = y + square_height) {
for (x = 0; x < original_image_width; x = x + square_width) {
square_array[i] = imageCopy(original_image, x, y, square_width, square_height);
i = i + 1;
}
}
createObject("java", "java.util.Collections").Shuffle(square_array);
i = 1;
for (y = 0; y < original_image_height; y = y + square_height) {
for (x = 0; x < original_image_width; x = x + square_width) {
imagePaste(new_image, square_array[i], x, y);
i = i + 1;
}
}
</cfscript>
<h3>Original Image</h3>
<p><cfimage action="writeToBrowser" source="#original_image#" format="jpg"></p>
<h3>Randomized Image</h3>
<p><cfimage action="writeToBrowser" source="#new_image#" format="jpg" /></p>