Salve a tutti, premetto che ho cercato nel forum ma non ho trovato nulla che mi potesse aiutare.
Ho creato un piccolo form per uplodare immagini, poi con uno script jquery le ritaglio e passo tutto ad un file php che prende l'immagine, prende le coordinate del rettangolo e mi salva solo l'immagine "evidenziata" nel rettangolo.
Quale è il problema? Il problema è che l'immagine ritagliata è tutta sgranata!
posto un pò di codice:
codice:
public function cropImage() {
if (!isset($_POST['x']) or !isset($_POST['y']) or !isset($_POST['h']) or !isset($_POST['w']))
return false;
$img_r = imagecreatefromjpeg($this->tmp_path . $this->name);
$dst_r = ImageCreateTrueColor( 300, 300 );
$dst_h = $_POST['h']; $dst_w = $_POST['w'];
imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],300,300,$dst_w,$dst_h);
$outPath = realpath("../../images/personal")."/";
imagejpeg($dst_r, $this->outPath . $this->name, $this->jpeg_quality);
if (file_exists($this->tmp_path . $this->name))
unlink($this->tmp_path . $this->name);
return true; }
esempio:
Immagine mentre ritaglio: http://img854.imageshack.us/i/es1.jpg/
Immagine ritagliata:
http://img263.imageshack.us/i/es2q.jpg/
Qualcuno ha qualche idea? eppure ho letto dappertutto che la funzione imagecopyresampled serviva proprio a questo.....