makeThumb() публичный статический Метод

生成缩略图
public static makeThumb ( string $image, string $thumbName, null $type = null, integer $width = 100, integer $height = 50, boolean $isAutoFix = true ) : false | string
$image string 要缩略的图
$thumbName string 生成的缩略图的路径
$type null 要生成的图片类型 默认跟原图一样
$width integer 缩略图的宽度
$height integer 缩略图的高度
$isAutoFix boolean 是否按比例缩放
Результат false | string
Пример #1
0
 /**
  * 保存
  *
  * @param array $file
  *
  * @return bool
  */
 private function save($file)
 {
     $filename = $file['savepath'] . $file['savename'];
     if (!$this->config['replace'] && is_file($filename)) {
         //不覆盖同名文件
         $this->errorInfo = "文件已经存在{$filename}";
         return false;
     }
     //如果是图片,检查格式
     if (in_array(strtolower($file['extension']), ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf']) && false === getimagesize($file['tmp_name'])) {
         $this->errorInfo = '非法图像文件';
         return false;
     }
     if (!move_uploaded_file($file['tmp_name'], $filename)) {
         $this->errorInfo = '文件上传错误!';
         return false;
     }
     if ($this->config['thumb'] && in_array(strtolower($file['extension']), ['gif', 'jpg', 'jpeg', 'bmp', 'png'])) {
         if ($image = getimagesize($filename)) {
             //生成缩略图
             $thumbPath = $this->config['thumbPath'] ? $this->config['thumbPath'] : dirname($filename);
             $thunbName = $this->config['thumbFile'] ? $this->config['thumbFile'] : $this->config['thumbPrefix'] . basename($filename);
             Image::makeThumb($filename, $thumbPath . '/' . $thunbName, null, $this->config['thumbMaxWidth'], $this->config['thumbMaxHeight']);
         }
     }
     return true;
 }