<?
/*
* 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);
}
}
?>
Comentários
Erro thumbs
Cara ta dando um erro quando executo esse codigo chamo a funçao:geraThumb($_FILES["foto1"]["name"],"thumb_foto1.jpg",100);
Retorna o seguinte erro:
Warning: file_get_contents(02-11-08_0858.jpg) [function.file-get-contents]: failed to open stream: No such file or directory in C:\xampp\htdocs\Projeto Voks\cadastro_usados.php on line 201
Warning: imagecreatefromstring() [function.imagecreatefromstring]: Empty string or invalid image in C:\xampp\htdocs\Projeto Voks\cadastro_usados.php on line 201
Warning: getimagesize(02-11-08_0858.jpg) [function.getimagesize]: failed to open stream: No such file or directory in C:\xampp\htdocs\Projeto Voks\cadastro_usados.php on line 202
Warning: copy(02-11-08_0858.jpg) [function.copy]: failed to open stream: No such file or directory in C:\xampp\htdocs\Projeto Voks\cadastro_usados.php on line 212
Galera me da uma ajuda ai, vlw!!Enviado por Rodrigo Martins alves em 2009-01-05
RE: Erro thumgs
Olá Rodrigo,
Use:
$_FILES[\'foto1\'][\'tmp_name\'];
No lugar de:
$_FILES[\'foto1\'][\'name\'];
abraço
PabloEnviado por Pablo em 2009-01-15
Legal =)
Ainda não testei, mas a principio gostei a forma que o método foi escrito fico bem didático
valww =]Enviado por Will Fernando em 2009-07-10


