Salve a tutti!
Sto cercando di fare una funzione che permetta di:
> Prendere un'immagine dal disco
> Ridimensionarla
> Comprimerla
> Riproporla (SENZA salvataggio su disco)
Non capisco solo come fare l'ultimo passaggio.. mi date una mano?
codice:
<?
function makeThumbnail($sourcefile, $endfile, $thumbwidth, $thumbheight, $quality)
{
$img = imagecreatefromjpeg($sourcefile);
$width = imagesx( $img );
$height = imagesy( $img );
if ($width > $height) {
$newwidth = $thumbwidth;
$divisor = $width / $thumbwidth;
$newheight = floor( $height / $divisor);
}
else {
$newheight = $thumbheight;
$divisor = $height / $thumbheight;
$newwidth = floor( $width / $divisor );
}
$tmpimg = imagecreatetruecolor( $newwidth, $newheight );
imagecopyresampled( $tmpimg, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height );
/* QUI NON SO COME RIPROPORLA ON THE FLY SENZA SAVE SUL DISCO */
imagejpeg( $tmpimg, $endfile, $quality);
imagedestroy($tmpimg);
imagedestroy($img);
}
?><?
makeThumbnail('images/water-lilies.jpg', 'images/winter2.jpg', 200, 100, 10);
?>