pixmicat

Subversion Repositories:
Compare Path: Rev
With Path: Rev
/PIO/ @ 817  →  /PIO/ @ 818
/PIO/lib/thumb/thumb.repng2jpeg.php
@@ -11,15 +11,21 @@
 
class ThumbWrapper{
var $sourceFile, $sourceWidth, $sourceHeight, $thumbWidth, $thumbHeight, $thumbSetting, $thumbQuality;
var $_exec, $_sys_exec, $_support_bmp;
var $_exec, $_sys_exec, $_support_bmp, $_shell_escape;
 
function ThumbWrapper($sourceFile='', $sourceWidth=0, $sourceHeight=0){
$this->sourceFile = $sourceFile;
$this->sourceWidth = $sourceWidth;
$this->sourceHeight = $sourceHeight;
$this->_exec = realpath('./repng2jpeg'.(strtoupper(substr(PHP_OS, 0, 3))==='WIN' ? '.exe' : ''));
if(strtoupper(substr(PHP_OS, 0, 3))==='WIN' && strpos($this->_exec,' ')!==false)
if(strtoupper(substr(PHP_OS, 0, 3))==='WIN' && strpos($this->_exec,' ')!==false) {
$this->_shell_escape = 1;
$this->_exec = '"'.$this->_exec.'"';
}
elseif(strtoupper(substr(PHP_OS, 0, 3))!='WIN' && strpos($this->_exec,' ')!==false) {
$this->_shell_escape = 2;
$this->_exec = str_replace(' ','\ ',$this->_exec);
}
if(function_exists('exec')) {
@exec('repng2jpeg --version', $status, $retval);
if($retval===0) {
@@ -30,17 +36,27 @@
}
}
 
function _shell_unescape($exec) {
if($this->_shell_escape == 1)
return substr($exec,1,-1);
elseif($this->_shell_escape == 2)
return str_replace('\ ',' ',$exec);
else
return $exec;
}
 
function getClass(){
$str = 'repng2jpeg Wrapper';
if($this->isWorking()){
$str .= ' : '.`$this->_exec --version`;
if($this->_support_bmp) $str .= '(BMP supported)';
if($this->_sys_exec) $str .= '[S]';
}
return $str;
}
 
function isWorking(){
return ($this->_sys_exec || ($this->_exec{0} == '"' ? file_exists(substr($this->_exec,1,-1)) : file_exists($this->_exec))) && function_exists('exec') && ($this->_sys_exec || strtoupper(substr(PHP_OS, 0, 3))==='WIN' || is_executable($this->_exec));
return ($this->_sys_exec || file_exists($this->_shell_unescape($this->_exec))) && function_exists('exec') && ($this->_sys_exec || strtoupper(substr(PHP_OS, 0, 3))==='WIN' || is_executable($this->_shell_unescape($this->_exec)));
}
 
function setThumbnailConfig($thumbWidth, $thumbHeight, $thumbSetting){
@@ -48,6 +64,8 @@
$this->thumbHeight = $thumbHeight;
$this->thumbSetting = $thumbSetting;
$this->thumbQuality = $thumbSetting['Quality'];
if($thumbSetting['Format']=='png') $this->thumbQuality = 'P';
elseif($thumbSetting['Format']=='gif') $this->thumbQuality = 'G';
}
 
function makeThumbnailtoFile($destFile){