16k x 16k Pixel Image Generated by PHP
By Raymond Berg on Feb 9, 2012 in programming
A PHP+GD image generator I created in 2008 was pulled out of the closet and given a [much,much, much] bigger canvas to work with. Pretty fun result. The image is 16,000 pixels squared, about 28MBs in size. It takes about 300MB of RAM for ~30 seconds of processing. The result is quite visually stunning!
Edit: As requested by the great JD Daniel, here’s the code I used to generate it:
<?php
//header("Content-Type: image/jpeg");
$width = 8000; #original 200
$height = 8000; #original 200
$ringWidth = 1; #original 1
$multiplier = 2; #original 2
$inv = false;
$centerX = intval($width / 2);
$centerY = intval($height / 2);
$cumulativeMultiplier = $multiplier;
while(true)
{
$ringSizeX = $width;
$ringSizeY = $height;
// create a 200*200 image
$img = imagecreatetruecolor($width, $height);
if($inv)$color = 255;
else $color = 0;
if($inv)$stepMod = -$ringWidth;
else $stepMod = $ringWidth;
$step = 0;
$w = true;
while($ringSizeX > 0 && $ringSizeY > 0)
{
imagearc($img, $centerX, $centerY, $ringSizeX, $ringSizeY, 0, 360, imagecolorallocate($img, $color+$step,$color+$step,$color+$step));
//echo intval(255 / (max(($ringSizeX+$ringSizeY)/2,1)));
$step += ($cumulativeMultiplier / ($width + $height)) * $stepMod;
//echo "$color n";
if($w) $ringSizeX -= 1;
else $ringSizeY -= 1;
$w = !$w;
}
imagegif($img, "circle$cumulativeMultiplier.gif");
echo "ncircle$cumulativeMultiplier.gif";
imagedestroy($img);
$cumulativeMultiplier = $cumulativeMultiplier * $multiplier;
if($cumulativeMultiplier > 200000000) break;
}
// allocate some colors
// mouth
?>
