裁图中 出现问题 提示 imagepreview_errorcode_1 错误
module/misc/misc_imgcropper.php中- $picwidth = $cutwidth > $_GET['picwidth'] ? $cutwidth : $_GET['picwidth'];
- $picheight = $cutheight > $_GET['picheight'] ? $cutheight : $_GET['picheight'];
复制代码 $picwidth,$picheight 可以大于 图片高宽
source/class/class_image.php中- function Thumb_GD() {
- if(!function_exists('imagecreatetruecolor') || !function_exists('imagecopyresampled') || !function_exists('imagejpeg') || !function_exists('imagecopymerge')) {
- return -4;
- }
- $imagefunc = &$this->imagefunc;
- $attach_photo = $this->loadsource();
- if($attach_photo < 0) {
- return $attach_photo;
- }
- $copy_photo = imagecreatetruecolor($this->imginfo['width'], $this->imginfo['height']);
- $bg = imagecolorallocate($copy_photo, 255, 255, 255);
- imagefill($copy_photo, 0, 0, $bg);
- imagecopy($copy_photo, $attach_photo ,0, 0, 0, 0, $this->imginfo['width'], $this->imginfo['height']);
- $attach_photo = $copy_photo;
- switch($this->param['thumbtype']) {
- case 'fixnone':
- case 1:
- //*******************************************
- // $picwidth,$picheight 可以大于 图片高宽
- // 及 $this->param['thumbwidth'] 》$this->imginfo['width']
- // 所以出现了BUG 下面这段代码不会运行
- //*******************************************
- if($this->imginfo['width'] > $this->param['thumbwidth'] || $this->imginfo['height'] > $this->param['thumbheight']) {
- $thumb = array();
- list(,,$thumb['width'], $thumb['height']) = $this->sizevalue(0);
- $cx = $this->imginfo['width'];
- $cy = $this->imginfo['height'];
- $thumb_photo = imagecreatetruecolor($thumb['width'], $thumb['height']);
- imagecopyresampled($thumb_photo, $attach_photo ,0, 0, 0, 0, $thumb['width'], $thumb['height'], $cx, $cy);
- }
- break;
- case 'fixwr':
- case 2:
- if(!($this->imginfo['width'] <= $this->param['thumbwidth'] || $this->imginfo['height'] <= $this->param['thumbheight'])) {
- list($startx, $starty, $cutw, $cuth) = $this->sizevalue(1);
- $dst_photo = imagecreatetruecolor($cutw, $cuth);
- imagecopymerge($dst_photo, $attach_photo, 0, 0, $startx, $starty, $cutw, $cuth, 100);
- $thumb_photo = imagecreatetruecolor($this->param['thumbwidth'], $this->param['thumbheight']);
- imagecopyresampled($thumb_photo, $dst_photo ,0, 0, 0, 0, $this->param['thumbwidth'], $this->param['thumbheight'], $cutw, $cuth);
- } else {
- $thumb_photo = imagecreatetruecolor($this->param['thumbwidth'], $this->param['thumbheight']);
- $bgcolor = imagecolorallocate($thumb_photo, 255, 255, 255);
- imagefill($thumb_photo, 0, 0, $bgcolor);
- $startx = ($this->param['thumbwidth'] - $this->imginfo['width']) / 2;
- $starty = ($this->param['thumbheight'] - $this->imginfo['height']) / 2;
- imagecopymerge($thumb_photo, $attach_photo, $startx, $starty, 0, 0, $this->imginfo['width'], $this->imginfo['height'], 100);
- }
- break;
- //*******************************************
- //自己加了一个 拿来临时解决此类BUG。不过也不完善。
- case 3:
- $this->param['thumbheight'] = $this->imginfo['height'] * ($this->param['thumbwidth'] / $this->imginfo['width']);
- $thumb = array();
- list(,, $thumb['width'], $thumb['height']) = $this->sizevalue(0);
- $cx = $this->imginfo['width'];
- $cy = $this->imginfo['height'];
- $thumb_photo = imagecreatetruecolor($thumb['width'], $thumb['height']);
- $bgcolor = imagecolorallocate($thumb_photo, 255, 255, 255);
- imagefill($thumb_photo, 0, 0, $bgcolor);
- imagecopyresampled($thumb_photo, $attach_photo, 0, 0, 0, 0, $thumb['width'], $thumb['height'], $cx, $cy);
- break;
- //*******************************************
- }
- clearstatcache();
- if($this->imginfo['mime'] == 'image/jpeg') {
- @$imagefunc($thumb_photo, $this->target, $this->param['thumbquality']);
- } else {
- @$imagefunc($thumb_photo, $this->target);
- }
- return 1;
- }
复制代码 希望官方早日解决
|