最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php创建缩略图程序
时间:2022-07-02 10:15:49 编辑:袖梨 来源:一聚教程网
function Thumb_IM($thumbwidth, $thumbheight, $preview = 0) {
global $thumbstatus, $imageimpath, $thumbquality;
if($thumbstatus) {
list($img_w, $img_h) = $this->attachinfo;
$targetfile = !$preview ? ($thumbstatus == 1 || $thumbstatus == 3 ? $this->targetfile.'.thumb.jpg' : $this->targetfile) : DISCUZ_ROOT.'./forumdata/watermark_temp.jpg';
if(!$this->animatedgif && ($img_w >= $thumbwidth || $img_h >= $thumbheight)) {
if($thumbstatus != 3) {
$exec_str = $imageimpath.'/convert -quality '.intval($thumbquality).' -geometry '.$thumbwidth.'x'.$thumbheight.' '.$this->targetfile.' '.$targetfile;
@exec($exec_str, $output, $return);
if(empty($return) && empty($output)) {
$this->attach['thumb'] = $thumbstatus == 1 ? 1 : 0;
}
} else {
$imgratio = $img_w / $img_h;
$thumbratio = $thumbwidth / $thumbheight;
if($imgratio >= 1 && $imgratio >= $thumbratio || $imgratio < 1 && $imgratio > $thumbratio) {
$cuty = $img_h;
$cutx = $cuty * $thumbratio;
} elseif($imgratio >= 1 && $imgratio <= $thumbratio || $imgratio < 1 && $imgratio < $thumbratio) {
$cutx = $img_w;
$cuty = $cutx / $thumbratio;
}
$exec_str = $imageimpath.'/convert -crop '.$cutx.'x'.$cuty.'+0+0 '.$this->targetfile.' '.$targetfile;
@exec($exec_str, $output, $return);
$exec_str = $imageimpath.'/convert -quality '.intval($thumbquality).' -geometry '.$thumbwidth.'x'.$thumbheight.' '.$targetfile.' '.$targetfile;
@exec($exec_str, $output, $return);
if(empty($return) && empty($output)) {
$this->attach['thumb'] = $thumbstatus == 1 || $thumbstatus == 3 ? 1 : 0;
}
}
}
}
}
相关文章
- 《星之破晓》虞姬云霓雀翎有哪些技能 06-14
- 《大侠立志传》御剑属性书获取条件说明 06-14
- 《异界事务所》困难1-4-1有哪些快速通关方法 06-14
- usdt交易平台有哪些?十大usdt交易平台推荐排行 06-14
- 《花亦山心之月》苏望夷装备搭配技巧全解 06-14
- 《卡拉彼丘》对局编号如何正确使用 06-14