3 * Thumbnail Generate API: Imagick Wrapper
\r
5 * 提供程式便於以 repng2jpeg 生成預覽圖的物件
\r
7 * @package PMCLibrary
\r
8 * @version $Id: thumb.repng2jpeg.php 497 2007-08-05 12:39:26Z scribe $
\r
9 * @date $Date: 2007-08-05 20:39:26 +0800 (星期日, 05 八月 2007) $
\r
13 var $sourceFile, $sourceWidth, $sourceHeight, $thumbWidth, $thumbHeight, $thumbQuality;
\r
16 function ThumbWrapper($sourceFile='', $sourceWidth=0, $sourceHeight=0){
\r
17 $this->sourceFile = $sourceFile;
\r
18 $this->sourceWidth = $sourceWidth;
\r
19 $this->sourceHeight = $sourceHeight;
\r
20 $this->_exec = realpath('./repng2jpeg'.(strtoupper(substr(PHP_OS, 0, 3))==='WIN' ? '.exe' : ''));
\r
23 function getClass(){
\r
24 $str = 'repng2jpeg Wrapper';
\r
25 if($this->isWorking()){
\r
26 $str .= ' : '.`$this->_exec --version`;
\r
31 function isWorking(){
\r
32 return file_exists($this->_exec) && function_exists('exec') && (strtoupper(substr(PHP_OS, 0, 3))==='WIN' || is_executable($this->_exec));
\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
42 if(!$this->isWorking()) return false;
\r
43 switch(strtolower(strrchr($this->sourceFile, '.'))){ // 取出副檔名
\r
51 $CLI = "$this->_exec \"$this->sourceFile\" \"$destFile\" $this->thumbWidth $this->thumbHeight $this->thumbQuality";
\r