Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

DIY 裁减功能中的BUG

[复制链接]
yovei 发表于 2012-7-19 16:16:00 | 显示全部楼层 |阅读模式
裁图中  出现问题 提示 imagepreview_errorcode_1 错误


module/misc/misc_imgcropper.php中
  1.         $picwidth = $cutwidth > $_GET['picwidth'] ? $cutwidth : $_GET['picwidth'];
  2.         $picheight = $cutheight > $_GET['picheight'] ? $cutheight : $_GET['picheight'];
复制代码
$picwidth,$picheight  可以大于 图片高宽


source/class/class_image.php中
  1.         function Thumb_GD() {
  2.                 if(!function_exists('imagecreatetruecolor') || !function_exists('imagecopyresampled') || !function_exists('imagejpeg') || !function_exists('imagecopymerge')) {
  3.                         return -4;
  4.                 }

  5.                 $imagefunc = &$this->imagefunc;
  6.                 $attach_photo = $this->loadsource();
  7.                 if($attach_photo < 0) {
  8.                         return $attach_photo;
  9.                 }
  10.                 $copy_photo = imagecreatetruecolor($this->imginfo['width'], $this->imginfo['height']);
  11.                 $bg = imagecolorallocate($copy_photo, 255, 255, 255);
  12.                 imagefill($copy_photo, 0, 0, $bg);
  13.                 imagecopy($copy_photo, $attach_photo ,0, 0, 0, 0, $this->imginfo['width'], $this->imginfo['height']);
  14.                 $attach_photo = $copy_photo;

  15.                 switch($this->param['thumbtype']) {
  16.                         case 'fixnone':
  17.                         case 1:
  18. //*******************************************
  19. // $picwidth,$picheight  可以大于 图片高宽
  20. // 及 $this->param['thumbwidth'] 》$this->imginfo['width']  
  21. // 所以出现了BUG   下面这段代码不会运行
  22. //*******************************************
  23.                                 if($this->imginfo['width'] > $this->param['thumbwidth'] || $this->imginfo['height'] > $this->param['thumbheight']) {
  24.                                         $thumb = array();
  25.                                         list(,,$thumb['width'], $thumb['height']) = $this->sizevalue(0);
  26.                                         $cx = $this->imginfo['width'];
  27.                                         $cy = $this->imginfo['height'];
  28.                                         $thumb_photo = imagecreatetruecolor($thumb['width'], $thumb['height']);
  29.                                         imagecopyresampled($thumb_photo, $attach_photo ,0, 0, 0, 0, $thumb['width'], $thumb['height'], $cx, $cy);
  30.                                 }
  31.                                 break;
  32.                         case 'fixwr':
  33.                         case 2:
  34.                                 if(!($this->imginfo['width'] <= $this->param['thumbwidth'] || $this->imginfo['height'] <= $this->param['thumbheight'])) {
  35.                                         list($startx, $starty, $cutw, $cuth) = $this->sizevalue(1);
  36.                                         $dst_photo = imagecreatetruecolor($cutw, $cuth);
  37.                                         imagecopymerge($dst_photo, $attach_photo, 0, 0, $startx, $starty, $cutw, $cuth, 100);
  38.                                         $thumb_photo = imagecreatetruecolor($this->param['thumbwidth'], $this->param['thumbheight']);
  39.                                         imagecopyresampled($thumb_photo, $dst_photo ,0, 0, 0, 0, $this->param['thumbwidth'], $this->param['thumbheight'], $cutw, $cuth);
  40.                                 } else {
  41.                                         $thumb_photo = imagecreatetruecolor($this->param['thumbwidth'], $this->param['thumbheight']);
  42.                                         $bgcolor = imagecolorallocate($thumb_photo, 255, 255, 255);
  43.                                         imagefill($thumb_photo, 0, 0, $bgcolor);
  44.                                         $startx = ($this->param['thumbwidth'] - $this->imginfo['width']) / 2;
  45.                                         $starty = ($this->param['thumbheight'] - $this->imginfo['height']) / 2;
  46.                                         imagecopymerge($thumb_photo, $attach_photo, $startx, $starty, 0, 0, $this->imginfo['width'], $this->imginfo['height'], 100);
  47.                                 }
  48.                                 break;
  49. //*******************************************
  50. //自己加了一个 拿来临时解决此类BUG。不过也不完善。
  51.                         case 3:
  52.                                 $this->param['thumbheight'] = $this->imginfo['height'] * ($this->param['thumbwidth'] / $this->imginfo['width']);
  53.                                 $thumb = array();
  54.                                 list(,, $thumb['width'], $thumb['height']) = $this->sizevalue(0);
  55.                                 $cx = $this->imginfo['width'];
  56.                                 $cy = $this->imginfo['height'];
  57.                                 $thumb_photo = imagecreatetruecolor($thumb['width'], $thumb['height']);
  58.                                 $bgcolor = imagecolorallocate($thumb_photo, 255, 255, 255);
  59.                                 imagefill($thumb_photo, 0, 0, $bgcolor);
  60.                                 imagecopyresampled($thumb_photo, $attach_photo, 0, 0, 0, 0, $thumb['width'], $thumb['height'], $cx, $cy);
  61.                                 break;
  62. //*******************************************
  63.                 }
  64.                 clearstatcache();
  65.                 if($this->imginfo['mime'] == 'image/jpeg') {
  66.                         @$imagefunc($thumb_photo, $this->target, $this->param['thumbquality']);
  67.                 } else {
  68.                         @$imagefunc($thumb_photo, $this->target);
  69.                 }
  70.                 return 1;
  71.         }
