Ver Mensaje Individual
  #6 (permalink)  
Antiguo 16/06/2014, 08:47
Avatar de Italico76
Italico76
 
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años, 1 mes
Puntos: 292
Respuesta: Redimensionar imagen para subir

Prueba esto que escribi:
(el copy no es necesario)

Código PHP:
Ver original
  1. <?php
  2.  
  3. $input_file  = $_FILES['portada']['tmp_name'];
  4. $output_file = 'test.jpg';
  5.  
  6. resize($input_file,640,480,$output_file);
  7.  
  8. function resize($input_file,$new_width,$new_height,$output_file=null)
  9. {
  10.     if (is_null($output_file))
  11.         header('Content-Type: image/jpeg');
  12.     list($width, $height) = getimagesize($input_file);
  13.  
  14.     $image_p = imagecreatetruecolor($new_width, $new_height);
  15.     $image = imagecreatefromjpeg($input_file);
  16.     imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
  17.     imagejpeg($image_p, $output_file, 100);
  18. }
  19. ?>
  20. <img src="<?= $output_file ?>" />
__________________
Salu2!