本帖最后由 haierspi 于 2011-7-30 12:49 编辑
第一个在高负载情况下出现不能识别动态GIF..
导致动态图被缩略图并各帧通过IM被分解成多个文件..
比如
一个10帧得GIF图片 会被分解成
data/attachment/image/79188_300_300-0.jpg
........
data/attachment/image/79188_300_300-9.jpg
10个图片..
并反复执行略图图操作..因为生成不能生成目标文件
data/attachment/image/79188_300_300.jpg
第二个
在开启IM之后一段时间通过进程管理
发现ImageMagick 进程 得名两行 进程 convert 不能正常退出
假死并高占用CPU..(测试的4核服务器 刚开始几天都是100%占用..)
所以在这里发一个临时解决补丁
请下载附件直接覆盖根目录.. 主要修改source\class\class_image.php
覆盖补丁包在这里..
如果你想自己动手修改..下面列出了修改方法
打开source\class\class_image.php
找到(大概160行位置)
- $content = fread($fp, $this->imginfo['size']);
复制代码 替换成
- if($this->imginfo['size']){
- $content = fread($fp, $this->imginfo['size']);
- }
- if(!$this->imginfo['size'] || !$content){
- $content = file_get_contents($source);
- }
复制代码
找到(第295行)
- function Thumb_IM() {
- global $_G;
- switch($this->param['thumbtype']) {
- case 'fixnone':
- case 1:
- if($this->imginfo['width'] >= $this->param['thumbwidth'] || $this->imginfo['height'] >= $this->param['thumbheight']) {
- $exec_str = $this->param['imageimpath'].'/convert -quality '.intval($this->param['thumbquality']).' -geometry '.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].' '.$this->source.' '.$this->target;
- $return = $this->exec($exec_str);
- if($return < 0) {
- return $return;
- }
- }
- 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);
- $exec_str = $this->param['imageimpath'].'/convert -quality '.intval($this->param['thumbquality']).' -crop '.$cutw.'x'.$cuth.'+'.$startx.'+'.$starty.' '.$this->source.' '.$this->target;
- $return = $this->exec($exec_str);
- if($return < 0) {
- return $return;
- }
- $exec_str = $this->param['imageimpath'].'/convert -quality '.intval($this->param['thumbquality']).' -thumbnail \''.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].'>\' -resize '.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].' -gravity center -extent '.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].' '.$this->target.' '.$this->target;
- $return = $this->exec($exec_str);
- if($return < 0) {
- return $return;
- }
- } else {
- $startx = -($this->param['thumbwidth'] - $this->imginfo['width']) / 2;
- $starty = -($this->param['thumbheight'] - $this->imginfo['height']) / 2;
- $exec_str = $this->param['imageimpath'].'/convert -quality '.intval($this->param['thumbquality']).' -crop '.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].'+'.$startx.'+'.$starty.' '.$this->source.' '.$this->target;
- $return = $this->exec($exec_str);
- if($return < 0) {
- return $return;
- }
- $exec_str = $this->param['imageimpath'].'/convert -quality '.intval($this->param['thumbquality']).' -thumbnail \''.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].'>\' -gravity center -extent '.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].' '.$this->target.' '.$this->target;
- $return = $this->exec($exec_str);
- if($return < 0) {
- return $return;
- }
- }
- break;
- }
- return 1;
- }
复制代码 替换
- function Thumb_IM() {
- global $_G;
- switch($this->param['thumbtype']) {
- case 'fixnone':
- case 1:
- if($this->imginfo['width'] >= $this->param['thumbwidth'] || $this->imginfo['height'] >= $this->param['thumbheight']) {
- $exec_str = $this->param['imageimpath'].'/convert -quality '.intval($this->param['thumbquality']).' -geometry '.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].' '.$this->source.' '.$this->target;
- $return = $this->exec($exec_str);
- if($return < 0) {
- return $return;
- }
- }
- break;
- case 'fixwr':
- case 2:
- if((substr($this->source,-4)=='.gif') && (substr($this->target,-4)=='.jpg' || substr($this->target,-4)=='.jpe' || substr($this->target,-5)=='.jpeg')){
- $animatedmaybe = '[0]';
- }else{
- $animatedmaybe = '';
- }
- if(!($this->imginfo['width'] < $this->param['thumbwidth'] || $this->imginfo['height'] < $this->param['thumbheight'])) {
- list($startx, $starty, $cutw, $cuth) = $this->sizevalue(1);
- $exec_str = $this->param['imageimpath'].'/convert -quality '.intval($this->param['thumbquality']).' -crop '.$cutw.'x'.$cuth.($startx<0 ?$startx:'+'.$startx).($starty<0 ?$starty:'+'.$starty).' '.$this->source.$animatedmaybe.' '.$this->target;
- $return = $this->exec($exec_str);
- if($return < 0) {
- return $return;
- }
- $exec_str = $this->param['imageimpath'].'/convert -quality '.intval($this->param['thumbquality']).' -thumbnail \''.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].'>\' -resize '.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].' -gravity center -extent '.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].' '.$this->target.' '.$this->target;
- $return = $this->exec($exec_str);
- if($return < 0) {
- return $return;
- }
- } else {
- $startx = -($this->param['thumbwidth'] - $this->imginfo['width']) / 2;
- $starty = -($this->param['thumbheight'] - $this->imginfo['height']) / 2;
- $exec_str = $this->param['imageimpath'].'/convert -quality '.intval($this->param['thumbquality']).' -crop '.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].($startx<0 ?$startx:'+'.$startx).($starty<0 ?$starty:'+'.$starty).' '.$this->source.$animatedmaybe.' '.$this->target;
- $return = $this->exec($exec_str);
- if($return < 0) {
- return $return;
- }
- $exec_str = $this->param['imageimpath'].'/convert -quality '.intval($this->param['thumbquality']).' -thumbnail \''.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].'>\' -gravity center -extent '.$this->param['thumbwidth'].'x'.$this->param['thumbheight'].' '.$this->target.' '.$this->target;
- $return = $this->exec($exec_str);
- if($return < 0) {
- return $return;
- }
- }
- break;
- }
- return 1;
- }
复制代码
|