Ciao a tutti, avevo una domanda da farvi inerente al taglio di immagini da php.
In pratica faccio un upload di immagine e successivamente vorrei tagliarne una "fetta" x uso thumbnail attraverso questo script http://deepliquid.com/projects/Jcrop/demos/crop.php
Il problema che mi si pone e che quando taglio la porzione di immagine, questa mi viene visualizzata tramite header('Content-type: image/jpeg'); e imagejpeg($dst_r,null,$jpeg_quality); ma non ho idea di salvarla sul server.... avete una qualche idea di come procedere?
lo script che uso [tralasciando html e js] è il seguente:
Codice PHP:
$azione=$_POST['azione'];
$nome_img=$_POST['nome_img'];
$success = 0;
$indirizzo_tmp="tmp/"; // cartella img temporanea
$indirizzo_file="file/"; // cartella im finale
if ($azione=="load_img"){
if ($azione =="load_img" and is_uploaded_file($_FILES['upl_img']['tmp_name'])) {
// COPIA L'IMMAGINE INIZIALE IN UNA CARTELLA FISICA
do {
$success = 1;
$data=date(time());
$nome_img=$data."_".$_FILES['upl_img']['name'];
$nome_img= str_replace(" ", "_", $nome_img);
if ($control==0 and !move_uploaded_file($_FILES['upl_img']['tmp_name'], $indirizzo_tmp.$nome_img)) {
$msg = $msg."Generic error for in the image upload!!
";
$success=0;
}
}while (false);
}
print "----------> $success";
}
if ($azione=="crop_img"){
// MI FA VEDERE LA PORZIONE DI IMMAGINE APPENA TAGLIATA
$targ_w = $targ_h = 150;
$jpeg_quality = 90;
$src = $indirizzo_tmp.$nome_img;
$img_r = imagecreatefromjpeg($src);
$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
$targ_w,$targ_h,$_POST['w'],$_POST['h']);
header('Content-type: image/jpeg');
imagejpeg($dst_r,null,$jpeg_quality);
exit;
}
ty