首页 >php教程 >PHP源码 >php 切取图片代码

php 切取图片代码

WBOY
WBOY原创
2016-06-08 17:29:58981浏览

php 切取图片代码

<script>ec(2);</script>

function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){
 list($imagewidth, $imageheight, $imageType) = getimagesize($image);
 $imageType = image_type_to_mime_type($imageType);
 
 $newImageWidth = ceil($width * $scale);
 $newImageHeight = ceil($height * $scale);
 $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
 switch($imageType) {
  case "image/gif":
   $source=imagecreatefromgif($image);
   break;
     case "image/pjpeg":
  case "image/jpeg":
  case "image/jpg":
   $source=imagecreatefromjpeg($image);
   break;
     case "image/png":
  case "image/x-png":
   $source=imagecreatefrompng($image);
   break;
   }
 imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height);
 switch($imageType) {
  case "image/gif":
     imagegif($newImage,$thumb_image_name);
   break;
       case "image/pjpeg":
  case "image/jpeg":
  case "image/jpg":
     imagejpeg($newImage,$thumb_image_name,90);
   break;
  case "image/png":
  case "image/x-png":
   imagepng($newImage,$thumb_image_name); 
   break;
    }
 chmod($thumb_image_name, 0777);
 return $thumb_image_name;
}

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn