Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.9.5

Request #19329 fitOnCanvas for imagick3 & GD
Submitted: 2012-03-12 15:12 UTC
From: gamesh Assigned:
Status: Open Package: Image_Transform (version 0.9.4)
PHP Version: 5.3.6 OS: Ubuntu
Roadmaps: (Not assigned)    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 29 + 31 = ?

 
 [2012-03-12 15:12 UTC] gamesh (Justinas Urbanavicius)
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; }

Comments

 [2012-04-01 18:57 UTC] doconnor (Daniel O'Connor)
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
 [2012-04-02 12:16 UTC] gamesh (Justinas Urbanavicius)
 [2012-04-02 12:17 UTC] gamesh (Justinas Urbanavicius)
-Summary: fitOnCanvas for imagick3 +Summary: fitOnCanvas for imagick3 & GD
 [2012-04-02 12:21 UTC] gamesh (Justinas Urbanavicius)
added code snippet for GD also. but can't write Unit tests sorry :)