Ciao a tutti,
chiedo scusa anticipatamente per la domanda probabilmente idiota ma sono molto arrugginita col PHP.
Sto usando questa funzione per ridimensionare/tagliare un'immagine:
Credo che funzioni tutto il problema è che poi non so come gestire l'oggetto $img in html...cioè...per visualizzare l'immagine in html cosa devo fare? Non posso fare un echo per un oggetto non string no?codice:function resize_image($file, $w, $h, $crop=FALSE) { list($width, $height) = getimagesize($file); $r = $width / $height; if ($crop) { if ($width > $height) { $width = ceil($width-($width*abs($r-$w/$h))); } else { $height = ceil($height-($height*abs($r-$w/$h))); } $newwidth = $w; $newheight = $h; } else { if ($w/$h > $r) { $newwidth = $h*$r; $newheight = $h; } else { $newheight = $w/$r; $newwidth = $w; } } $src = imagecreatefromjpeg($file); $dst = imagecreatetruecolor($newwidth, $newheight); if(imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height)){ echo 'Successo!'; }else{ echo 'Fallimento'; } return $dst; } $img = resize_image('images/bg-breadcrumbs-04.jpg', 200, 200);

Rispondi quotando