X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=lib%2Fthumb%2Fthumb.repng2jpeg.php;fp=lib%2Fthumb%2Fthumb.repng2jpeg.php;h=d6414588fd2c585e0e34759c42c3e7670f49ea1e;hb=62196eb15d5c72cd127b7133f20d974238eae774;hp=0000000000000000000000000000000000000000;hpb=e5177fa202121cb20c6b40e774c928210dd56908;p=test.git diff --git a/lib/thumb/thumb.repng2jpeg.php b/lib/thumb/thumb.repng2jpeg.php new file mode 100755 index 0000000..d641458 --- /dev/null +++ b/lib/thumb/thumb.repng2jpeg.php @@ -0,0 +1,56 @@ +sourceFile = $sourceFile; + $this->sourceWidth = $sourceWidth; + $this->sourceHeight = $sourceHeight; + $this->_exec = realpath('./repng2jpeg'.(strtoupper(substr(PHP_OS, 0, 3))==='WIN' ? '.exe' : '')); + } + + function getClass(){ + $str = 'repng2jpeg Wrapper'; + if($this->isWorking()){ + $str .= ' : '.`$this->_exec --version`; + } + return $str; + } + + function isWorking(){ + return file_exists($this->_exec) && function_exists('exec') && (strtoupper(substr(PHP_OS, 0, 3))==='WIN' || is_executable($this->_exec)); + } + + function setThumbnailConfig($thumbWidth, $thumbHeight, $thumbQuality=50){ + $this->thumbWidth = $thumbWidth; + $this->thumbHeight = $thumbHeight; + $this->thumbQuality = $thumbQuality; + } + + function makeThumbnailtoFile($destFile){ + if(!$this->isWorking()) return false; + switch(strtolower(strrchr($this->sourceFile, '.'))){ // 取出副檔名 + case '.jpg': + case '.gif': + case '.png': + break; // 僅支援此三種格式 + default: + return false; + } + $CLI = "$this->_exec \"$this->sourceFile\" \"$destFile\" $this->thumbWidth $this->thumbHeight $this->thumbQuality"; + @exec($CLI); + return true; + } +} +?> \ No newline at end of file