public function resetimg($savePath, $image_name, $save_path)
{
$file_path = date('/Y/md/H/');
$filename = UPLOAD_URL . $file_path . $image_name;
//将URL转化为本地地址
$oldimageinfo = getimagesize($filename);
$w = intval($oldimageinfo[0]);
$h = intval($oldimageinfo[1]);
$type = intval($oldimageinfo[2]);
switch ($type) {
case 2:
$image = imagecreatefromjpeg($filename);
break;
case 1:
$image = imagecreatefromgif($filename);
break;
case 3:
$image = imagecreatefrompng($filename);
imagesavealpha($image, true);
break;
}
if ($image) {
if ($w <= 1000 && $w) {
} elseif ($w) {
$temp = 1000 / $w;
$width = 1000;
$height = floor($h * $temp);
$image_p = imagecreatetruecolor($width, $height);
imagealphablending($image_p, false);
imagesavealpha($image_p, true);
$res = imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $w, $h);
$size = filesize($filename);
$real = 500 * 1024;
if ($size > $real) {
$temp = sqrt($real / $size);
$width = floor($width * $temp);
$height = floor($height * $temp);
$image_p = imagecreatetruecolor($width, $height);
imagealphablending($image_p, false);
imagesavealpha($image_p, true);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $w, $h);
}
$ii = imagejpeg($image_p, $savePath . $image_name);
imagedestroy($image_p);
imagedestroy($image);
}
}
}