Displaying a loop of generated images
Posted: Wed Aug 12, 2009 12:02 am
Good morning!
I have some simple test code (below) that generates a random image of 100x100 pixels. I have a loop to generate a new image 25 times. I want to see each of those 25 runs. But this code only shows what may be the last image. What did I do wrong?
How can I automatically update newly generated images in PHP?
Thank you for your expertise!
]
I have some simple test code (below) that generates a random image of 100x100 pixels. I have a loop to generate a new image 25 times. I want to see each of those 25 runs. But this code only shows what may be the last image. What did I do wrong?
How can I automatically update newly generated images in PHP?
Thank you for your expertise!
Code: Select all
<?php
header ("Content-type: image/png");
$ImageSize = 100;
$Img = imagecreatetruecolor($ImageSize, $ImageSize);
for ($Runs = 0; $Runs < 25; $Runs++) {
for ($XVal = 0; $XVal < $ImageSize; $XVal++) {
for ($YVal = 0; $YVal < $ImageSize; $YVal++) {
$RedVal = rand(0, 255); $GreenVal = rand(0, 255); $BlueVal = rand(0, 255);
$PixelClr = imagecolorallocate($Img, $RedVal, $GreenVal, $BlueVal);
imagesetpixel($Img, $XVal, $YVal, $PixelClr);
imagecolordeallocate($Img, $PixelClr);
}
}
imagepng($Img);
imagedestroy($Img);
}
?>