用户名:
密 码: 记住
您当前的位置:首页 > 网络编程 > php教程

php创建缩略图程序

时间:2015-01-23  来源:西部数据  作者:西部数据
  1. function Thumb_IM($thumbwidth$thumbheight$preview = 0) { 
  2.   global $thumbstatus$imageimpath$thumbquality
  3.   if($thumbstatus) { 
  4.    list($img_w$img_h) = $this->attachinfo; 
  5.    $targetfile = !$preview ? ($thumbstatus == 1 || $thumbstatus == 3 ? $this->targetfile.'.thumb.jpg' : $this->targetfile) : DISCUZ_ROOT.'./forumdata/watermark_temp.jpg'
  6.    if(!$this->animatedgif && ($img_w >= $thumbwidth || $img_h >= $thumbheight)) { 
  7.     if($thumbstatus != 3) { 
  8.      $exec_str = $imageimpath.'/convert -quality '.intval($thumbquality).' -geometry '.$thumbwidth.'x'.$thumbheight.' '.$this->targetfile.' '.$targetfile
  9.      @exec($exec_str$output$return); 
  10.      if(emptyempty($return) && emptyempty($output)) { 
  11.       $this->attach['thumb'] = $thumbstatus == 1 ? 1 : 0; 
  12.      } 
  13.     } else { 
  14.      $imgratio = $img_w / $img_h
  15.      $thumbratio = $thumbwidth / $thumbheight
  16.      if($imgratio >= 1 && $imgratio >= $thumbratio || $imgratio < 1 && $imgratio > $thumbratio) { 
  17.       $cuty = $img_h
  18.       $cutx = $cuty * $thumbratio
  19.      } elseif($imgratio >= 1 && $imgratio <= $thumbratio || $imgratio < 1 && $imgratio < $thumbratio) { 
  20.       $cutx = $img_w
  21.       $cuty = $cutx / $thumbratio
  22.      } 
  23.      $exec_str = $imageimpath.'/convert -crop '.$cutx.'x'.$cuty.'+0+0  '.$this->targetfile.' '.$targetfile
  24.      @exec($exec_str$output$return); 
  25.      $exec_str = $imageimpath.'/convert -quality '.intval($thumbquality).' -geometry '.$thumbwidth.'x'.$thumbheight.' '.$targetfile.' '.$targetfile
  26.      @exec($exec_str$output$return); 
  27.      if(emptyempty($return) && emptyempty($output)) { 
  28.       $this->attach['thumb'] = $thumbstatus == 1 || $thumbstatus == 3 ? 1 : 0; 
  29.      }//开源代码phpfensi.com 
  30.     } 
  31.              } 
  32.   } 
  33.  } 
来顶一下
返回首页
返回首页
推荐资讯
WiFi太不安全:7岁女孩11分钟内入侵公共网络 WiFi太不安全:7岁女孩11分钟内入侵近期刚刚发布研究说WiFi网络能获得人们手机里多少私人信息,
不服跑个分?人工智能也出现“刷分”乱象 不服跑个分?人工智能也出现“刷分2014年,人工智能领域突然爆发,成为了科研和科技创业的热门
相关文章
    无相关信息
栏目更新
栏目热门