php创建缩略图程序
<?php 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 (emptyempty($return) && emptyempty($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 (emptyempty($return) && emptyempty($output)) { $this->attach['thumb'] = $thumbstatus == 1 || $thumbstatus == 3 ? 1 : 0; } } } } }
本文地址:http://www.phprm.com/tuxiang/fs4504.html
转载随意,但请附上文章地址:-)