Ho due file.
Il primo, dove inserisco lo script: gd.php
Codice PHP:
<?php
$l = 100;
$src = $_GET['image'];
function OutThumb($src, $l){
$size = getimagesize($src);
if( $size[2] == 2 ){$im = @imagecreatefromjpeg($src);}
elseif( $size[2] == 1 ){$im = @imagecreatefromgif($src);}
elseif( $size[2] == 3 ){$im = @imagecreatefrompng($src);}
if( $size[0]>$l or $size[1]>$l ){
$centerX = $size[0]/2;
$centerY = $size[1]/2;
if( $size[0] > $size[1] ){
$luy = 0;
$lux = $centerX-$centerY;
$rdy = $size[1];
$rdx = $size[1];
}
else{
$lux = 0;
$luy = $centerY-$centerX;
$rdx = $size[0];
$rdy = $size[0];
}
if( (GDVersion() == 2) AND ($size[2] != 1) ){
$new = imagecreatetruecolor($l, $l);
imagecopyresampled($new, $im, 0, 0, $lux, $luy, $l, $l, $rdx, $rdy);
}
else{
$new = imagecreate($l, $l);
imagecopyresized($new, $im, 0, 0, $lux, $luy, $l, $l, $rdx, $rdy);
}
}
else{
$new &= $im;
}
header('Content-Type: ' . $size['mime']);
if( $size[2] == 2 ){@imagejpeg($new, $fileOut, 100);}
elseif( $size[2] == 1 ){@imagegif($new, $fileOut);}
elseif( $size[2] == 3 ){@imagepng($new, $fileOut);}
@imagedestroy($im);
@imagedestroy($new);
}
?>
E il file img.php dove chiamo il file e la funzione:
Codice PHP:
[img]gd.php?image=cartoline.jpg[/img]
Il risultato è che non funziona...appare una bella X sullo schermo.
Cosa può essere? Le GD2 sono attive sul mio hosting.