php生成缩略图的效能

php生成缩略图的功能
客户自己上传的图片大小不标准,想让传上来的图片统一变成150X113尺寸的。从网上搜到的程序在IE里用正常,到了别的浏览器(如搜狗浏览器等)就不行,这是什么原因?(感觉老是不执行)
代码如下:

<?php
session_start();
if (isset($_SESSION['adminname']) && isset($_SESSION['adminpass'])){


//****************************************
//生成缩略图========================================
$myname=date("YmdHis");

$filename="product/min/".$myname; //小图片文件名
$resizewidth=150; // 生成图片的宽度 
$resizeheight=113; // 生成图片的高度


function ResizeImage($im,$maxwidth,$maxheight,$name){ 
$resizewidth = $resizeheight = false;
 
$width = imagesx($im); 
$height = imagesy($im); 
if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){ 
if($maxwidth && $width > $maxwidth){ 
$widthratio = $maxwidth/$width; 
$resizewidth=true; 

if($maxheight && $height > $maxheight){ 
$heightratio = $maxheight/$height; 
$resizeheight=true; 

if($resizewidth && $resizeheight){ 
if($widthratio < $heightratio){ 
$ratio = $widthratio; 
}else{ 
$ratio = $heightratio; 

}elseif($resizewidth){ 
$ratio = $widthratio; 
}elseif($resizeheight){ 
$ratio = $heightratio; 

$newwidth = $width * $ratio; 
$newheight = $height * $ratio; 
if(function_exists("imagecopyresampled")){ 
$newim = imagecreatetruecolor($newwidth, $newheight); 
imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); 
}else{ 
$newim = imagecreate($newwidth, $newheight); 
imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); 

ImageJpeg ($newim,$name . ".jpg"); 
ImageDestroy ($newim); 
}else{ 
ImageJpeg ($im,$name . ".jpg"); 

}



if(isset($_FILES['image']['size'])){ 
if($_FILES['image']['type'] == "image/pjpeg"){ 
$im = imagecreatefromjpeg($_FILES['image']['tmp_name']); 
}elseif($_FILES['image']['type'] == "image/x-png"){ 
$im = imagecreatefrompng($_FILES['image']['tmp_name']); 
}elseif($_FILES['image']['type'] == "image/gif"){ 
$im = imagecreatefromgif($_FILES['image']['tmp_name']); 



if($im){ 
if(file_exists("$filename.jpg")){ 
unlink("$filename.jpg"); 


ResizeImage($im,$resizewidth,$resizeheight,$filename);  //生成小图
ImageDestroy ($im); 

echo "上传成功,图片文件名是:";
echo $myname.".jpg";



   //****************************************
}else{
echo "<script> window.location='login.php'</script>";
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body,td,th {
color: #FF0000;
font-size: 12px;
}
body {
margin-left: 2px;
margin-top: 2px;
margin-right: 2px;
margin-bottom: 0px;
background-color: #e3efe7;
}
-->
</style>
</head>
<body>

 <form name="form1" action="" enctype="multipart/form-data"   method="post">

  <input name="image" type="file"> 
  <input type="submit" value="提交">
 </form>


</body>
</html>
------解决思路----------------------
你看看 product/min/ 目录下是否有生成的图片
------解决思路----------------------
ie ,Firefox,chrome试试看,这三个行的话说明代码没问题。