Problemas con thumbnail
| From: | Daniel | Date: | Mon, 11 Apr 2005 18:50:13 +0000 |
| Subject: | Problemas con thumbnail | ||
| Groups: | php.general.es | ||
| Request: | Send a blank email to general-es+get-54060@lists.php.net to get a copy of this message | ||
hola a todos, hace días pense que habia terminado con esto pero el cliente me dio nuevos parametros
y por ende nuevos cambios en el codigo...
Estoy usando este script para generar las thumbnail y funciona perfecto, con la imagen bien
proporcional...
$original = imagecreatefromjpeg($nombre);
$altura=100;
$ratio = ($datos[1] / $altura);
$anchura = round($datos[0] / $ratio);
$thumb = imagecreatetruecolor($anchura,$altura);
imagecopyresampled($thumb, $original, 0, 0, 0, 0, $anchura, $altura, $datos[0], $datos[1]);
imagejpeg($thumb,"thumb".$codigo.".jpg",90);
... pero ahora, el cliente quiere que las imagenes sin importar la orientación sean proporcionales
en alto y ancho, dando vueltas por la web de Macromedia me tope con un articulo relacionado: http://www.macromedia.com/devnet/mx/dreamweaver/articles/php_graphics_04.html
y use el ejemplo adaptado a mis necesidades, pero ahora me esta creando la thumbnail defectuosa ó
deformada...
Este es el nuevo codigo de thumbnail que reduce la imagen a un 1/8 del tamaño real...
//load the image into memory and get its properties
$img = imagecreatefromjpeg($nombre);
//create new image for thumbnail 1/8 the size of the original
$nuevo_ancho = round($imgsz[0]/8);
$nuevo_alto = round($imgsz[1]/8);
$thumb = imagecreate($nuevo_ancho, $nuevo_alto);
//shrink the original image to 1/8th its size
imagecopyresized($thumb, $img, 0, 0, 0, 0, $nuevo_ancho, $nuevo_alto, $imgsz[0], $imgsz[1]);
//write the thumbnail to disk
imagejpeg($thumb,"thumb".$codigo.".jpg",100);
¿que hago para que la thumbnail se cree perfecta?
Daniel Naranjo
Lo Último en la Web, Soluciones efectivas
0416 2917532
0416 8955234
0295 2630298 (Fax)
www.loultimoenlaweb.com
"...compartiendo un poco, mis conocimientos:
www.loultimoenlaweb.com/blog..."