Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/05/2010, 17:04
Avatar de metacortex
metacortex
Viejo demente
 
Fecha de Ingreso: junio-2004
Ubicación: Caracas - Venezuela
Mensajes: 9.027
Antigüedad: 19 años, 10 meses
Puntos: 832
Respuesta: No me redimenciona imagen.

A manera de complemento: estoy usando una función que va muy bien. Te dejo el código, quizás ayude a una mejora:

Código PHP:
Ver original
  1. /*
  2. Micro Image Manipulation Pack
  3.  
  4. ©PhpToys 2006
  5. http://www.phptoys.com
  6.  
  7. Released under the terms and conditions of the
  8. GNU General Public License (http://gnu.org).
  9. */
  10.  
  11. function resizeImage($originalImage,$toWidth,$toHeight){
  12.    
  13.     // Get the original geometry and calculate scales
  14.     list($width, $height) = getimagesize($originalImage);
  15.     $xscale=$width/$toWidth;
  16.     $yscale=$height/$toHeight;
  17.    
  18.     // Recalculate new size with default ratio
  19.     if ($yscale>$xscale){
  20.         $new_width = round($width * (1/$yscale));
  21.         $new_height = round($height * (1/$yscale));
  22.     }
  23.     else {
  24.         $new_width = round($width * (1/$xscale));
  25.         $new_height = round($height * (1/$xscale));
  26.     }
  27.  
  28.     // Resize the original image
  29.     $imageResized = imagecreatetruecolor($new_width, $new_height);
  30.     $imageTmp     = imagecreatefromjpeg ($originalImage);
  31.     imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  32.  
  33.     return $imageResized;
  34. }
Aplicando la función:
Código PHP:
Ver original
  1. <?php
  2. $myimg1 = resizeImage('test.jpg',120,120);
  3. imagejpeg($myimg1,'result1.jpg',100);
  4. echo '<img src="result1.jpg" alt="miniatura" />';
  5. ?>