Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/02/2014, 14:37
Avatar de rodrigus71
rodrigus71
 
Fecha de Ingreso: mayo-2012
Ubicación: Alicante
Mensajes: 73
Antigüedad: 12 años
Puntos: 3
Redimensionar imagen con php

Hola de nuevo foro:

Estoy atascado intentando redimensionar una imagen mediante php pero no consigo que funcione. El archivo lo he llamado resize.php y el código que contiene es el siguiente:

Código PHP:
 <?php 
$anchura
=80
$hmax=80
$nombre=basename($_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$img0000$anchura$altura$datos[0], $datos[1]); 
if(
$datos[2]==1){header("Content-type: image/gif"); imagegif($thumb);} 
if(
$datos[2]==2){header("Content-type: image/jpeg");imagejpeg($thumb);} 
if(
$datos[2]==3){header("Content-type: image/png");imagepng($thumb); } 
imagedestroy($thumb); 
?>
cuando ejecuto el archivo resize.php?imagen=test.jpg obtengo el siguiente mensaje de error en el navegador:

No se puede mostrar la imagen "http:127.0.0.1/resize.php?imagen=test.jpg" porque contiene errores

A ver si a alguien se le ocurre que puede estar pasando

Gracias anticipadas
__________________
Dame hueco, que habiendo hueco yo ya...
https://www.ofidecoeducativos.es/