Req #19329 [Opn]: fitOnCanvas for imagick3
| From: | daniel dot oconnor at gmail dot com | Date: | Sun, 01 Apr 2012 13:57:21 +0000 |
| Subject: | Req #19329 [Opn]: fitOnCanvas for imagick3 | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-8486@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=19329&edit=1
ID: 19329
Updated by: daniel.oconnor@gmail.com
Reported By: justinasu at gmail dot com
Summary: fitOnCanvas for imagick3
Status: Open
Type: Feature/Change Request
Package: Image_Transform
Operating System: Ubuntu
Package Version: 0.9.4
PHP Version: 5.3.6
Roadmap Versions:
New Comment:
Hi, thanks for the snippet - but is there any chance I can ask you to do
this as a diff
against svn?
$ svn co
http://svn.php.net/repository/pear/packages/Image_Transform/trunk/
# Add your changes
$ svn diff > myfeature.diff.txt
+ any unit test coverage if applicable
Previous Comments:
------------------------------------------------------------------------
[2012-03-12 11:12:58] gamesh
Description:
------------
i wrote fitOnCanvas for imagick3, feel free to add this:
/**
* @param integer $width
* @param integer $height
* @param string $position
* @param string $backgroundColor
* @return boolean
*/
public function fitOnCanvas($width, $height, $position = 'center',
$backgroundColor = 'white')
{
$this->fit($width, $height);
$canvas = new Imagick();
$canvas->newImage($width, $height, new ImagickPixel($backgroundColor),
$this->imagick->getFormat());
switch ($position) {
case 'center':
default:
$x = ($width - $this->getNewImageWidth()) / 2;
$y = ($height - $this->getNewImageHeight()) / 2;
break;
}
$x = round($x);
$y = round($y);
$result = $canvas->compositeImage($this->imagick,
imagick::COMPOSITE_OVER, $x, $y);
$this->new_x = $canvas->getImageWidth();
$this->new_y = $canvas->getImageHeight();
$this->imagick->setimage($canvas);
return $result;
}
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19329&edit=1