Ver Mensaje Individual
  #6 (permalink)  
Antiguo 22/03/2007, 02:24
Gustavo_AR
 
Fecha de Ingreso: septiembre-2006
Ubicación: Argentina
Mensajes: 190
Antigüedad: 20 años, 1 mes
Puntos: 1
Re: Guardar imagenes en miniaturas

No entiendo bien lo de imagen=$_GET['']... de donde sacás la imagen para redimensionar? Igualmente te dejo es code corregido, fijate que la variable $nombre_imagen toma el nombre del archivo pasado por post desde un formulario clásico con un input the archivo. Si el nombre viene por get, reeemplazá $nombre_imagen = $_FILES['archivo']['name']; por $nombre_imagen = $_GET['imagen'];

Saludos.

Código PHP:
<?php 
$nombre_imagen 
= $_FILES['archivo']['name']; //nombre de la imagen 
//('archivo' es el nombre del campo file del formulario

$directorio = "imagenes/"; //directorio de destino de la imagen

$destino= $directorio.$nombre_imagen; //directorio + nombre de la imagen

$anchura=190; 
$hmax=230; 
$nombre=$_GET['imagen']; 
$datos = getimagesize($nombre); 
if(
$datos[2]==1){$img = @imagecreatefromgif($nombre);} 
if(
$datos[2]==2){$img = @imagecreatefromjpeg($nombre);} 
if(
$datos[2]==3){$img = @imagecreatefrompng($nombre);} 
$ratio = ($datos[0] / $anchura); 
$altura = ($datos[1] / $ratio); 
if(
$altura>$hmax){$anchura2=$hmax*$anchura/$altura;$altura=$hmax;$anchura=$anchura2;} 
$thumb = imagecreatetruecolor($anchura,$altura); 
imagecopyresampled($thumb, $img, 0, 0, 0, 0, $anchura, $altura, $datos[0], $datos[1]); 
if(
$datos[2]==1){imagegif($thumb,$destino);} 
if(
$datos[2]==2){imagejpeg($thumb,$destino);} 
if(
$datos[2]==3){imagejpeg($thumb,$destino); } 

imagedestroy($thumb); 

?>
__________________
Gustavo

Última edición por Gustavo_AR; 22/03/2007 a las 02:48