3 * Thumbnail Generate API: Imagick Wrapper
\r
5 * 提供程式便於以 Imagick (Imagick Image Library) 生成預覽圖的物件
\r
7 * @package PMCLibrary
\r
8 * @version $Id: thumb.imagick.php 490 2007-07-26 14:36:47Z scribe $
\r
9 * @date $Date: 2007-07-26 22:36:47 +0800 (星期四, 26 七月 2007) $
\r
13 var $sourceFile, $sourceWidth, $sourceHeight, $thumbWidth, $thumbHeight, $thumbQuality;
\r
15 function ThumbWrapper($sourceFile='', $sourceWidth=0, $sourceHeight=0){
\r
16 $this->sourceFile = $sourceFile;
\r
17 $this->sourceWidth = $sourceWidth;
\r
18 $this->sourceHeight = $sourceHeight;
\r
21 function getClass(){
\r
22 $str = 'Imagick Wrapper';
\r
23 if($this->isWorking()){
\r
24 $a = new Imagick(); $b = $a->getVersion(); $b = $b['versionString'];
\r
25 $str .= ' : '.str_replace(strrchr($b, ' '), '', $b);
\r
26 unset($a); unset($b);
\r
31 function isWorking(){
\r
32 return extension_loaded('imagick') && class_exists('Imagick');
\r
35 function setThumbnailConfig($thumbWidth, $thumbHeight, $thumbQuality=50){
\r
36 $this->thumbWidth = $thumbWidth;
\r
37 $this->thumbHeight = $thumbHeight;
\r
38 $this->thumbQuality = $thumbQuality;
\r
41 function makeThumbnailtoFile($destFile){
\r
43 if(!$this->isWorking()) return false;
\r
44 $image = new Imagick($this->sourceFile);
\r
45 $image->setCompressionQuality($this->thumbQuality);
\r
46 $image->thumbnailImage($this->thumbWidth, $this->thumbHeight);
\r
47 $returnVal = $image->writeImage($destFile);
\r