Código PHP:
function createthumb($name,$file,$maxsize)
{
$maxsize += 8;
list($width, $height) = getimagesize("$name/$file");
$width = min($width, $height);
$tn = imagecreatetruecolor($maxsize, $maxsize);
$image = imagecreatefromjpeg("$name/$file");
imagecopyresampled($tn, $image, 0, 0, 0, 0, $maxsize, $maxsize, $width, $width);
if(!is_dir("$name/thumbnails"))
{
mkdir ("$name/thumbnails", 0777);
}
imagejpeg($tn, "$name/thumbnails/tn_$file", 90);
return true;
}