[limb-svn] r6963 - in 3.x/trunk/limb/imagekit: src/exception src/gd src/gd/filters src/im/filters tests/cases/gd/filters tests/cases/im/filters
svn at limb-project.com
svn at limb-project.com
Mon Apr 28 08:04:31 MSD 2008
Author: svk
Date: 2008-04-28 08:04:31 +0400 (Mon, 28 Apr 2008)
New Revision: 6963
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6963
Added:
3.x/trunk/limb/imagekit/src/im/filters/lmbImCropImageFilter.class.php
3.x/trunk/limb/imagekit/tests/cases/im/filters/lmbImCropImageFilterTest.class.php
Modified:
3.x/trunk/limb/imagekit/src/exception/lmbImageCreateFailedException.class.php
3.x/trunk/limb/imagekit/src/exception/lmbImageLibraryNotInstalledException.class.php
3.x/trunk/limb/imagekit/src/exception/lmbImageSaveFailedException.class.php
3.x/trunk/limb/imagekit/src/exception/lmbImageTypeNotSupportedException.class.php
3.x/trunk/limb/imagekit/src/gd/filters/lmbGdCropImageFilter.class.php
3.x/trunk/limb/imagekit/src/gd/filters/lmbGdOutputImageFilter.class.php
3.x/trunk/limb/imagekit/src/gd/filters/lmbGdResizeImageFilter.class.php
3.x/trunk/limb/imagekit/src/gd/filters/lmbGdRotateImageFilter.class.php
3.x/trunk/limb/imagekit/src/gd/filters/lmbGdWaterMarkImageFilter.class.php
3.x/trunk/limb/imagekit/src/gd/lmbGdImageConvertor.class.php
3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdCropImageFilterTest.class.php
Log:
-- imagekit :: crop filter added for Imagick
-- php close tags removed
Modified: 3.x/trunk/limb/imagekit/src/exception/lmbImageCreateFailedException.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/exception/lmbImageCreateFailedException.class.php 2008-04-27 12:48:28 UTC (rev 6962)
+++ 3.x/trunk/limb/imagekit/src/exception/lmbImageCreateFailedException.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -22,4 +22,3 @@
}
}
-?>
Modified: 3.x/trunk/limb/imagekit/src/exception/lmbImageLibraryNotInstalledException.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/exception/lmbImageLibraryNotInstalledException.class.php 2008-04-27 12:48:28 UTC (rev 6962)
+++ 3.x/trunk/limb/imagekit/src/exception/lmbImageLibraryNotInstalledException.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -21,5 +21,4 @@
parent::__construct('Library not installed', array('file' => $lib_name));
}
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
Modified: 3.x/trunk/limb/imagekit/src/exception/lmbImageSaveFailedException.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/exception/lmbImageSaveFailedException.class.php 2008-04-27 12:48:28 UTC (rev 6962)
+++ 3.x/trunk/limb/imagekit/src/exception/lmbImageSaveFailedException.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -22,4 +22,3 @@
}
}
-?>
Modified: 3.x/trunk/limb/imagekit/src/exception/lmbImageTypeNotSupportedException.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/exception/lmbImageTypeNotSupportedException.class.php 2008-04-27 12:48:28 UTC (rev 6962)
+++ 3.x/trunk/limb/imagekit/src/exception/lmbImageTypeNotSupportedException.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -22,4 +22,3 @@
}
}
-?>
Modified: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdCropImageFilter.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdCropImageFilter.class.php 2008-04-27 12:48:28 UTC (rev 6962)
+++ 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdCropImageFilter.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -1,27 +1,27 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2008 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require(dirname(__FILE__).'/../../lmbAbstractImageFilter.class.php');
-
-/**
- * Crop image filter
- * @package imagekit
- * @version $Id$
- */
-class lmbGdCropImageFilter extends lmbAbstractImageFilter
-{
- function apply(lmbAbstractImageContainer $container)
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2008 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require(dirname(__FILE__).'/../../lmbAbstractImageFilter.class.php');
+
+/**
+ * Crop image filter
+ * @package imagekit
+ * @version $Id$
+ */
+class lmbGdCropImageFilter extends lmbAbstractImageFilter
+{
+ function apply(lmbAbstractImageContainer $container)
{
list($x, $y, $width, $height) = $this->calculateCropArea($container->getWidth(), $container->getHeight());
- $im = $container->isPallete() ? imagecreate($width, $height) : imagecreatetruecolor($width, $height);
- imagecopy($im, $container->getResource(), 0, 0, $x, $y, $width, $height);
- $container->replaceResource($im);
+ $im = $container->isPallete() ? imagecreate($width, $height) : imagecreatetruecolor($width, $height);
+ imagecopy($im, $container->getResource(), 0, 0, $x, $y, $width, $height);
+ $container->replaceResource($im);
}
function calculateCropArea($image_width, $image_height)
@@ -42,17 +42,17 @@
$height -= $y + $height - $image_height;
return array($x, $y, $width, $height);
- }
-
- function getWidth()
- {
- return $this->getParam('width');
- }
-
- function getHeight()
- {
- return $this->getParam('height');
}
+
+ function getWidth()
+ {
+ return $this->getParam('width');
+ }
+
+ function getHeight()
+ {
+ return $this->getParam('height');
+ }
function getX()
{
@@ -64,5 +64,4 @@
return $this->getParam('y', 0);
}
-}
-?>
+}
\ No newline at end of file
Modified: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdOutputImageFilter.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdOutputImageFilter.class.php 2008-04-27 12:48:28 UTC (rev 6962)
+++ 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdOutputImageFilter.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -27,4 +27,3 @@
}
}
-?>
\ No newline at end of file
Modified: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdResizeImageFilter.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdResizeImageFilter.class.php 2008-04-27 12:48:28 UTC (rev 6962)
+++ 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdResizeImageFilter.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -58,4 +58,3 @@
return $this->getParam('save_min_size', false);
}
}
-?>
Modified: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdRotateImageFilter.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdRotateImageFilter.class.php 2008-04-27 12:48:28 UTC (rev 6962)
+++ 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdRotateImageFilter.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -40,4 +40,3 @@
return $this->parseHexColor($bgcolor);
}
}
-?>
\ No newline at end of file
Modified: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdWaterMarkImageFilter.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdWaterMarkImageFilter.class.php 2008-04-27 12:48:28 UTC (rev 6962)
+++ 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdWaterMarkImageFilter.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -1,33 +1,33 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require(dirname(__FILE__).'/../../lmbAbstractImageFilter.class.php');
-
-/**
- * Resize image filter
- * @package imagekit
- * @version $Id$
- */
-class lmbGdWaterMarkImageFilter extends lmbAbstractImageFilter
-{
-
- function apply(lmbAbstractImageContainer $container)
- {
- $width = $container->getWidth();
- $height = $container->getHeight();
- $wm_cont = new lmbGdImageContainer();
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require(dirname(__FILE__).'/../../lmbAbstractImageFilter.class.php');
+
+/**
+ * Resize image filter
+ * @package imagekit
+ * @version $Id$
+ */
+class lmbGdWaterMarkImageFilter extends lmbAbstractImageFilter
+{
+
+ function apply(lmbAbstractImageContainer $container)
+ {
+ $width = $container->getWidth();
+ $height = $container->getHeight();
+ $wm_cont = new lmbGdImageContainer();
$wm_cont->load($this->getWaterMark());
$wm_width = $this->getXCenter() ? $wm_cont->getWidth() : false;
- $wm_height = $this->getYCenter() ? $wm_cont->getHeight() : false;
- list($x, $y) = $this->calcPosition($this->getX(), $this->getY(), $width, $height, $wm_width, $wm_height);
- imagecopymerge($container->getResource(), $wm_cont->getResource(), $x, $y, 0, 0, $wm_cont->getWidth(), $wm_cont->getHeight(), 100 - $this->getOpacity());
- }
+ $wm_height = $this->getYCenter() ? $wm_cont->getHeight() : false;
+ list($x, $y) = $this->calcPosition($this->getX(), $this->getY(), $width, $height, $wm_width, $wm_height);
+ imagecopymerge($container->getResource(), $wm_cont->getResource(), $x, $y, 0, 0, $wm_cont->getWidth(), $wm_cont->getHeight(), 100 - $this->getOpacity());
+ }
/**
* Calculate position of a watermark
@@ -39,8 +39,8 @@
* @param mixed $wm_width width of a watermark
* @param mixed $wm_height height of a watermark
* @return array (x, y)
- */
- function calcPosition($x, $y, $width, $height, $wm_width = false, $wm_height = false)
+ */
+ function calcPosition($x, $y, $width, $height, $wm_width = false, $wm_height = false)
{
if($wm_width !== false)
{
@@ -59,29 +59,29 @@
{
if($y < 0)
$y += $height;
- }
- return array($x, $y);
- }
-
- function getWaterMark()
- {
- return $this->getParam('water_mark');
- }
-
- function getX()
- {
- return $this->getParam('x', 0);
- }
-
- function getY()
- {
- return $this->getParam('y', 0);
- }
-
- function getOpacity()
- {
- return $this->getParam('opacity', 0);
+ }
+ return array($x, $y);
}
+
+ function getWaterMark()
+ {
+ return $this->getParam('water_mark');
+ }
+
+ function getX()
+ {
+ return $this->getParam('x', 0);
+ }
+
+ function getY()
+ {
+ return $this->getParam('y', 0);
+ }
+
+ function getOpacity()
+ {
+ return $this->getParam('opacity', 0);
+ }
function getXCenter()
{
@@ -92,5 +92,4 @@
{
return $this->getParam('ycenter', false);
}
-}
-?>
\ No newline at end of file
+}
Modified: 3.x/trunk/limb/imagekit/src/gd/lmbGdImageConvertor.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/lmbGdImageConvertor.class.php 2008-04-27 12:48:28 UTC (rev 6962)
+++ 3.x/trunk/limb/imagekit/src/gd/lmbGdImageConvertor.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -1,62 +1,61 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require(dirname(__FILE__).'/../lmbAbstractImageConvertor.class.php');
-lmb_require(dirname(__FILE__).'/lmbGdImageContainer.class.php');
-lmb_require('limb/fs/src/exception/lmbFileNotFoundException.class.php');
-lmb_require('limb/imagekit/src/exception/lmbImageLibraryNotInstalledException.class.php');
-
-/**
- * GD image convertor
- *
- * @package imagekit
- * @version $Id$
- */
-class lmbGdImageConvertor extends lmbAbstractImageConvertor
-{
-
- function __construct($params = array())
- {
- if (!function_exists('gd_info'))
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require(dirname(__FILE__).'/../lmbAbstractImageConvertor.class.php');
+lmb_require(dirname(__FILE__).'/lmbGdImageContainer.class.php');
+lmb_require('limb/fs/src/exception/lmbFileNotFoundException.class.php');
+lmb_require('limb/imagekit/src/exception/lmbImageLibraryNotInstalledException.class.php');
+
+/**
+ * GD image convertor
+ *
+ * @package imagekit
+ * @version $Id$
+ */
+class lmbGdImageConvertor extends lmbAbstractImageConvertor
+{
+
+ function __construct($params = array())
+ {
+ if (!function_exists('gd_info'))
throw new lmbImageLibraryNotInstalledException('gd');
if(!isset($params['filters_scan_dirs']))
$params['filters_scan_dirs'] = dirname(__FILE__).'/filters';
- parent::__construct($params);
- }
-
- protected function createFilter($name, $params)
- {
- $class = $this->loadFilter($name, 'Gd', $params);
- return new $class($params);
- }
-
- protected function createImageContainer($file_name, $type = '')
- {
- $container = new lmbGdImageContainer();
- $container->load($file_name, $type);
- return $container;
- }
-
- function isSupportConversion($file, $src_type = '', $dest_type = '')
- {
- if(!$src_type)
- {
- $imginfo = @getimagesize($file);
- if(!$imginfo)
- throw new lmbFileNotFoundException($file);
- $src_type = lmbGdImageContainer::convertImageType($imginfo[2]);
- }
- if(!$dest_type)
- $dest_type = $src_type;
- return lmbGdImageContainer::supportLoadType($src_type) &&
- lmbGdImageContainer::supportSaveType($dest_type);
- }
-}
-?>
+ parent::__construct($params);
+ }
+
+ protected function createFilter($name, $params)
+ {
+ $class = $this->loadFilter($name, 'Gd', $params);
+ return new $class($params);
+ }
+
+ protected function createImageContainer($file_name, $type = '')
+ {
+ $container = new lmbGdImageContainer();
+ $container->load($file_name, $type);
+ return $container;
+ }
+
+ function isSupportConversion($file, $src_type = '', $dest_type = '')
+ {
+ if(!$src_type)
+ {
+ $imginfo = @getimagesize($file);
+ if(!$imginfo)
+ throw new lmbFileNotFoundException($file);
+ $src_type = lmbGdImageContainer::convertImageType($imginfo[2]);
+ }
+ if(!$dest_type)
+ $dest_type = $src_type;
+ return lmbGdImageContainer::supportLoadType($src_type) &&
+ lmbGdImageContainer::supportSaveType($dest_type);
+ }
+}
Added: 3.x/trunk/limb/imagekit/src/im/filters/lmbImCropImageFilter.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/im/filters/lmbImCropImageFilter.class.php (rev 0)
+++ 3.x/trunk/limb/imagekit/src/im/filters/lmbImCropImageFilter.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -0,0 +1,65 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2008 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require(dirname(__FILE__).'/../../lmbAbstractImageFilter.class.php');
+
+/**
+ * Crop image filter
+ * @package imagekit
+ * @version $Id: $
+ */
+class lmbImCropImageFilter extends lmbAbstractImageFilter
+{
+ function apply(lmbAbstractImageContainer $container)
+ {
+ list($x, $y, $width, $height) = $this->calculateCropArea($container->getWidth(), $container->getHeight());
+ $container->getResource()->cropImage($width, $height, $x, $y);
+ }
+
+ function calculateCropArea($image_width, $image_height)
+ {
+ $width = $this->getWidth();
+ $height = $this->getHeight();
+ if($width === null)
+ $width = $image_width;
+ if($height === null)
+ $height = $image_height;
+
+ $x = $this->getX();
+ $y = $this->getY();
+
+ if($x + $width > $image_width)
+ $width -= $x + $width - $image_width;
+ if($y + $height > $image_height)
+ $height -= $y + $height - $image_height;
+
+ return array($x, $y, $width, $height);
+ }
+
+ function getWidth()
+ {
+ return $this->getParam('width');
+ }
+
+ function getHeight()
+ {
+ return $this->getParam('height');
+ }
+
+ function getX()
+ {
+ return $this->getParam('x', 0);
+ }
+
+ function getY()
+ {
+ return $this->getParam('y', 0);
+ }
+
+}
\ No newline at end of file
Modified: 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdCropImageFilterTest.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdCropImageFilterTest.class.php 2008-04-27 12:48:28 UTC (rev 6962)
+++ 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdCropImageFilterTest.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -1,22 +1,22 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/imagekit/src/gd/lmbGdImageContainer.class.php');
-lmb_require('limb/imagekit/src/gd/filters/lmbGdCropImageFilter.class.php');
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+lmb_require('limb/imagekit/src/gd/lmbGdImageContainer.class.php');
+lmb_require('limb/imagekit/src/gd/filters/lmbGdCropImageFilter.class.php');
+
/**
* @package imagekit
* @version $Id$
- */
-class lmbGdCropImageFilterTest extends UnitTestCase
-{
-
+ */
+class lmbGdCropImageFilterTest extends UnitTestCase
+{
+
function _getInputImage()
{
return dirname(__FILE__).'/../../../var/input.jpg';
@@ -27,11 +27,11 @@
return dirname(__FILE__).'/../../../var/water_mark.gif';
}
- function _getOutputImage()
- {
- return dirname(__FILE__).'/../../../var/output.jpg';
- }
-
+ function _getOutputImage()
+ {
+ return dirname(__FILE__).'/../../../var/output.jpg';
+ }
+
function _getContainer()
{
$cont = new lmbGdImageContainer();
@@ -113,19 +113,19 @@
$cont->load($this->_getOutputImage());
}
- function testParams()
- {
- $filter = new lmbGdCropImageFilter(array('width' => 90, 'height' => 100, 'x' => 10, 'y' => 20));
-
+ function testParams()
+ {
+ $filter = new lmbGdCropImageFilter(array('width' => 90, 'height' => 100, 'x' => 10, 'y' => 20));
+
$this->assertEqual($filter->getWidth(), 90);
$this->assertEqual($filter->getHeight(), 100);
$this->assertEqual($filter->getX(), 10);
$this->assertEqual($filter->getY(), 20);
- }
-
- function tearDown()
- {
- @unlink($this->_getOutputImage());
- }
-}
+ }
+
+ function tearDown()
+ {
+ @unlink($this->_getOutputImage());
+ }
+}
?>
\ No newline at end of file
Added: 3.x/trunk/limb/imagekit/tests/cases/im/filters/lmbImCropImageFilterTest.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/tests/cases/im/filters/lmbImCropImageFilterTest.class.php (rev 0)
+++ 3.x/trunk/limb/imagekit/tests/cases/im/filters/lmbImCropImageFilterTest.class.php 2008-04-28 04:04:31 UTC (rev 6963)
@@ -0,0 +1,131 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/imagekit/src/im/lmbImImageContainer.class.php');
+lmb_require('limb/imagekit/src/im/filters/lmbImCropImageFilter.class.php');
+
+/**
+ * @package imagekit
+ * @version $Id: $
+ */
+class lmbImCropImageFilterTest extends UnitTestCase
+{
+
+ function _getInputImage()
+ {
+ return dirname(__FILE__).'/../../../var/input.jpg';
+ }
+
+ function _getInputPalleteImage()
+ {
+ return dirname(__FILE__).'/../../../var/water_mark.gif';
+ }
+
+ function _getOutputImage()
+ {
+ return dirname(__FILE__).'/../../../var/output.jpg';
+ }
+
+ function _getContainer()
+ {
+ $cont = new lmbImImageContainer();
+ $cont->load($this->_getInputImage());
+ return $cont;
+ }
+
+ function _getPalleteContainer()
+ {
+ $cont = new lmbImImageContainer();
+ $cont->load($this->_getInputPalleteImage());
+ return $cont;
+ }
+
+ function testTrueColorCrop()
+ {
+ $cont = $this->_getContainer();
+ $filter = new lmbImCropImageFilter(array('width' => 50, 'height' => 70, 'x' => 10, 'y' => 20));
+
+ $filter->apply($cont);
+ $cont->save($this->_getOutputImage());
+ list($width, $height, $type) = getimagesize($this->_getOutputImage());
+ $this->assertEqual($width, 50);
+ $this->assertEqual($height, 70);
+ $cont->load($this->_getOutputImage());
+ $this->assertFalse($cont->isPallete());
+ }
+
+ function testPalleteCrop()
+ {
+ $cont = $this->_getPalleteContainer();
+ $filter = new lmbImCropImageFilter(array('width' => 5, 'height' => 10));
+
+ $filter->apply($cont);
+ $cont->save($this->_getOutputImage());
+ list($width, $height, $type) = getimagesize($this->_getOutputImage());
+ $this->assertEqual($width, 5);
+ $this->assertEqual($height, 10);
+ $cont->load($this->_getOutputImage());
+ $this->assertTrue($cont->isPallete());
+ }
+
+ function testMaxSizeRestriction()
+ {
+ $cont = $this->_getPalleteContainer();
+ $filter = new lmbImCropImageFilter(array('width' => 100, 'height' => 100));
+
+ $filter->apply($cont);
+ $cont->save($this->_getOutputImage());
+ list($width, $height, $type) = getimagesize($this->_getOutputImage());
+ $this->assertEqual($width, 14);
+ $this->assertEqual($height, 15);
+ $cont->load($this->_getOutputImage());
+ }
+
+ function testCropOfInternalArea()
+ {
+ $cont = $this->_getContainer();
+ $filter = new lmbImCropImageFilter(array('x' => 10, 'y' => 20, 'width' => 40, 'height' => 50));
+
+ $filter->apply($cont);
+ $cont->save($this->_getOutputImage());
+ list($width, $height, $type) = getimagesize($this->_getOutputImage());
+ $this->assertEqual($width, 40);
+ $this->assertEqual($height, 50);
+ $cont->load($this->_getOutputImage());
+ }
+
+ function testAutoDetectionOfSize()
+ {
+ $cont = $this->_getContainer();
+ $filter = new lmbImCropImageFilter(array('x' => 10, 'y' => 20));
+
+ $filter->apply($cont);
+ $cont->save($this->_getOutputImage());
+ list($width, $height, $type) = getimagesize($this->_getOutputImage());
+ $this->assertEqual($width, 90);
+ $this->assertEqual($height, 117);
+ $cont->load($this->_getOutputImage());
+ }
+
+ function testParams()
+ {
+ $filter = new lmbImCropImageFilter(array('width' => 90, 'height' => 100, 'x' => 10, 'y' => 20));
+
+ $this->assertEqual($filter->getWidth(), 90);
+ $this->assertEqual($filter->getHeight(), 100);
+ $this->assertEqual($filter->getX(), 10);
+ $this->assertEqual($filter->getY(), 20);
+ }
+
+ function tearDown()
+ {
+ @unlink($this->_getOutputImage());
+ }
+}
+?>
\ No newline at end of file
More information about the limb-svn
mailing list