I am trying to grab a random 50 by 50 square from a photo and can't quite see where my error is. I am a little new to GD so I may be using the wrong function or something.
<?
header("Content-type: image/jpeg");
$img_info = getimagesize("test.jpg");
$img_w = $img_info[0];
$img_h = $img_info[1];
$rand_w = mt_rand(1,$img_w);
$rand_h = mt_rand(1,$img_h);
$rand_x = mt_rand(1,50);
$rand_y = mt_rand(1,50);
$background = imagecreate (50, 50);
$foreground = imagecreatefromjpeg("test.jpg");
$done = imagecopyresampled($background,$foreground, 0, 0, $rand_w, $rand_h, 50, 50, $img_w, $img_h);
imagejpeg($done);
?>