salve a tutti!
sto lavorando sul resize di alcune immagini che inserisco da un form. Ho usato la funzione imagecreatetruecolor che richiede la libreria gd. Se invio dal form una sola immagine funziona tutto, ma se passo 2 immagini insieme e faccio il resize della prima e poi della seconda, quando arrivo a richiamare la funzione imagecreatetruecolor per la seconda volta mi da errore...
if ( extension_loaded( 'gd' ) ) {
/* RESIZE FOTO 1 */
$ext = substr( $_GET['foto'], strrpos( $_GET['foto'], '.' ) + 1 );
if ( $ext == 'jpg' || $ext == 'jpeg' ) $src = imagecreatefromjpeg( $_GET['foto'] ) or die( 'Cannot load input JPEG image' );
else if ( $ext == 'gif' ) $src = imagecreatefromgif( $_GET['foto'] ) or die( 'Cannot load input GIF image' );
else if ( $ext == 'png' ) $src = imagecreatefrompng( $_GET['foto'] ) or die( 'Cannot load input PNG image' );
else die( 'Unsupported source file format' );
/*OUTPUT FOTO 1 */
$dest = imagecreatetruecolor( $dest_width, $dest_height ) or die( 'Cannot initialize new GD image stream' );
imagecopyresized( $dest, $src, 0, 0, 0, 0, $dest_width, $dest_height, $src_size[0], $src_size[1] );
$aaa=$_GET['modello'];
$path= "img/$aaa.jpg";
imagejpeg($dest,$path);
/* RESIZE FOTO 2 */
$ext = substr( $_GET['zoom_foto'], strrpos( $_GET['zoom_foto'], '.' ) + 1 );
if ( $ext == 'jpg' || $ext == 'jpeg' ) $srcZ = imagecreatefromjpeg( $_GET['zoom_foto'] ) or die( 'Cannot load input JPEG image' );
else if ( $ext == 'gif' ) $srcZ = imagecreatefromgif( $_GET['zoom_foto'] ) or die( 'Cannot load input GIF image' );
else if ( $ext == 'png' ) $srcZ = imagecreatefrompng( $_GET['zoom_foto'] ) or die( 'Cannot load input PNG image' );
else die( 'Unsupported source file format' );
/* OUTPUT FOTO 2 */
$destZ = imagecreatetruecolor( $dest_larg, $dest_alt ) or die( 'Cannot initialize new GD image stream' );
imagecopyresized( $destZ, $srcZ, 0, 0, 0, 0, $dest_larg, $dest_alt, $src_sizeZ[0], $src_sizeZ[1] );
$aaaZ=$_GET['modello'];
$pathZ= "img/zoom/$aaaZ.jpg";
imagejpeg($destZ,$pathZ);