profileImage('icc', $icc_rgb); unset($icc_rgb); $im->setIteratorIndex(0); $owidth=$im->getImageWidth(); $oheight=$im->getImageHeight(); //$whsize = $this->getImageThumbsize($owidth,$oheight,$meta['thumbwidth'],$meta['thumbheight']); if($owidth>getglobal('config/pichomethumlargwidth') && $oheight>getglobal('config/pichomethumlargheight')){ $width=1920; $height=ceil($width*$oheight/$owidth); }else{ $width=$owidth; $height=$oheight; } if($prefix=='ai'){ $prefix='png'; if($width<1920){ $width=1920; $height=ceil($width*$oheight/$owidth); } } if($prefix=='ai'){ $prefix='png'; if($$width<1920){ $width=1920; $height=ceil($width*$oheight/$owidth); } } $a = $im->thumbnailImage($width, $height, false); $im->stripImage(); //去除图片信息 $im->setImageCompressionQuality(100); //图片质量 $im->writeImage(($prefix?$prefix.':':'').$jpg); if($imginfo=@getimagesize($jpg)){ if(!$meta['tmpfile'])C::t('pichome_resources')->update($meta['rid'],array('width'=>$owidth,'height'=>$oheight)); return $jpg; }else{ runlog('imagick','uneable get size file:'.$jpg); return ''; } }catch(\Exception $e){ $message= $e->getMessage(); $message = diconv($message,'GBK','UTF-8'); runlog('imagick',$message.' file:'.$file); }; return ''; } public function getPath($dir = 'imagick') { global $_G; $target1 = $dir . '/index.html'; $target_attach = $_G['setting']['attachdir'] .'./'. $target1; $targetpath = dirname($target_attach); dmkdir($targetpath); return $dir; } public function getImageThumbsize($owidth, $oheight, $width, $height) { if ($owidth > $width || $oheight > $height) { $or = $owidth / $oheight; $r = $width / $height; if ($r > $or) { if ($oheight < $height) { $height = $oheight; $width = $owidth; } else { $width = ceil($height * $or); if ($width < 242) { $width = 242; $height = ceil($width / $or); } } } else { if ($owidth < $width) { $height = $oheight; $width = $owidth; } else { $height = ceil($width / $or); $width = ceil($height * $or); if ($width < 242) { $width = 242; $height = ceil($width / $or); } } } } else { $width = $owidth; $height = $oheight; } //Return the results return array($width, $height); } }