function setImage($image)
 {
     if (!rex_image::isValid($image)) {
         trigger_error('Given image is not a valid rex_image_abstract', E_USER_ERROR);
     }
     $this->image = $image;
 }
 public function applyEffects(rex_image $image, $type)
 {
     global $REX;
     if (!$this->image_cacher->isCached($image, $type)) {
         $set = $this->effectsFromType($type);
         // REGISTER EXTENSION POINT
         $set = rex_register_extension_point('IMAGE_MANAGER_FILTERSET', $set, array('rex_image_type' => $type, 'img' => $image));
         $image->prepare();
         // execute effects on image
         $effect = array();
         $c = 1;
         foreach ($set as $effect_params) {
             $effect_class = 'rex_effect_' . $effect_params['effect'];
             require_once dirname(__FILE__) . '/effects/class.' . $effect_class . '.inc.php';
             $effect[$c] = new $effect_class();
             $effect[$c]->setImage($image);
             $effect[$c]->setParams($effect_params['params']);
             if (!$effect[$c]->execute()) {
             } else {
             }
         }
         if (!rex_image::isValid($image) || !$image->isImage()) {
             // Given image is not a valid rex_image
             $image->sendErrorImage();
         }
     }
     return $image;
 }
 function sendImage($image, $cacheParams, $lastModified = null)
 {
     global $REX;
     if (!rex_image::isValid($image)) {
         trigger_error('Given image is not a valid rex_image', E_USER_ERROR);
     }
     $cacheFile = $this->getCacheFile($image, $cacheParams);
     // save image to file
     if (!$this->isCached($image, $cacheParams)) {
         $image->prepare();
         $image->save($cacheFile);
     }
     $tmp = $REX['USE_GZIP'];
     $REX['USE_GZIP'] = 'false';
     // send file
     $format = $image->getFormat();
     $image->sendHeader();
     rex_send_file($cacheFile, 'image/' . $format, 'frontend');
     $REX['USE_GZIP'] = $tmp;
 }
 function applyEffects($image, $type)
 {
     global $REX;
     if (!rex_image::isValid($image)) {
         trigger_error('Given image is not a valid rex_image', E_USER_ERROR);
     }
     if (!$this->image_cacher->isCached($image, $type)) {
         $set = $this->effectsFromType($type);
         $image->prepare();
         // execute effects on image
         foreach ($set as $effect_params) {
             $effect_class = 'rex_effect_' . $effect_params['effect'];
             require_once dirname(__FILE__) . '/effects/class.' . $effect_class . '.inc.php';
             $effect = new $effect_class();
             $effect->setImage($image);
             $effect->setParams($effect_params['params']);
             $effect->execute();
         }
     }
     return $image;
 }
 function sendImage($image, $cacheParams, $lastModified = null)
 {
     if (!rex_image::isValid($image)) {
         trigger_error('Given image is not a valid rex_image', E_USER_ERROR);
     }
     // caching gifs doesn't work
     //	  if($image->getFormat() == 'GIF' && !$image->hasGifSupport())
     //	  {
     //	    $image->prepare();
     //	    $image->send($lastModified);
     //	  }
     //	  else
     //	  {
     $cacheFile = $this->getCacheFile($image, $cacheParams);
     // save image to file
     if (!$this->isCached($image, $cacheParams)) {
         $image->prepare();
         $image->save($cacheFile);
     }
     // send file
     $image->sendHeader(array("Content-Length" => filesize($cacheFile)));
     readfile($cacheFile);
     //	  }
 }
 function execute()
 {
     global $REX;
     // -------------------------------------- CONFIG
     $brandimage = $REX['MEDIAFOLDER'] . '/' . $this->params['brandimage'];
     if (!file_exists($brandimage) || !is_file($brandimage)) {
         $brandimage = dirname(__FILE__) . '/../../media/brand.gif';
     }
     // Abstand vom Rand
     $padding_x = -10;
     if (isset($this->params['padding_x'])) {
         $padding_x = (int) $this->params['padding_x'];
     }
     $padding_y = -10;
     if (isset($this->params['padding_y'])) {
         $padding_y = (int) $this->params['padding_y'];
     }
     // horizontale ausrichtung: left/center/right
     $hpos = 'right';
     if (isset($this->params['hpos'])) {
         $hpos = (string) $this->params['hpos'];
     }
     // vertikale ausrichtung:   top/center/bottom
     $vpos = 'bottom';
     if (isset($this->params['vpos'])) {
         $vpos = (string) $this->params['vpos'];
     }
     // -------------------------------------- /CONFIG
     $brand = new rex_image($brandimage);
     $brand->prepare();
     $gdbrand =& $brand->getImage();
     $gdimage =& $this->image->getImage();
     $image_width = $this->image->getWidth();
     $image_height = $this->image->getHeight();
     $brand_width = $brand->getWidth();
     $brand_height = $brand->getHeight();
     switch ($hpos) {
         case 'left':
             $dstX = 0;
             break;
         case 'center':
             $dstX = (int) (($image_width - $brand_width) / 2);
             break;
         case 'right':
         default:
             $dstX = $image_width - $brand_width;
     }
     switch ($vpos) {
         case 'top':
             $dstY = 0;
             break;
         case 'center':
             $dstY = (int) (($image_height - $brand_height) / 2);
             break;
         case 'bottom':
         default:
             $dstY = $image_height - $brand_height;
     }
     imagealphablending($gdimage, true);
     imagecopy($gdimage, $gdbrand, $dstX + $padding_x, $dstY + $padding_y, 0, 0, $brand_width, $brand_height);
     $brand->destroy();
 }