<commit_before><?php
/**
 * Thumbnail Generate API: Imagick Wrapper
 *
 * 提供程式便於以 repng2jpeg 生成預覽圖的物件
 *
 * @package PMCLibrary
 * @version $Id$
 * @date $Date$
 */

class ThumbWrapper{
	var $sourceFile, $sourceWidth, $sourceHeight, $thumbWidth, $thumbHeight, $thumbQuality;
	var $_exec;

	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' : ''));
	}

	function getClass(){
		$str = 'repng2jpeg Wrapper';
		if($this->isWorking()){
			$str .= ' : '.`$this->_exec --version`;
		}
		return $str;
	}

	function isWorking(){
		return file_exists($this->_exec) && (is_executable($this->_exec) || strtoupper(substr(PHP_OS, 0, 3))==='WIN');
	}

	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($destFile, '.'))){ // 取出副檔名
			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;
	}
}
?><commit_msg>修正 PHP 4 for Windows 下沒有is_executable()的問題<commit_after><?php
/**
 * Thumbnail Generate API: Imagick Wrapper
 *
 * 提供程式便於以 repng2jpeg 生成預覽圖的物件
 *
 * @package PMCLibrary
 * @version $Id$
 * @date $Date$
 */

class ThumbWrapper{
	var $sourceFile, $sourceWidth, $sourceHeight, $thumbWidth, $thumbHeight, $thumbQuality;
	var $_exec;

	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' : ''));
	}

	function getClass(){
		$str = 'repng2jpeg Wrapper';
		if($this->isWorking()){
			$str .= ' : '.`$this->_exec --version`;
		}
		return $str;
	}

	function isWorking(){
		return file_exists($this->_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($destFile, '.'))){ // 取出副檔名
			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;
	}
}
?>
{'fraction_non_alphanumeric': 0.19289340101522842, 'fraction_numerical': 0.0077834179357022, 'mean_word_length': 4.619771863117871, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6319938', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1130, 'n_words': 201}