コード例 #1
0
ファイル: Reflection.php プロジェクト: densem-2013/exikom
                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 = RokCommon_Image::getInstance();
$pt->registerPlugin('RokCommon_Image_Plugin_Reflection', 'gd');
コード例 #2
0
ファイル: Image.php プロジェクト: densem-2013/exikom
 /**
  * Returns an instance of self
  *
  * This is the usual singleton function that returns / instantiates the object
  *
  * @return RokCommon_Image
  */
 public static function getInstance()
 {
     if (!self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #3
0
ファイル: Image.php プロジェクト: densem-2013/exikom
 public function resize($width = 0, $height = 0)
 {
     $container = RokCommon_Service::getContainer();
     /** @var $platformHelper RokSprocket_PlatformHelper */
     $platformHelper = $container->roksprocket_platformhelper;
     if (!empty($this->filepath) && file_exists($this->filepath)) {
         try {
             $file_parts = pathinfo($this->filepath);
             $file_path_md5 = md5($this->filepath);
             $new_path = sprintf('%s/%s_%d_%d.%s', $platformHelper->getCacheDir(), $file_path_md5, $height, $width, $file_parts['extension']);
             $new_source = sprintf('%s/%s_%d_%d.%s', $platformHelper->getCacheUrl(), $file_path_md5, $height, $width, $file_parts['extension']);
             if (!file_exists($new_path)) {
                 $new_path_parts = pathinfo($new_path);
                 if (!is_dir($new_path_parts['dirname']) && !is_file($new_path_parts['dirname'])) {
                     $origmask = @umask(0);
                     if (!($ret = @mkdir($new_path_parts['dirname'], 0755, true))) {
                         @umask($origmask);
                         throw new RokCommon_Image_Exception(rc__('Unable to create directory %s.', $new_path_parts['dirname']));
                     }
                     @umask($origmask);
                 }
                 $resized_image = RokCommon_Image::create($this->filepath);
                 $resized_image->setOption(RokCommon_Image_ImageType::OPTION_NAME_RESIZE_UP, true);
                 $resized_image->resize($width, $height)->save($new_path);
             }
             $this->setSource($new_source);
         } catch (RokCommon_Image_Exception $rcie) {
         }
     }
 }