salve ragazzi vi pongo un problema ...
ho seguito questa pillola per l'upload e il resize delle immaggini
http://forum.html.it/forum/showthrea...hreadid=694523
solo che ottengo degli errori che secondo me sono dovuti perchè ho sbagliato a scrivere la classe...
image.class.php
Codice PHP:<?PHP
class Image{
var $src_filename;
var $src_witdh;
var $src_height;
var $src_type;
var $src_attr;
var $src_image;
function Image($filename){
$this->src_filename = $filename;
$this->GetImageInfo();
}
function GetImageInfo(){
list($this->src_width,$this->src_height, $this->src_type, $this->src_attr) = getimagesize($this->src_filename);
}
function CreateSourceImage(){
switch($this->src_type){
case 1:
$this->src_image =imagecreatefromgif($this->src_filename);
break;
case 2:
$this->src_image =imagecreatefromjpeg($this->src_filename);
break;
case 3:
$this->src_image =imagecreatefrompng($this->src_filename);
break;
default: return false;
}
return true;
}
function SaveProportionateImage($filename, $quality, $height){
$dest_height = $height;
$ratio = $this->src_height / $dest_height;
$dest_image = imagecreatetruecolor( $this->src_width / $ratio,$dest_height);
imagecopyresampled($dest_image, $this->src_image, 0, 0, 0, 0,
$this->src_width / $ratio,
$this->src_height / $ratio,
$this->src_width,
$this->src_height);
imagejpeg($dest_image, $filename.'.jpg', $quality);
imagedestroy($dest_image);
}
function Free(){
imagedestroy($this->src_image);
}
}
?>
<?
//$up->filename è il nome del file uploadato o il 'nuovo_nome' del file
//in caso abbiamo usato il metodo RenameFile della classe FileUpload.
$result = $img->CreateSourceImage();
$img->SaveProportionateImage('./img_big' . $up->filename, 100, 400);
$img->SaveProportionateImage('./img_small' . $up->filename, 100, 75);
$img->Free();
$up->DeleteFile();
?>
non avendo mai usato le classi vichiedo se inseito questi comandi nel posto giusto nella classe
opure li devo posizionare diversamente per far funzionare il tutto???Codice PHP:<?
//$up->filename è il nome del file uploadato o il 'nuovo_nome' del file
//in caso abbiamo usato il metodo RenameFile della classe FileUpload.
$result = $img->CreateSourceImage();
$img->SaveProportionateImage('./img_big' . $up->filename, 100, 400);
$img->SaveProportionateImage('./img_small' . $up->filename, 100, 75);
$img->Free();
$up->DeleteFile();
?>

Rispondi quotando