Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di Threepwood
    Registrato dal
    Feb 2003
    Messaggi
    2,107

    [PHP] Imagejpeg OnTheFly

    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);
    ?>
    Guybrush Threepwood

  2. #2
    Utente di HTML.it L'avatar di telegio
    Registrato dal
    Sep 2001
    Messaggi
    2,592
    ho trovato questa
    http://forum.html.it/forum/showthrea...readid=1412426
    che poi rimanda qua
    http://php.html.it/articoli/leggi/87...erie-gd-e-php/

    volendo bypassare la cosa, ma non so il limite, potresti scrivere l'immagine su disco, farla visualizzare e alla fine dello script cancellarla con unlink..

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.