Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/11/2010, 01:37
faticod
 
Fecha de Ingreso: noviembre-2009
Mensajes: 19
Antigüedad: 14 años, 5 meses
Puntos: 0
Errores al redimensionar

Buenas Noches!

Estuve ya bastantes horas buscando el por que de un error que tengo pero no consigo que funcione al %100.

Les cuento que tengo este codigo para redimensionar:

Código PHP:
<?php
$anchura
=$_GET['anchura'];
$hmax=$_GET['anchura']; 
$nombre=basename($_GET['imagen']);
$datos getimagesize($nombre); 
$ratio = ($datos[0] / $anchura);
$altura = ($datos[1] / $ratio);
if(
$altura>$hmax){$anchura2=$hmax*$anchura/$altura;$altura=$hmax;$anchura=$anchura2;} 
$thumb imagecreatetruecolor($anchura,$altura);
if(
$datos[2]==1){$img = @imagecreatefromgif($nombre);}
if(
$datos[2]==2){$img = @imagecreatefromjpeg($nombre);}
if(
$datos[2]==3){$img = @imagecreatefrompng($nombre);}
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); 
?>

Funciona bien , pero solo con imagenes JPG , si es GIF ó PNG muestra un tache como si no hubiera subido nada y en el servidor marca estos errores:

Código PHP:
PHP Warning:  imagecreatetruecolor() [<a href='function.imagecreatetruecolor'>function.imagecreatetruecolor</a>]: Invalid image dimensions in /home/arellano/public_html/redimensionar.php on line 9
PHP Warning
:  imagecopyresampled(): supplied argument is not a valid Image resource in /home/arellano/public_html/redimensionar.php on line 13
PHP Warning
:  imagedestroy(): supplied argument is not a valid Image resource in /home/arellano/public_html/redimensionar.php on line 17
PHP Warning
:  Division by zero in /home/arellano/public_html/redimensionar.php on line 7 
Segun yo ya coloque el codigo como debe de ir pero no se si me falte algo ó este haciendo algo mal.

Muchas Gracias

saludos