$line = mysql_fetch_array($result, MYSQL_ASSOC); $desc = $line ['desc']; $user = $line['user']; $filename = $line['realname']; $getfile = './imgs/' . $filename; // Lets get the image to fit into our page $width = 600; $height = 600; list($origwidth, $origheight) = getimagesize($getfile); if(($origwidth < $width) && ($origheight < $height)) { $width = $origwidth; $height = $origheight; } $imagef = imagecreatetruecolor($width,$height); if ($filetype == 'image/bmp') { header('Content-type: image/vnd.wap.wbmp'); $thumb = imagecreatefromwbmp($getfile); } if ($filetype == 'image/gif') { header('Content-type: image/gif'); $thumb = imagecreatefromgif($getfile); } if ($filetype == 'image/png') { header('Content-type: image/png'); $thumb = imagecreatefrompng($getfile); } if ($filetype == 'image/jpeg') { header('Content-type: image/jpeg'); $thumb = imagecreatefromjpeg($getfile); } // ALMOST done :) Just put these babies where they need to be imagecopyresampled($imagef, $thumb, 0, 0, 0, 0, $width, $height, $origwidth, $origheight); if ($filetype == 'image/wbmp') { imagewbmp($imagef, null, 100); } if ($filetype == 'image/jpeg') { imagejpeg($imagef, null, 100); } if ($filetype == 'image/png') { imagepng($imagef, null, 100); } if ($filetype == 'image/gif') { imagegif($imagef, null, 100); }