首頁 >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