Horde_Image_Imagick::frameImage PHP Méthode

frameImage() public static méthode

Use when you don't want to replace all pixels in the clipping area with the border color i.e. you want to "frame" the existing image. Preserves transparency etc.
public static frameImage ( &$image, string $color, integer $width, integer $height )
$color string The border color.
$width integer The image width including the border.
$height integer The image height including the border.
    public static function frameImage(&$image, $color, $width, $height)
    {
        // Need to jump through these hoops in order to preserve any
        // transparency.
        // @TODO Imagick::clone is deprecated as of 3.1.0. For H6 use the clone
        // keyword instead.
        try {
            $border = $image->clone();
            $border->borderImage(new ImagickPixel($color), $width, $height);
            $border->compositeImage($image, Imagick::COMPOSITE_COPY, $width, $height);
            $image->clear();
            $image->addImage($border);
        } catch (ImagickPixelException $e) {
            throw new Horde_Image_Exception($e);
        } catch (ImagickException $e) {
            throw new Horde_Image_Exception($e);
        }
        $border->destroy();
    }

Usage Example

Exemple #1
0
 /**
  * Draw the border.
  *
  * This draws the configured border to the provided image. Beware,
  * that every pixel inside the border clipping will be overwritten
  * with the background color.
  */
 public function apply()
 {
     if ($this->_params['preserve']) {
         Horde_Image_Imagick::frameImage($this->_image->imagick, $this->_params['bordercolor'], $this->_params['borderwidth'], $this->_params['borderwidth']);
     } else {
         $this->_image->imagick->borderImage(new ImagickPixel($this->_params['bordercolor']), $this->_params['borderwidth'], $this->_params['borderwidth']);
     }
     return true;
 }
All Usage Examples Of Horde_Image_Imagick::frameImage