Вы сделали изображение, вы разместили его, но не нарисовали. попробуйте этот код
<?php
$x = imagecreatetruecolor(250, 250);
$y = imagecolorallocate($x, 120 ,156,100);
imagerectangle($x, 50, 50, 150, 150, $y);// draw the rectange of image
header('Content-Type: image/jpeg');
imagejpeg($x);
?>