quindi se non ho sbagliato questo fa in modo che ogni volta ci sia un controllo giusto ?
[PHP]function pette($filename){
list($current_width, $current_height) = getimagesize($filename);
$left = 50;
$top = 0;
$crop_width = 70;
$crop_height = 70;
$canvas = imagecreatetruecolor($crop_width, $crop_height);
$current_image = imagecreatefromjpeg($filename);
imagecopy($canvas, $current_image, 0, 0, $left, $top, $current_width, $current_height);
$filename = str_replace('http://www.xxxxx/images/', '', $filename);
$nuovonome= 'temp/'.$filename;
//$nuovonome.='.jpg';
//qui facciamo il controllo
if (file_exists($nuovonome)) {
return $nuovonome;
}
else {
imagejpeg($canvas, $nuovonome, 100);
//echo ('<img src="'.$nuovonome.'" width="100" height="100">');
return $nuovonome;
}
}[/PHP]