复制代码
希望官方早日解决   





无效楼层,该帖已经被删除
m.king 发表于 2012-7-19 17:42:28 | 显示全部楼层
请问如何重现 裁图中  出现问题 提示 imagepreview_errorcode_1 错误  。

请告之详细重现步骤。
回复

使用道具 举报

 楼主| yovei 发表于 2012-7-19 21:34:57 | 显示全部楼层
m.king 发表于 2012-7-19 17:42
请问如何重现 裁图中  出现问题 提示 imagepreview_errorcode_1 错误  。

请告之详细重现步骤。

比如  我的diy模块限制的图片大小是 300x300  实际图片是 400X600
我把这个图拉大  成为800X1200的时候 好像就会这样!
还有一种情况是  diy模块限制的图片大小是 300x300  实际图片 200X200
也会出现问题!  
回复

使用道具 举报

 楼主| yovei 发表于 2012-7-19 21:40:46 | 显示全部楼层
m.king 发表于 2012-7-19 17:42
请问如何重现 裁图中  出现问题 提示 imagepreview_errorcode_1 错误  。

请告之详细重现步骤。

其实看代码很明显就知道     这个逻辑会冲突

在diy 裁图 是先 生成与缩放大小一致的 图片 然后再根据位置进行裁剪

而在原有的Thumb_GD中  如果 缩放的大小 超过原图 则不会执行相关代码了  这样就会出现问题了

if($this->imginfo['width'] > $this->param['thumbwidth'] || $this->imginfo['height'] > $this->param['thumbheight']) {


thumbwidth 是 等于 传参过来的 width
但是thumbheight 是等于 原图的等高
这个判断中就根本不会执行了
回复

使用道具 举报

m.king 发表于 2012-7-20 15:47:20 | 显示全部楼层
yovei 发表于 2012-7-19 21:40
其实看代码很明显就知道     这个逻辑会冲突

在diy 裁图 是先 生成与缩放大小一致的 图片 然后再根据位 ...

该问题我们再看看。
回复

使用道具 举报

m.king 发表于 2012-7-20 15:47:20 | 显示全部楼层
yovei 发表于 2012-7-19 21:40
其实看代码很明显就知道     这个逻辑会冲突

在diy 裁图 是先 生成与缩放大小一致的 图片 然后再根据位 ...

该问题我们再看看。
回复

使用道具 举报

 楼主| yovei 发表于 2012-7-20 16:34:14 | 显示全部楼层
m.king 发表于 2012-7-20 15:47
该问题我们再看看。

DIY里面 图片限制267x437的宽高
图片使用这个  


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

 楼主| yovei 发表于 2012-7-20 16:34:59 | 显示全部楼层
本帖最后由 yovei 于 2012-7-21 08:48 编辑
m.king 发表于 2012-7-20 15:47
该问题我们再看看。

或者可以QQ CALL 我下 我演示给你看!  
回复

使用道具 举报

m.king 发表于 2012-7-20 17:52:33 | 显示全部楼层
yovei 发表于 2012-7-20 16:34
或者可以QQ CALL 我下 我演示给你看!  281762391

等会再看看吧。我现在忙其他。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-5-18 18:33 , Processed in 0.055556 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表