* * @author Ian Selby <*****@*****.**> * @copyright Copyright (c) 2009 Gen X Design * @link http://phpthumb.gxdlabs.com * @license http://www.opensource.org/licenses/mit-license.php The MIT License * @version 3.0 * @package PhpThumb * @filesource */ // define some useful constants define('THUMBLIB_BASE_PATH', dirname(__FILE__)); define('THUMBLIB_PLUGIN_PATH', THUMBLIB_BASE_PATH . '/thumb_plugins/'); define('DEFAULT_THUMBLIB_IMPLEMENTATION', 'gd'); /** * Include the PhpThumb Class */ require_once THUMBLIB_BASE_PATH . '/PhpThumb.inc.php'; /** * Include the ThumbBase Class */ require_once THUMBLIB_BASE_PATH . '/ThumbBase.inc.php'; /** * Include the GdThumb Class */ require_once THUMBLIB_BASE_PATH . '/GdThumb.inc.php'; /** * PhpThumbFactory Object *
imagecopy($this->workingImage, $this->workingImage, $x, $y_i - $y - 1, $x, $y, 1, 1); } } } /** * Converts a hex color to rgb tuples * * @return mixed * @param string $hex * @param bool $asString */ protected function hex2rgb($hex, $asString = false) { // strip off any leading # if (0 === strpos($hex, '#')) { $hex = substr($hex, 1); } elseif (0 === strpos($hex, '&H')) { $hex = substr($hex, 2); } // break into hex 3-tuple $cutpoint = ceil(strlen($hex) / 2) - 1; $rgb = explode(':', wordwrap($hex, $cutpoint, ':', $cutpoint), 3); // convert each tuple to decimal $rgb[0] = isset($rgb[0]) ? hexdec($rgb[0]) : 0; $rgb[1] = isset($rgb[1]) ? hexdec($rgb[1]) : 0; $rgb[2] = isset($rgb[2]) ? hexdec($rgb[2]) : 0; return $asString ? "{$rgb[0]} {$rgb[1]} {$rgb[2]}" : $rgb; } } $pt = PhpThumb::getInstance(); $pt->registerPlugin('GdReflectionLib', 'gd');
/** * Utility function for checking if the server can generate thumbnails. * * @return bool True if it can, false otherwise. */ public function thumbnailsAvailable() { if (!self::$_thumbnails) { require_once JPATH_LIBRARIES.'/koowa/components/com_files/helper/phpthumb/phpthumb.php'; $pt = PhpThumb::getInstance(); self::$_thumbnails = $pt->isValidImplementation(PhpThumbFactory::$defaultImplemenation) || $pt->isValidImplementation('gd'); } return self::$_thumbnails; }