= 2); imagefilledrectangle($im, $x, $y, $x + $width/2, $y + $height/2, $color); } // Make a perfect circle in the image middle. $color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255)); $smaller_dimension = min($width, $height); $smaller_dimension = ($smaller_dimension % 2) ? $smaller_dimension : $smaller_dimension; imageellipse($im, $width/2, $height/2, $smaller_dimension, $smaller_dimension, $color); $save_function = 'image'. ($extension == 'jpg' ? 'jpeg' : $extension); $save_function($im, $temp_file); $images[$extension][$min_resolution][$max_resolution][$temp_file] = $temp_file; } } // Select one of the images we've already generated for this field. else { $temp_file = array_rand($images[$extension][$min_resolution][$max_resolution]); } return $temp_file; }