cvs: pear /Image_Transform Transform.php
| From: | Philippe Jausions | Date: | Tue, 07 Mar 2006 21:26:05 +0000 |
| Subject: | cvs: pear /Image_Transform Transform.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-38965@lists.php.net to get a copy of this message | ||
jausions Tue Mar 7 21:26:05 2006 UTC
Modified files:
/pear/Image_Transform Transform.php
Log:
Added 2 new methods fitX() and fitY() to fit an image within the given width or height
(respectively). Per request # 6004.
http://cvs.php.net/viewcvs.cgi/pear/Image_Transform/Transform.php?r1=1.36&r2=1.37&diff_format=u
Index: pear/Image_Transform/Transform.php
diff -u pear/Image_Transform/Transform.php:1.36 pear/Image_Transform/Transform.php:1.37
--- pear/Image_Transform/Transform.php:1.36 Tue Mar 7 21:09:05 2006
+++ pear/Image_Transform/Transform.php Tue Mar 7 21:26:05 2006
@@ -22,7 +22,7 @@
* @author Philippe Jausions <Philippe.Jausions@11abacus.com>
* @copyright 2002-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: Transform.php,v 1.36 2006/03/07 21:09:05 jausions Exp $
+ * @version CVS: $Id: Transform.php,v 1.37 2006/03/07 21:26:05 jausions Exp $
* @link http://pear.php.net/package/Image_Transform
*/
@@ -416,6 +416,8 @@
* it will be scaled down to fit inside of it.
* If the image is smaller, nothing is done.
*
+ * @param integer $width
+ * @param integer $height
* @return bool|PEAR_Error TRUE or PEAR_Error object on error
* @access public
*/
@@ -437,6 +439,38 @@
}
/**
+ * Fits the image in the specified width
+ *
+ * If the image is wider than the width specified by $width,
+ * it will be scaled down to fit inside of it.
+ * If the image is smaller, nothing is done.
+ *
+ * @param integer $width
+ * @return bool|PEAR_Error TRUE or PEAR_Error object on error
+ * @access public
+ */
+ function fitX($width)
+ {
+ return ($this->img_x <= $width) ? true : $this->scaleByX($width);
+ }
+
+ /**
+ * Fits the image in the specified height
+ *
+ * If the image is taller than the height specified by $height,
+ * it will be scaled down to fit inside of it.
+ * If the image is smaller, nothing is done.
+ *
+ * @param integer $height
+ * @return bool|PEAR_Error TRUE or PEAR_Error object on error
+ * @access public
+ */
+ function fitY($height)
+ {
+ return ($this->img_y <= $height) ? true : $this->scaleByY($height);
+ }
+
+ /**
* Sets one options
*
* @param string Name of option