Ver Mensaje Individual
  #9 (permalink)  
Antiguo 09/10/2009, 17:45
samu22
 
Fecha de Ingreso: abril-2008
Mensajes: 453
Antigüedad: 16 años, 11 meses
Puntos: 16
Respuesta: Editar script redimesionador de imagenes timthumb.php

yo tengo hecho esto, fijate si te sirve, igualmente lo tengo que mejorar

Código php:
Ver original
  1. <?php
  2. $getFile = $_GET['f'];
  3. //ROOT_PATH es una constante predefinida, en mi caso http://localhost/sitio
  4. $nombre = str_replace(ROOT_PATH,'',$getFile);
  5. $datos = getimagesize($nombre);
  6.  
  7. // Vemos si esta definido el ancho y el alto
  8.     //ancho
  9.         if(!isset($_GET['ancho'])){
  10.             $ancho = 175;
  11.         }else{
  12.             $ancho = $_GET['ancho'];
  13.         }
  14.     //alto
  15.         if(!isset($_GET['alto'])){
  16.             $alto = 175;
  17.         }else{
  18.             $alto = $_GET['alto'];
  19.         }
  20.  
  21.  
  22. switch($datos[2]){
  23.     case 1:
  24.         $img = @imagecreatefromgif($nombre);
  25.         $contType = 'Content-type: image/gif';
  26.         $imagen = ImageCreate($ancho,$alto);
  27.         ImageCopyResized($imagen,$img,0,0,0,0,$ancho,$alto,$datos[0],$datos[1]);
  28.         header($contType);
  29.         imageGIF($imagen);
  30.     break;
  31.     case 2:
  32.         $img = @imagecreatefromjpeg($nombre);
  33.         $contType = 'Content-type: image/jpeg';
  34.         $imagen = imagecreatetruecolor($ancho,$alto);
  35.         ImageCopyResized($imagen,$img,0,0,0,0,$ancho,$alto,$datos[0],$datos[1]);
  36.         header("Content-type: image/jpg");
  37.         imagejpeg($imagen);
  38.     break;
  39.     case 3:
  40.         $img = @imagecreatefrompng($nombre);
  41.         $contType = 'Content-type: image/png';
  42.         $imagen = ImageCreate($ancho,$alto);
  43.         ImageCopyResized($imagen,$img,0,0,0,0,$ancho,$alto,$datos[0],$datos[1]);
  44.         header($contType);
  45.         imagePNG($imagen);
  46.     break;
  47. }
  48.  
  49.  
  50.  
  51.  
  52. ?>