protected function createMask(sfImage $image, $w, $h)
 {
     // Create a mask png image of the area you want in the circle/ellipse (a 'magicpink' image with a black shape on it, with black set to the colour of alpha transparency) - $mask
     $mask = $image->getAdapter()->getTransparentImage($w, $h);
     // Set the masking colours
     if (false === $this->getColor() || 'image/png' == $image->getMIMEType()) {
         $mask_black = imagecolorallocate($mask, 0, 0, 0);
     } else {
         $mask_black = $image->getAdapter()->getColorByHex($mask, $this->getColor());
     }
     // Cannot use white as transparent mask if color is set to white
     if ($this->getColor() === '#FFFFFF' || $this->getColor() === false) {
         $mask_transparent = imagecolorallocate($mask, 255, 0, 0);
     } else {
         $mask_color = imagecolorsforindex($mask, imagecolorat($image->getAdapter()->getHolder(), 0, 0));
         $mask_transparent = imagecolorallocate($mask, $mask_color['red'], $mask_color['green'], $mask_color['blue']);
     }
     imagecolortransparent($mask, $mask_transparent);
     imagefill($mask, 0, 0, $mask_black);
     // Draw the rounded rectangle for the mask
     $this->imagefillroundedrect($mask, 0, 0, $w, $h, $this->getRadius(), $mask_transparent);
     $mask_image = clone $image;
     $mask_image->getAdapter()->setHolder($mask);
     return $mask_image;
 }
 /**
  * Apply the opacity transformation to the sfImage object
  * 
  * @param sfImage
  * 
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $new_img = $image->getAdapter()->getTransparentImage($image->getWidth(), $image->getHeight());
     imagealphablending($new_img, false);
     imagesavealpha($new_img, true);
     $opacity = (int) round(127 - 127 / 100 * $this->getOpacity());
     // imagesavealpha($new_img, true);
     $width = $image->getWidth();
     $height = $image->getHeight();
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             $rgb = imagecolorat($image->getAdapter()->getHolder(), $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $alpha = ($rgb & 0x7f000000) >> 24;
             $new_opacity = $alpha + (127 - $alpha) / 100 * $this->getOpacity();
             $colors[$alpha] = $new_opacity;
             $color = imagecolorallocatealpha($new_img, $r, $g, $b, $new_opacity);
             imagesetpixel($new_img, $x, $y, $color);
         }
     }
     $image->getAdapter()->setHolder($new_img);
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 public function execute(sfImage $image)
 {
     // Check we have a valid image holder
     if (false === $image->getAdapter()->hasHolder()) {
         print $image->getAdapter()->hasHolder();
         print_r($image->getAdapter());
         exit;
         throw new sfImageTransformException(sprintf('Cannot perform transform: %s invalid image resource', get_class($this)));
     }
     return $this->transform($image);
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     // Set the defined color as transparent
     if ($this->color !== '') {
         $color = $image->getAdapter()->getColorByHex($resource, $this->color);
     } else {
         $color = imagecolorat($resource, 0, 0);
     }
     imagecolortransparent($resource, $color);
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param integer
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $x = imagesx($resource);
     $y = imagesy($resource);
     $dest_resource = $image->getAdapter()->getTransparentImage($x, $y);
     for ($h = 0; $h < $y; $h++) {
         imagecopy($dest_resource, $resource, 0, $h, 0, $y - $h - 1, $x, 1);
     }
     // Tidy up
     imagedestroy($resource);
     // Replace old image with flipped version
     $image->getAdapter()->setHolder($dest_resource);
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $resourcex = imagesx($resource);
     $resourcey = imagesy($resource);
     for ($x = 0; $x < $resourcex; ++$x) {
         for ($y = 0; $y < $resourcey; ++$y) {
             $distx = rand(-$this->scatter_factor, $this->scatter_factor);
             $disty = rand(-$this->scatter_factor, $this->scatter_factor);
             // keep inside the image boundaries
             if ($x + $distx >= $resourcex) {
                 continue;
             }
             if ($x + $distx < 0) {
                 continue;
             }
             if ($y + $disty >= $resourcey) {
                 continue;
             }
             if ($y + $disty < 0) {
                 continue;
             }
             $oldcol = imagecolorat($resource, $x, $y);
             $newcol = imagecolorat($resource, $x + $distx, $y + $disty);
             imagesetpixel($resource, $x, $y, $newcol);
             imagesetpixel($resource, $x + $distx, $y + $disty, $oldcol);
         }
     }
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param integer
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     // Check we have a valid image resource
     $resource = $image->getAdapter()->getHolder();
     $resource->flopImage();
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param integer
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $x = imagesx($resource);
     $y = imagesy($resource);
     imagealphablending($resource, true);
     $dest_resource = $image->getAdapter()->getTransparentImage($x, $y);
     imagealphablending($dest_resource, true);
     for ($w = 0; $w < $x; $w++) {
         imagecopy($dest_resource, $resource, $w, 0, $x - $w - 1, 0, 1, $y);
     }
     // Tidy up
     imagedestroy($resource);
     // Replace old image with flipped version
     $image->getAdapter()->setHolder($dest_resource);
     return $image;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     if (function_exists('imagefilter')) {
         imagefilter($resource, IMG_FILTER_NEGATE);
     } else {
         throw new sfImageTransformException(sprintf('Cannot perform transform, GD does not support imagefilter '));
     }
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $resourcex = imagesx($resource);
     $resourcey = imagesy($resource);
     for ($x = 0; $x < $resourcex; $x += $this->block_size) {
         for ($y = 0; $y < $resourcey; $y += $this->block_size) {
             $rgb = imagecolorat($resource, $x, $y);
             imagefilledrectangle($resource, $x, $y, $x + $this->block_size - 1, $y + $this->block_size - 1, $rgb);
         }
     }
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     // No need to do anything
     if ($this->angle == 0) {
         return $image;
     }
     $resource = $image->getAdapter()->getHolder();
     // By default use the background of the top left corner
     if ($this->background === '') {
         $this->background = $resource->getImagePixelColor(0, 0);
     }
     $resource->rotateImage($this->background, $this->angle);
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     // By default use the background of the top left corner
     if (is_null($this->background)) {
         $this->background = $resource->getImagePixelColor(0, 0);
         $background = $this->background;
     } else {
         $background = new ImagickPixel();
         $background->setColor($this->background);
     }
     $resource->setBackgroundColor($background);
     $resource->trimImage($this->fuzz);
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @access protected
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $resourcex = imagesx($resource);
     $resourcey = imagesy($resource);
     for ($x = 0; $x < $resourcex; ++$x) {
         for ($y = 0; $y < $resourcey; ++$y) {
             $newr = 0;
             $newg = 0;
             $newb = 0;
             $colours = array();
             $thiscol = imagecolorat($resource, $x, $y);
             for ($k = $x - $this->blur_pixels; $k <= $x + $this->blur_pixels; ++$k) {
                 for ($l = $y - $this->blur_pixels; $l <= $y + $this->blur_pixels; ++$l) {
                     if ($k < 0) {
                         $colours[] = $thiscol;
                         continue;
                     }
                     if ($k >= $resourcex) {
                         $colours[] = $thiscol;
                         continue;
                     }
                     if ($l < 0) {
                         $colours[] = $thiscol;
                         continue;
                     }
                     if ($l >= $resourcey) {
                         $colours[] = $thiscol;
                         continue;
                     }
                     $colours[] = imagecolorat($resource, $k, $l);
                 }
             }
             foreach ($colours as $colour) {
                 $newr += $colour >> 16 & 0xff;
                 $newg += $colour >> 8 & 0xff;
                 $newb += $colour & 0xff;
             }
             $numelements = count($colours);
             $newr /= $numelements;
             $newg /= $numelements;
             $newb /= $numelements;
             $newcol = imagecolorallocate($resource, $newr, $newg, $newb);
             imagesetpixel($resource, $x, $y, $newcol);
         }
     }
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $resourcex = imagesx($resource);
     $resourcey = imagesy($resource);
     for ($x = 0; $x < $resourcex; ++$x) {
         for ($y = 0; $y < $resourcey; ++$y) {
             $rgb = imagecolorat($resource, $x, $y);
             $red = $rgb >> 16 & 0xff;
             $green = $rgb >> 8 & 0xff;
             $blue = $rgb & 0xff;
             $red = (int) (($red + $green + $blue) / 3);
             $modifier = rand(-$this->density, $this->density);
             $red += $modifier;
             $green += $modifier;
             $blue += $modifier;
             // Max value is 255
             // Min value is 0
             if ($red > 255) {
                 $red = 255;
             }
             if ($green > 255) {
                 $green = 255;
             }
             if ($blue > 255) {
                 $blue = 255;
             }
             if ($red < 0) {
                 $red = 0;
             }
             if ($green < 0) {
                 $green = 0;
             }
             if ($blue < 0) {
                 $blue = 0;
             }
             $newcol = imagecolorallocate($resource, $red, $green, $blue);
             imagesetpixel($resource, $x, $y, $newcol);
         }
     }
     return $image;
 }
 /**
  * Computes the offset of the overlayed image
  * and sets the top and left coordinates based on the named position
  *
  * @param sfImage $image canvas image
  *
  * @return void
  */
 protected function computeCoordinates(sfImage $image)
 {
     $position = $this->getPosition();
     // no named position nothing to compute
     if (is_null($position)) {
         return;
     }
     $resource = $image->getAdapter()->getHolder();
     $resource_x = $resource->getImageWidth();
     $resource_y = $resource->getImageHeight();
     $overlay = $this->getOverlay()->getAdapter()->getHolder();
     $overlay_x = $overlay->getImageWidth();
     $overlay_y = $overlay->getImageHeight();
     switch ($position) {
         case 'top':
         case 'top-left':
             $this->setLeft(0);
             $this->setTop(0);
             break;
         case 'bottom':
         case 'bottom-left':
             $this->setLeft(0);
             $this->setTop($resource_y - $overlay_y);
             break;
         case 'left':
             $this->setLeft(0);
             $this->setTop(round(($resource_y - $overlay_y) / 2));
             break;
         case 'right':
             $this->setLeft(round($resource_x - $overlay_x));
             $this->setTop(round(($resource_y - $overlay_y) / 2));
             break;
         case 'top-right':
             $this->setLeft($resource_x - $overlay_x);
             $this->setTop(0);
             break;
         case 'bottom-right':
             $this->setLeft($resource_x - $overlay_x);
             $this->setTop($resource_y - $overlay_y);
             break;
         case 'bottom-center':
             $this->setLeft(round(($resource_x - $overlay_x) / 2));
             $this->setTop(round($resource_y - $overlay_y));
             break;
         case 'center':
         case 'middle-center':
             $this->setLeft(round(($resource_x - $overlay_x) / 2));
             $this->setTop(round(($resource_y - $overlay_y) / 2));
             break;
         case 'middle-left':
             $this->setLeft(0);
             $this->setTop(round(($resource_y - $overlay_y) / 2));
             break;
         case 'middle-right':
             $this->setLeft(round($resource_x - $overlay_x));
             $this->setTop(round(($resource_y - $overlay_y) / 2));
             break;
         case 'bottom-left':
         default:
             $this->setLeft(0);
             $this->setTop($resource_y - $overlay_y);
             break;
     }
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     if (is_object($this->fill)) {
         imagesettile($resource, $this->fill->getAdapter()->getHolder());
         imagefill($resource, $this->x, $this->y, IMG_COLOR_TILED);
     } else {
         imagefill($resource, $this->x, $this->y, $image->getAdapter()->getColorByHex($resource, $this->fill));
     }
     return $image;
 }
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $resource->normalizeImage();
     $resource->unsharpMaskImage($this->getRadius(), $this->getSigma(), $this->getAmount(), $this->getThreshold());
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @access protected
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $draw = new ImagickDraw();
     $draw->setFont($this->font_dir . '/' . $this->font . '.ttf');
     $draw->setFontSize($this->size);
     $resource->annotateImage($draw, $this->x, $this->y, $this->angle, $this->text);
     // old GD code
     /*
     $this->font = $this->font_dir . '/' . $this->font . '.ttf';
     
     $box = imageTTFBbox($this->size, $this->angle, $this->font, $this->text);
     
     $textwidth = abs($box[4] - $box[0]) - 4;
     $textheight = abs($box[5] - $box[1]) - 4;
         
     $rgb = sscanf($this->color, '#%2x%2x%2x');
     
     $color = imagecolorallocate($resource, $rgb[0], $rgb[1], $rgb[2]);
     
     imagettftext($resource, $this->size, $this->angle, $this->x, $this->y + $textheight, $color, $this->font, $this->text);
     */
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $fill = new ImagickPixel();
     $fill->setColor($this->fill);
     /*
      *  colorFloodfillImage has been depricated, use new method is available
      */
     if (method_exists($resource, 'floodFillPaintImage') && is_null($this->border)) {
         $target = $resource->getImagePixelColor($this->getX(), $this->getY());
         $resource->floodFillPaintImage($fill, $this->getFuzz(), $target, $this->getX(), $this->getY(), false);
     } else {
         $border = new ImagickPixel();
         $border->setColor($this->border);
         $resource->colorFloodfillImage($fill, $this->getFuzz(), $border, $this->getX(), $this->getY());
     }
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @access protected
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     // Use GD's built in filter
     if (function_exists('imagefilter')) {
         // we have to check for the php version as alpha support was added to imagefilter/IMG_FILTER_COLORIZE in 5.2.5
         if (strnatcmp(phpversion(), '5.2.5') >= 0) {
             imagefilter($resource, IMG_FILTER_COLORIZE, $this->red_tint, $this->green_tint, $this->blue_tint, $this->alpha);
         } else {
             imagefilter($resource, IMG_FILTER_COLORIZE, $this->red_tint, $this->green_tint, $this->blue_tint);
         }
     } else {
         $resourcex = imagesx($resource);
         $resourcey = imagesy($resource);
         for ($x = 0; $x < $resourcex; ++$x) {
             for ($y = 0; $y < $resourcey; ++$y) {
                 $rgb = imagecolorat($resource, $x, $y);
                 $red = $rgb >> 16 & 0xff;
                 $green = $rgb >> 8 & 0xff;
                 $blue = $rgb & 0xff;
                 $red = (int) (($red + $green + $blue) / 3);
                 $green = $red + $this->green_tint;
                 $blue = $red + $this->blue_tint;
                 $red += $this->red_tint;
                 // Max value is 255
                 // Min value is 0
                 if ($red > 255) {
                     $red = 255;
                 }
                 if ($green > 255) {
                     $green = 255;
                 }
                 if ($blue > 255) {
                     $blue = 255;
                 }
                 if ($red < 0) {
                     $red = 0;
                 }
                 if ($green < 0) {
                     $green = 0;
                 }
                 if ($blue < 0) {
                     $blue = 0;
                 }
                 $newcol = imagecolorallocate($resource, $red, $green, $blue);
                 imagesetpixel($resource, $x, $y, $newcol);
             }
         }
     }
     return $image;
 }
 /**
  * Apply the opacity transformation to the sfImage object
  * 
  * @param sfImage
  * 
  * @return sfImage
  */
 public function transform(sfImage $image)
 {
     // Get the actual image resource
     $resource = $image->getAdapter()->getHolder();
     //get the resource dimentions
     $width = $image->getWidth();
     $height = $image->getHeight();
     $reflection = $image->copy();
     $reflection->flip()->resize($width, $this->reflection_height);
     $r_resource = $reflection->getAdapter()->getHolder();
     $dest_resource = $reflection->getAdapter()->getTransparentImage($width, $height + $this->reflection_height);
     imagecopymerge($dest_resource, $resource, 0, 0, 0, 0, $width, $height, 100);
     imagecopymerge($dest_resource, $r_resource, 0, $height, 0, 0, $width, $this->reflection_height, 100);
     // Increments we are going to increase the transparency
     $increment = 100 / $this->reflection_height;
     // Overlay line we use to apply the transparency
     $line = imagecreatetruecolor($width, 1);
     // Use white as our overlay color
     imagefilledrectangle($line, 0, 0, $width, 1, imagecolorallocate($line, 255, 255, 255));
     $tr = $this->start_transparency;
     // Start at the bottom of the original image
     for ($i = $height; $i <= $height + $this->reflection_height; $i++) {
         if ($tr > 100) {
             $tr = 100;
         }
         imagecopymerge($dest_resource, $line, 0, $i, 0, 0, $width, 1, $tr);
         $tr += $increment;
     }
     // To set a new resource for the image object
     $image->getAdapter()->setHolder($dest_resource);
     return $image;
 }
 /**
  * Computes the offset of the overlayed image and sets
  * the top and left coordinates based on the named position
  *
  * @param sfImage $image canvas image
  *
  * @return boolean
  */
 public function computeCoordinates(sfImage $image)
 {
     $position = $this->getPosition();
     if (is_null($position)) {
         return false;
     }
     $resource = $image->getAdapter()->getHolder();
     $resource_x = ImageSX($resource);
     $resource_y = ImageSY($resource);
     $overlay = $this->getOverlay()->getAdapter()->getHolder();
     $overlay_x = ImageSX($overlay);
     $overlay_y = ImageSY($overlay);
     switch (strtolower($position)) {
         case 'top':
         case 'top-left':
             $this->setLeft(0);
             $this->setTop(0);
             break;
         case 'bottom':
         case 'bottom-left':
             $this->setLeft(0);
             $this->setTop($resource_y - $overlay_y);
             break;
         case 'left':
             $this->setLeft(0);
             $this->setTop(round(($resource_y - $overlay_y) / 2));
             break;
         case 'right':
             $this->setLeft(round($resource_x - $overlay_x));
             $this->setTop(round(($resource_y - $overlay_y) / 2));
             break;
         case 'top-right':
             $this->setLeft($resource_x - $overlay_x);
             $this->setTop(0);
             break;
         case 'bottom-right':
             $this->setLeft($resource_x - $overlay_x);
             $this->setTop($resource_y - $overlay_y);
             break;
         case 'bottom-center':
             $this->setLeft(round(($resource_x - $overlay_x) / 2));
             $this->setTop(round($resource_y - $overlay_y));
             break;
         case 'center':
         case 'middle-center':
             $this->setLeft(round(($resource_x - $overlay_x) / 2));
             $this->setTop(round(($resource_y - $overlay_y) / 2));
             break;
         case 'middle-left':
             $this->setLeft(0);
             $this->setTop(round(($resource_y - $overlay_y) / 2));
             break;
         case 'middle-right':
             $this->setLeft(round($resource_x - $overlay_x));
             $this->setTop(round(($resource_y - $overlay_y) / 2));
             break;
         case 'bottom-left':
         default:
             $this->setLeft(0);
             $this->setTop($resource_y - $overlay_y);
             break;
     }
     return true;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     // No need to do anything
     if ($this->angle == 0) {
         return $image;
     }
     $resource = $image->getAdapter()->getHolder();
     // By default use the background of the top left corner
     if ($this->background === '') {
         $this->background = ImageColorAt($resource, 0, 0);
     } else {
         $this->background = $image->getAdapter()->getColorByHex($resource, $this->background);
     }
     // Easy
     if (function_exists("imagerotate")) {
         $image->getAdapter()->setHolder(imagerotate($resource, $this->angle, $this->background));
         // manual rotating based base on pilot at myupb dot com @ php.net
     } else {
         throw new sfImageTransformException(sprintf('Cannot perform transform: %s. Your install of GD does not support imagerotate', get_class($this)));
         // TODO: FIX ME!!
         $srcw = imagesx($resource);
         $srch = imagesy($resource);
         // Convert the angle to radians
         $pi = 3.141592654;
         $theta = $this->angle * $pi / 180;
         // Get the origin (center) of the image
         $originx = $srcw / 2;
         $originy = $srch / 2;
         // The pixels array for the new image
         $pixels = array();
         $minx = 0;
         $maxx = 0;
         $miny = 0;
         $maxy = 0;
         $dstw = 0;
         $dsth = 0;
         // Loop through every pixel and transform it
         for ($x = 0; $x < $srcw; $x++) {
             for ($y = 0; $y < $srch; $y++) {
                 list($x1, $y1) = $this->translateCoordinate($originx, $originy, $x, $y, false);
                 $x2 = $x * cos($theta) - $y * sin($theta);
                 $y2 = $x * sin($theta) + $y * cos($theta);
                 // Store the pixel color
                 $pixels[] = array($x2, $y2, imagecolorat($resource, $x, $y));
                 // Check our boundaries
                 if ($x2 > $maxx) {
                     $maxx = $x2;
                 }
                 if ($x2 < $minx) {
                     $minx = $x2;
                 }
                 if ($y2 > $maxy) {
                     $maxy = $y2;
                 }
                 if ($y2 < $miny) {
                     $miny = $y2;
                 }
             }
         }
         // Determine the new image size
         $dstw = $maxx - $minx + 1;
         $dsth = $maxy - $miny + 1;
         // Create our new image
         $dstImg = $image->getAdapter()->getTransparentImage($dstw, $dsth);
         // Get the new origin
         $neworiginx = -$minx;
         $neworiginy = -$miny;
         // Fill in the pixels
         foreach ($pixels as $data) {
             list($x, $y, $color) = $data;
             list($newx, $newy) = $this->translateCoordinate($neworiginx, $neworiginy, $x, $y);
             imagesetpixel($dstImg, (int) $newx, (int) $newy, $color);
         }
         unset($resource);
         $image->getAdapter()->setHolder($dstImg);
     }
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param integer
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $resource->flipImage();
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @access protected
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     $resource->modulateImage($this->getBrightness(), 100, 100);
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     imagegammacorrect($resource, $this->input_gamma, $this->output_gamma);
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @access protected
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     // Use GD's built in filter
     if (function_exists('imagefilter')) {
         imagefilter($resource, IMG_FILTER_COLORIZE, $this->red_tint, $this->green_tint, $this->blue_tint, $this->alpha);
         // Else do filter in code
         // Alpha not supported
     } else {
         $resourcex = imagesx($resource);
         $resourcey = imagesy($resource);
         for ($x = 0; $x < $resourcex; ++$x) {
             for ($y = 0; $y < $resourcey; ++$y) {
                 $rgb = imagecolorat($resource, $x, $y);
                 $red = $rgb >> 16 & 0xff;
                 $green = $rgb >> 8 & 0xff;
                 $blue = $rgb & 0xff;
                 $red = (int) (($red + $green + $blue) / 3);
                 $green = $red + $this->green_tint;
                 $blue = $red + $this->blue_tint;
                 $red += $this->red_tint;
                 // Max value is 255
                 // Min value is 0
                 if ($red > 255) {
                     $red = 255;
                 }
                 if ($green > 255) {
                     $green = 255;
                 }
                 if ($blue > 255) {
                     $blue = 255;
                 }
                 if ($red < 0) {
                     $red = 0;
                 }
                 if ($green < 0) {
                     $green = 0;
                 }
                 if ($blue < 0) {
                     $blue = 0;
                 }
                 $newcol = imagecolorallocate($resource, $red, $green, $blue);
                 imagesetpixel($resource, $x, $y, $newcol);
             }
         }
     }
     return $image;
 }
 /**
  * Apply the transform to the sfImage object.
  *
  * @param sfImage
  * @return sfImage
  */
 protected function transform(sfImage $image)
 {
     $resource = $image->getAdapter()->getHolder();
     imagesetthickness($resource, $this->thickness);
     if (!is_null($this->fill)) {
         if (!is_object($this->fill)) {
             imagefilledellipse($resource, $this->x, $this->y, $this->width, $this->height, $image->getAdapter()->getColorByHex($resource, $this->fill));
         }
         if (is_object($this->fill)) {
             imagefilledellipse($resource, $this->x, $this->y, $this->width, $this->height, $image->getAdapter()->getColorByHex($resource, $this->color));
             $image->fill($this->x, $this->y, $this->fill);
         }
         if ($this->color !== "" && $this->fill !== $this->color) {
             imageellipse($resource, $this->x, $this->y, $this->width, $this->height, $image->getAdapter()->getColorByHex($resource, $this->color));
         }
     } else {
         imageellipse($resource, $this->x, $this->y, $this->width, $this->height, $image->getAdapter()->getColorByHex($resource, $this->color));
     }
     return $image;
 }