Ejemplo n.º 1
0
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $x = $resource->getImageWidth();
     $y = $resource->getImageHeight();
     $image->resize(round($x * $this->scale), round($y * $this->scale));
     return $image;
 }
Ejemplo n.º 2
0
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $x = imagesx($resource);
     $y = imagesy($resource);
     $image->resize(round($x * $this->scale), round($y * $this->scale));
     return $image;
 }
Ejemplo n.º 3
0
 /**
  * Apply the transformation to the image and returns the image thumbnail
  */
 protected function transform(sfImage $image)
 {
     $resource_w = $image->getWidth();
     $resource_h = $image->getHeight();
     $scale_w = $this->getWidth() / $resource_w;
     $scale_h = $this->getHeight() / $resource_h;
     $method = $this->getMethod();
     switch ($method) {
         case 'deflate':
         case 'inflate':
             return $image->resize($this->getWidth(), $this->getHeight());
         case 'left':
         case 'right':
         case 'top':
         case 'bottom':
         case 'top-left':
         case 'top-right':
         case 'bottom-left':
         case 'bottom-right':
         case 'center':
             $image->scale(max($scale_w, $scale_h));
             if (false !== strstr($method, 'top')) {
                 $top = 0;
             } else {
                 if (false !== strstr($method, 'bottom')) {
                     $top = $image->getHeight() - $this->getHeight();
                 } else {
                     $top = (int) round(($image->getHeight() - $this->getHeight()) / 2);
                 }
             }
             if (false !== strstr($method, 'left')) {
                 $left = 0;
             } else {
                 if (false !== strstr($method, 'right')) {
                     $left = $image->getWidth() - $this->getWidth();
                 } else {
                     $left = (int) round(($image->getWidth() - $this->getWidth()) / 2);
                 }
             }
             return $image->crop($left, $top, $this->getWidth(), $this->getHeight());
         case 'scale':
             return $image->scale(min($scale_w, $scale_h));
         case 'fit':
         default:
             $img = clone $image;
             $image->create($this->getWidth(), $this->getHeight());
             // Set a background color if specified
             if (!is_null($this->getBackground()) && $this->getBackground() != '') {
                 $image->fill(0, 0, $this->getBackground());
             }
             $img->scale(min($this->getWidth() / $img->getWidth(), $this->getHeight() / $img->getHeight()));
             $image->overlay($img, 'center');
             return $image;
     }
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $image->resize($this->getWidth(), $this->getHeight());
     $resource->roundCorners($this->getRadius(), $this->getRadius());
     $shadow = $resource->clone();
     $shadow->setImageBackgroundColor(new ImagickPixel('black'));
     $shadow->shadowImage(80, 3, 5, 5);
     $shadow->compositeImage($resource, Imagick::COMPOSITE_OVER, 0, 0);
     return $image;
 }