/usr/share/php/Horde/Image/Effect/Imagick/RoundCorners.php is in php-horde-image 2.1.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <?php
/**
* Image effect for rounding image corners.
*
* Copyright 2007-2014 Horde LLC (http://www.horde.org/)
*
* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Image
*/
class Horde_Image_Effect_Imagick_RoundCorners extends Horde_Image_Effect
{
/**
* Valid parameters:
*
* radius - Radius of rounded corners.
*
* @var array
*/
protected $_params = array('radius' => 10,
'background' => 'none',
'border' => 0,
'bordercolor' => 'none');
public function apply()
{
if (!method_exists($this->_image->imagick, 'roundCorners')) {
throw new Horde_Image_Exception('Your version of Imagick is not compiled against a recent enough ImageMagick library (> 6.2.8) to use the RoundCorners effect.');
}
$round = $this->_params['radius'];
$result = $this->_image->imagick->roundCorners($round, $round);
// Using a border?
if ($this->_params['bordercolor'] != 'none' &&
$this->_params['border'] > 0) {
$size = $this->_image->getDimensions();
$new = new Imagick();
$new->newImage($size['width'] + $this->_params['border'],
$size['height'] + $this->_params['border'],
$this->_params['bordercolor']);
$new->setImageFormat($this->_image->getType());
$new->roundCorners($round, $round);
$new->compositeImage($this->_image->imagick, Imagick::COMPOSITE_OVER, 1, 1);
$this->_image->imagick->clear();
$this->_image->imagick->addImage($new);
$new->destroy();
}
// If we have a background other than 'none' we need to
// compose two images together to make sure we *have* a background. We
// can't use border because we don't want to extend the image area, just
// fill in the parts removed by the rounding.
if ($this->_params['background'] != 'none') {
$size = $this->_image->getDimensions();
$new = new Imagick();
$new->newImage($size['width'],
$size['height'],
$this->_params['background']);
$new->setImageFormat($this->_image->getType());
$new->compositeImage($this->_image->imagick, Imagick::COMPOSITE_OVER, 0, 0);
$this->_image->imagick->clear();
$this->_image->imagick->addImage($new);
$new->destroy();
}
// Reset width/height since these might have changed
$this->_image->clearGeometry();
return true;
}
}
|