Ver Mensaje Individual
  #5 (permalink)  
Antiguo 07/02/2013, 16:18
Avatar de erozwashere
erozwashere
 
Fecha de Ingreso: noviembre-2012
Ubicación: mex
Mensajes: 176
Antigüedad: 11 años, 6 meses
Puntos: 0
Respuesta: Cual es mi error en esta funcion? php

Cita:
Iniciado por Triby Ver Mensaje
Qué es lo que no funcionó?, muestra nuevamente tu código.
El codigo es el mismo, solo que en vez de while tenia un if asi

Código PHP:
Ver original
  1. $altoancho = GetImageSize($imagen);  
  2. echo "Ancho: ".$altoancho[0];
  3. echo "Alto: ".$altoancho[1];
  4.  
  5. $dest=$folder.$destino;
  6.  
  7.  
  8.  if($altoancho[0] > 250 && $altoancho[1] > 270) {
  9.  
  10.  ## CONFIGURACION #############################
  11.  
  12.     # ruta de la imagen a redimensionar
  13.    $imagen=$filename;
  14.     # ruta de la imagen final, si se pone el mismo nombre que la imagen, esta se sobreescribe
  15.    $imagen_final="".$filename."";
  16.     $ancho_nuevo=300;
  17.     $alto_nuevo=400;
  18.  
  19. ## FIN CONFIGURACION #############################
  20.  
  21.  
  22. redim ($imagen,$imagen_final,$ancho_nuevo,$alto_nuevo);
  23.  
  24.  
  25. function redim($ruta1,$ruta2,$ancho,$alto)
  26.     {
  27.     # se obtene la dimension y tipo de imagen
  28.    $datos=getimagesize ($ruta1);
  29.      
  30.     $ancho_orig = $datos[0]; # Anchura de la imagen original
  31.    $alto_orig = $datos[1];    # Altura de la imagen original
  32.    $tipo = $datos[2];
  33.      
  34.     if ($tipo==1){ # GIF
  35.        if (function_exists("imagecreatefromgif"))
  36.             $img = imagecreatefromgif($ruta1);
  37.         else
  38.             return false;
  39.     }
  40.     else if ($tipo==2){ # JPG
  41.        if (function_exists("imagecreatefromjpeg"))
  42.             $img = imagecreatefromjpeg($ruta1);
  43.         else
  44.             return false;
  45.     }
  46.     else if ($tipo==3){ # PNG
  47.        if (function_exists("imagecreatefrompng"))
  48.             $img = imagecreatefrompng($ruta1);
  49.         else
  50.             return false;
  51.     }
  52.      
  53.     # Se calculan las nuevas dimensiones de la imagen
  54.    if ($ancho_orig>$alto_orig)
  55.         {
  56.         $ancho_dest=$ancho;
  57.         $alto_dest=($ancho_dest/$ancho_orig)*$alto_orig;
  58.         }
  59.     else
  60.         {
  61.         $alto_dest=$alto;
  62.         $ancho_dest=($alto_dest/$alto_orig)*$ancho_orig;
  63.         }
  64.  
  65.     // imagecreatetruecolor, solo estan en G.D. 2.0.1 con PHP 4.0.6+
  66.     $img2=@imagecreatetruecolor($ancho_dest,$alto_dest) or $img2=imagecreate($ancho_dest,$alto_dest);
  67.  
  68.     // Redimensionar
  69.     // imagecopyresampled, solo estan en G.D. 2.0.1 con PHP 4.0.6+
  70.     @imagecopyresampled($img2,$img,0,0,0,0,$ancho_dest,$alto_dest,$ancho_orig,$alto_orig) or imagecopyresized($img2,$img,0,0,0,0,$ancho_dest,$alto_dest,$ancho_orig,$alto_orig);
  71.  
  72.     // Crear fichero nuevo, según extensión.
  73.     if ($tipo==1) // GIF
  74.         if (function_exists("imagegif"))
  75.             imagegif($img2, $ruta2);
  76.         else
  77.             return false;
  78.  
  79.     if ($tipo==2) // JPG
  80.         if (function_exists("imagejpeg"))
  81.             imagejpeg($img2, $ruta2);
  82.         else
  83.             return false;
  84.  
  85.     if ($tipo==3)  // PNG
  86.         if (function_exists("imagepng"))
  87.             imagepng($img2, $ruta2);
  88.         else
  89.             return false;
  90.      
  91.     return true;
  92.     }
  93.  
  94.  
  95.  
  96.  
  97.  
  98. }

y surgia el mismo error,
Fatal error: Call to undefined function redim() in A:\AppServ\www\reducir.php on line 64

ya sea con while, o if el error es el mismo