Ver Mensaje Individual
  #5 (permalink)  
Antiguo 17/10/2006, 08:33
Avatar de Anastasiaphp
Anastasiaphp
 
Fecha de Ingreso: junio-2006
Ubicación: El patio de mi casa
Mensajes: 196
Antigüedad: 20 años, 5 meses
Puntos: 3
Esto te valdrá. Yo lo utilizo en uno de los webs y me funciona muy bien. Crea un fichero como este (imagen_reducida.php):

Código PHP:
<?php
// Variables que indican el archivo de la imagen y el nuevo tamaño
$nombre = $_GET["valor"];
$filename = 'imagenes/'.$nombre;  //ubicacion de la foto
$percent = 0.30; //Este porcentaje te hace la imagen a un tamaño del 30%, puedes variarlo como gustes

// 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 = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);

// Redimensionar
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Mostrar la nueva imagen
imagejpeg($thumb);
?>
Donde quieras llamar a las imágenes pequeñas, tienes que hacerlo de la siguiente manera:

Código HTML:
<img src='imagen_reducida.php?valor=nombre_imagen.jpg'> 

Este script está pensado para imágenes jpg, pero igual puedes adaptarlo si utilizas otro formato.

Saludos.