<?
/*
* Método geraThumb
* Gera thumbnail a partir da foto
*/
function geraThumb($photo, $output, $new_width)
{
$source = imagecreatefromstring(file_get_contents($photo));
list($width, $height) = getimagesize($photo);
if ($width>$new_width)
{
$new_height = ($new_width/$width) * $height;
$thumb = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($thumb, $output, 100);
}
else
{
copy($photo, $output);
}
}
?>


