salve a tutti! ho provato finora su un server windows con php5 questo codice e funzionava... mi faceva il resize di un'immagine prima come miniatura e poi come zoom e mi salvava le due nuove immagini in due cartelle sul server. Ora ho portato il tutto su un server linux con php5, ho dato i permessi di scrittura alle cartelle, la pagina viene eseguita tutta (mi fa anche le query di aggiornamento che sono in fondo a questo codice...) non mi dà nessun errore, eppure non mi crea le immagini!!!!
javascript:smilie('')
![]()
/* some checks */
if ($_GET['foto'] !="" ) {
if ( isset( $_GET['w'] ) && ereg( "^[0-9]+$", $_GET['w'] ) ) $MAX_WIDTH = $_GET['w'];
else $MAX_WIDTH = 130;
if ( isset( $_GET['h'] ) && ereg( "^[0-9]+$", $_GET['h'] ) ) $MAX_HEIGHT = $_GET['h'];
else $MAX_HEIGHT = 100;
/* GET source image size */
$getfoto=$_GET['foto'];
$is="noresize/$getfoto";
$src_size = GETimagesize($is);
/* resize the image (if needed) */
if ( $src_size[0] > $MAX_WIDTH && $src_size[1] > $MAX_HEIGHT ) {
if ( $src_size[0] > $src_size[1] ) {
$dest_width = $MAX_WIDTH;
$dest_height = ( $src_size[1] * $MAX_WIDTH ) / $src_size[0];
}
else {
$dest_width = ( $src_size[0] * $MAX_HEIGHT ) / $src_size[1];
$dest_height = $MAX_HEIGHT;
}
}
else if ( $src_size[0] > $MAX_WIDTH ) {
$dest_width = $MAX_WIDTH;
$dest_height = ( $src_size[1] * $MAX_WIDTH ) / $src_size[0];
}
else if ( $src_size[1] > $MAX_HEIGHT ) {
$dest_width = ( $src_size[0] * $MAX_HEIGHT ) / $src_size[1];
$dest_height = $MAX_HEIGHT;
}
else {
$dest_width = $src_size[0];
$dest_height = $src_size[1];
}
}
/* resize zoom */
if ($_GET['zoom_foto'] !="" )
{
if ( isset( $_GET['a'] ) && ereg( "^[0-9]+$", $_GET['a'] ) ) $MAX_LARG = $_GET['a'];
else $MAX_LARG = 450;
if ( isset( $_GET['b'] ) && ereg( "^[0-9]+$", $_GET['b'] ) ) $MAX_ALT = $_GET['b'];
else $MAX_ALT = 300;
$getzoomfoto=$_GET['zoom_foto'];
/* GET source image size */
$isz="noresize/$getzoomfoto";
$src_sizeZ = GETimagesize($isz);
/* resize the image (if needed) */
if ( $src_sizeZ[0] > $MAX_LARG && $src_sizeZ[1] > $MAX_ALT ) {
if ( $src_sizeZ[0] > $src_sizeZ[1] ) {
$dest_larg = $MAX_LARG;
$dest_alt = ( $src_sizeZ[1] * $MAX_LARG ) / $src_sizeZ[0];
}
else {
$dest_larg = ( $src_sizeZ[0] * $MAX_ALT ) / $src_sizeZ[1];
$dest_alt = $MAX_ALT;
}
}
else if ( $src_sizeZ[0] > $MAX_LARG ) {
$dest_larg = $MAX_LARG;
$dest_alt = ( $src_sizeZ[1] * $MAX_LARG ) / $src_sizeZ[0];
}
else if ( $src_sizeZ[1] > $MAX_ALT ) {
$dest_larg = ( $src_sizeZ[0] * $MAX_ALT ) / $src_sizeZ[1];
$dest_alt = $MAX_ALT;
}
else {
$dest_larg = $src_sizeZ[0];
$dest_alt = $src_sizeZ[1];
}
}
if ( $getfoto !="" || $getzoomfoto !="" ) {
if ( extension_loaded( 'gd' ) ) {
/* check the source file format */
$ext = substr( $getfoto, strrpos( $getfoto, '.' ) + 1 );
$icfj="noresize/$getfoto";
if ( $ext == 'jpg' || $ext == 'jpeg' ) $src = imagecreatefromjpeg($icfj) or die( 'Cannot load input JPEG image' );
else if ( $ext == 'gif' ) $src = imagecreatefromgif($icfj) or die( 'Cannot load input GIF image' );
else if ( $ext == 'png' ) $src = imagecreatefrompng($icfj) or die( 'Cannot load input PNG image' );
else die( 'Unsupported source file format1' );
/* create and output the destination image */
$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] ) or die( 'errore imagecopyresized' );
if ($_GET['id'] =="") {
$i=mt_rand(800, 2500);
$ii="x";
$aaaZ="{$_GET['modello']}".$i.$ii;
}
else $aaa="{$_GET['modello']}.{$_GET['id']}";
$path= "img/$aaa.jpg";
imagejpeg($dest,$path);
imagedestroy($dest);
/* check the source file format */
$extZ = substr($getzoomfoto, strrpos($getzoomfoto, '.' ) + 1 );
$icfjz="noresize/$getzoomfoto";
if ( $extZ == 'jpg' || $extZ == 'jpeg' ) $srcZ = imagecreatefromjpeg($icfjz) or die( 'Cannot load input JPEG image' );
else if ( $extZ == 'gif' ) $srcZ = imagecreatefromgif($icfjz) or die( 'Cannot load input GIF image' );
else if ( $extZ == 'png' ) $srcZ = imagecreatefrompng($icfjz) or die( 'Cannot load input PNG image' );
else die( 'Unsupported source file format2' );
/* create and output the destination image */
$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] )or die ('problemi con imagecopyresized');
if ($_GET['id'] =="") {
$i=mt_rand(800, 2500);
$ii="x";
$aaaZ="{$_GET['modello']}.zoom".$i.$ii;
}
else $aaaZ="{$_GET['modello']}.zoom.{$_GET['id']}";
$pathZ= "img/zoom/$aaaZ.jpg";
imagejpeg($destZ,$pathZ);
$foto = "$aaa.jpg";
$zoom = "$aaaZ.jpg";