创建图像后获取空白页面[重复]

This question already has an answer here:

I have this code below from the "php.net".if I execute it then it gives me a just a black page .Is there something I have to declare or am I leaving something out?

<?php

header('Content-type: image/png');
$resim = imagecreatetruecolor(400, 30);
$beyaz = imagecolorallocate($resim, 255, 255, 255);
$gri = imagecolorallocate($resim, 128, 128, 128);
$siyah = imagecolorallocate($resim, 0, 0, 0);
imagefilledrectangle($resim, 0, 0, 399, 29, $beyaz);
$metin = 'Testing...';
$font = 'arial.ttf';
imagettftext($resim, 20, 0, 11, 21, $gri, $font, $metin);
imagettftext($resim, 20, 0, 10, 20, $siyah, $font, $metin);
imagepng($resim);
imagedestroy($resim);
?>
</div>