Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/07/2010, 10:28
Avatar de kaninox
kaninox
 
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 19 años, 4 meses
Puntos: 49
Links Externos

Hola muchachos tengo un redimensionador de imagenes GD pero tengo algunos problemas para implementarlo para que tambien me redimencione imagenes con URLs externas? alguna idea.

mi codigo

Código PHP:
Ver original
  1. <?php
  2. $anchura = $_GET['ancho']; //768
  3. $hmax = $_GET['alto'];
  4. $nombre = $_GET['archivo'];
  5. $datos = getimagesize($nombre);
  6. if (($datos[0] <= $anchura) && ($datos[1] <= $hmax))
  7. {
  8. readfile($nombre);
  9. }
  10. else
  11. {
  12. if($datos[2]==1){$img = @imagecreatefromgif($nombre);}
  13. if($datos[2]==2){$img = @imagecreatefromjpeg($nombre);}
  14. if($datos[2]==3){$img = @imagecreatefrompng($nombre);}
  15. $ratio = ($datos[0] / $anchura);
  16. $altura = ($datos[1] / $ratio);
  17. if($altura>$hmax){$anchura2=$hmax*$anchura/$altura;$altura=$hmax;$anchura=$anchura2;}
  18. $thumb = imagecreatetruecolor($anchura,$altura);
  19. imagecopyresampled($thumb, $img, 0, 0, 0, 0, $anchura, $altura, $datos[0], $datos[1]);
  20. if($datos[2]==1){header("Content-type: image/gif"); imagegif($thumb);}
  21. if($datos[2]==2){header("Content-type: image/jpeg");imagejpeg($thumb);}
  22. if($datos[2]==3){header("Content-type: image/png");imagepng($thumb); }
  23. imagedestroy($thumb);
  24. }
  25. ?>

Código PHP:
Ver original
  1. //y llamo las imagenes asi
  2. //donde $folder puede ser una carpeta interna como una URL
  3. //y $datos[archivo] es el archivo recogido de una consulta SQL
  4. echo "<img src=\"rd.php?archivo=$folder/$datos[archivo]&amp;alto=120&amp;ancho=90\" border=\"0\" alt=\"\" title=\"\" />"


con carpetas internas funciona muy bien, con url externas se traba :/
Saludos
__________________
Gokuh Salvo al mundo. PUNTO!!!!