User uploaded image resizing issue with Mozilla
Posted: Tue Sep 07, 2004 2:04 pm
Script I use to resize user uploaded image works well in IE, but doesn't resize image in Mozilla. Any ideas why?
Code: Select all
if($picture!=null)
{
$type=@explode(".",$picture);
$name=$type[0];
$image=$this->path."images/".$picture;
$size=getimagesize($image);
//get photo file type
$type=$size[2];
$width=$size[0];
//echo $width."<br>";
$height=$size[1];
//echo $height."==height<br>";
$newwidth = 300;
$newheight = 300;
if($width<$newwidth and $height<$newheight)
{
return;
}
if($width>=$height)
{
$factor=$width/$newwidth;
$newheight=$height/$factor;
$newwidth=$width/$factor;
}
else
{
$factor=$height/$newheight;
$newwidth=$width/$factor;
$newheight=$height/$factor;
}
$im1=ImageCreateTrueColor($newwidth,$newheight);
if($type==2)
{
$name=$name.".jpg";
$im = ImageCreateFromJpeg("$image");
}
elseif($type==3)
{
$name=$name.".png";
$im = ImageCreateFromPng("$image");
}
elseif($type==1)
{
$name=$name.".gif";
$im = ImageCreateFromGif("$image");
}
$newpath=$this->path."images/".$name;
imagecopyresampled ($im1, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // reduce the image sizes
if($type==3)
{
ImagePng($im1,$newpath); // output image
}
elseif($type==2)
{
ImageJPEG($im1,$newpath,100); // output image
}
elseif($type==1)
{
imagetruecolortopalette($im1, true, 256);
ImageGIF($im1,$newpath); // output image
}
chmod($newpath,0777);
ImageDestroy($im1);
}
}