Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/07/2012, 12:10
kerberos001
 
Fecha de Ingreso: julio-2012
Mensajes: 1
Antigüedad: 11 años, 9 meses
Puntos: 0
Pregunta recortar imgenes en php y enviar a descargar

Hola amigos, soy nuevo aqui y

Tengo este problema me podrian ayudar
con este codigo que encontre en un blog, pude imprimir la imagen recortada en la web pero nesecito enviar la imagen a descargar lo que pasa es que no lo e logrado

<?php

// Abre la imagen

$fichero = getcwd()."/".$_GET["img"];



if (preg_match('/.png$/', $fichero)) {

$img = imagecreatefrompng($fichero);

} else if (preg_match('/.gif$/', $fichero)) {

$img = imagecreatefromgif($fichero);

} else if (preg_match('/.jpg$/', $fichero)) {

$img = imagecreatefromjpeg($fichero);

}



$xini = $_GET["xini"];

$yini = $_GET["yini"];

$xfin = $_GET["xfin"];

$yfin = $_GET["yfin"];



$res = imagecreatetruecolor ($xfin-$xini, $yfin-$yini);

imagecopy($res, $img, 0, 0, $xini, $yini, $xfin-$xini, $yfin-$yini);



header("Content-type: image/png");

imagepng($res);

imagedestroy($res);



//lo intente utilizando esto, pero no funciona

header('Content-disposition: attachment; filename=algun_nombre.png');
header('Content-type: image/png ');
readfile($res);



?>