Hi frnds...
here i am getting some error...plz check this one...
these are the two files regarding my code...
thumbnail.php
<?php
class thumbnail {
var $img;
function thumbnail($imgfile)
{
//detect image format
$this->img["format"]=ereg_replace(".*\.(.*)$","\\1",$imgfile);
$this->img["format"]=strtoupper($this->img["format"]);
if (strtoupper($this->img["format"])=="JPG" || strtoupper($this->img["format"])=="JPEG") {
//JPEG
$this->img["format"]="JPEG";
$this->img["src"] = imagecreatefromjpeg($imgfile);
} elseif ($this->img["format"]=="PNG") {
//PNG
$this->img["format"]="PNG";
$this->img["src"] = @ImageCreateFromPNG ($imgfile);
} elseif ($this->img["format"]=="GIF") {
//GIF
$this->img["format"]="GIF";
$this->img["src"] = @ImageCreateFromGIF ($imgfile);
} elseif ($this->img["format"]=="WBMP") {
//WBMP
$this->img["format"]="WBMP";
$this->img["src"] = @ImageCreateFromWBMP ($imgfile);
} else {
return 0;
}
$this->img["src_width"] = imagesx($this->img["src"]);
$this->img["src_height"] = imagesy($this->img["src"]);
}
/*$save => containa a path where the thumbnail will be stored ex. sohail/a.png
$w => width of thumbnail
$h => height of thumbnail
*/
function saveImage($save="",$w,$h)
{
$old_x=imageSX($save);
$old_y=imageSY($save);
if ($old_x > $old_y) {
$thumb_w=$w;
$thumb_h=$old_y*($h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($w/$old_y);
$thumb_h=$h;
}
if ($old_x == $old_y) {
$thumb_w=$w;
$thumb_h=$h;
}
$this->img["dest_width"] = $thumb_w ;
$this->img["dest_height"] = $thumb_h ;
/* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/
$this->img["des"] = imagecreatetruecolor($this->img["dest_width"],$this->img["dest_height"]) ;
@imagecopyresized($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["dest_width"], $this->img["dest_height"], $this->img["src_width"], $this->img["src_height"]);
if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
//JPEG
@imagejpeg($this->img["des"],"$save",75);
} elseif ($this->img["format"]=="PNG") {
//PNG
@imagepng($this->img["des"],"$save");
} elseif ($this->img["format"]=="GIF") {
//GIF
@imagegif($this->img["des"],"$save");
} elseif ($this->img["format"]=="WBMP") {
//WBMP
@imagewbmp($this->img["des"],"$save");
}
}
}
//End of thumbnail
gallery.php
@$tmp_name0 = $_FILES["attachments4"]["tmp_name"][0];
@$name0 = $_FILES["attachments4"]["name"][0];
@$type0=$_FILES["attachments4"]["type"][0];
@$size0=$_FILES["attachments4"]["size"][0];
$title1="../../gallery/allgallerys/$gcategory/$gname";
@move_uploaded_file($tmp_name0, "$title1"."/"."$name0");
if($name0!='')
{
$thumbpath0="$tpath/thumb/$name0";
$filepath0="$title1/$name0";
$thumb = new thumbnail($filepath0);
[B]$thumb -> saveImage($thumbpath0,"115","120");[/B]
$path="$title"."/"."$name0";
$sql="insert into galleryphotos values('','$gid','$path','$thumbpath0','$date')";
mysql_query($sql)or die(mysql_error());
}
here everything is ok..but my problem is getting warning
and also image is damaged....plz rectify this problem...