Imagenes con gd
| From: | Salva | Date: | Mon, 04 Aug 2008 19:18:37 +0000 |
| Subject: | Imagenes con gd | ||
| Groups: | php.general.es | ||
| Request: | Send a blank email to general-es+get-62983@lists.php.net to get a copy of this message | ||
Hola, estoy con las imagenes en php mediante la libreria gd, quiero
redimensionar una imagen y copio y pego el siguiente codigo tal cual viene
en el manual oficial de php Pero me sala la hoja en blanco o me saca
garabatos y me da erro en la linea del header.
<?php
// Variables que indican el archivo de la imagen y el nuevo tamano
$filename = 'test.jpg';
$percent = 0.5;
// Content-type para el navegador
header('Content-type: image/jpeg');
// Se obtienen las nuevas dimensiones
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;
// Cargar la imagen
$thumb = imagecreate($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
// Redimensionar
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width,
$height);
// Mostrar la nueva imagen
imagejpeg($thumb);
?>