[limb-svn] r6333 - in 3.x/trunk/limb/imagekit: docs src src/exception src/gd src/gd/filters tests/cases tests/cases/gd tests/cases/gd/filters
svn at limb-project.com
svn at limb-project.com
Mon Sep 24 20:38:23 MSD 2007
Author: cmz
Date: 2007-09-24 20:38:22 +0400 (Mon, 24 Sep 2007)
New Revision: 6333
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6333
Added:
3.x/trunk/limb/imagekit/docs/imagekit.png
3.x/trunk/limb/imagekit/docs/imagekit.zargo
3.x/trunk/limb/imagekit/src/gd/filters/lmbGdOutputImageFilter.class.php
3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdOutputImageFilterTest.class.php
Removed:
3.x/trunk/limb/imagekit/docs/image_alt.png
3.x/trunk/limb/imagekit/docs/image_alt.zargo
Modified:
3.x/trunk/limb/imagekit/src/exception/lmbImageCreateFailedException.class.php
3.x/trunk/limb/imagekit/src/exception/lmbImageSaveFailedException.class.php
3.x/trunk/limb/imagekit/src/exception/lmbImageTypeNotSupportException.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/lmbGdImageContainer.class.php
3.x/trunk/limb/imagekit/src/gd/lmbGdImageConvertor.class.php
3.x/trunk/limb/imagekit/src/lmbAbstractImageContainer.class.php
3.x/trunk/limb/imagekit/src/lmbAbstractImageConvertor.class.php
3.x/trunk/limb/imagekit/src/lmbAbstractImageFilter.class.php
3.x/trunk/limb/imagekit/src/lmbImageKit.class.php
3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdResizeImageFilterTest.class.php
3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdRotateImageFilterTest.class.php
3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdWaterMarkImageFilterTest.class.php
3.x/trunk/limb/imagekit/tests/cases/gd/lmbGdImageContainerTest.class.php
3.x/trunk/limb/imagekit/tests/cases/gd/lmbGdImageConvertorTest.class.php
3.x/trunk/limb/imagekit/tests/cases/lmbImageKitTest.class.php
Log:
-- total refactoring
Deleted: 3.x/trunk/limb/imagekit/docs/image_alt.png
===================================================================
(Binary files differ)
Deleted: 3.x/trunk/limb/imagekit/docs/image_alt.zargo
===================================================================
(Binary files differ)
Copied: 3.x/trunk/limb/imagekit/docs/imagekit.png (from rev 6331, 3.x/trunk/limb/imagekit/docs/image_alt.png)
===================================================================
(Binary files differ)
Property changes on: 3.x/trunk/limb/imagekit/docs/imagekit.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Copied: 3.x/trunk/limb/imagekit/docs/imagekit.zargo (from rev 6331, 3.x/trunk/limb/imagekit/docs/image_alt.zargo)
===================================================================
(Binary files differ)
Property changes on: 3.x/trunk/limb/imagekit/src/exception/lmbImageCreateFailedException.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: 3.x/trunk/limb/imagekit/src/exception/lmbImageSaveFailedException.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: 3.x/trunk/limb/imagekit/src/exception/lmbImageTypeNotSupportException.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Added: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdOutputImageFilter.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdOutputImageFilter.class.php (rev 0)
+++ 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdOutputImageFilter.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -0,0 +1,34 @@
+<?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
+ */
+
+/**
+ * @package imagekit
+ * @version $Id$
+ */
+lmb_require(dirname(__FILE__).'/../../lmbAbstractImageFilter.class.php');
+
+/**
+ * Change output type
+ * @package imagekit
+ * @version $Id$
+ */
+class lmbGdOutputImageFilter extends lmbAbstractImageFilter {
+
+ function apply(lmbAbstractImageContainer $container)
+ {
+ $container->setOutputType($this->getType());
+ }
+
+ function getType()
+ {
+ return $this->getParam('type', '');
+ }
+
+}
+?>
\ No newline at end of file
Property changes on: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdOutputImageFilter.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdResizeImageFilter.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdResizeImageFilter.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdResizeImageFilter.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -20,7 +20,7 @@
*/
class lmbGdResizeImageFilter extends lmbAbstractImageFilter
{
- function run(lmbAbstractImageContainer $container)
+ function apply(lmbAbstractImageContainer $container)
{
$src_w = $container->getWidth();
$src_h = $container->getHeight();
@@ -33,31 +33,33 @@
protected function calcNewSize($src_w, $src_h)
{
$dst_w = $this->getWidth();
- if(!$dst_w) $dst_w = $src_w;
+ if(!$dst_w)
+ $dst_w = $src_w;
$dst_h = $this->getheight();
- if(!$dst_h) $dst_h = $src_h;
+ if(!$dst_h)
+ $dst_h = $src_h;
//return array($dst_w, $dst_h);
return $this->calcSize($src_w, $src_h, $dst_w, $dst_h, $this->getPreserveAspectRatio(), $this->getSaveMinSize());
}
function getWidth()
{
- return $this->getParam('width', 0);
+ return $this->getParam('width');
}
function getHeight()
{
- return $this->getParam('height', 1);
+ return $this->getParam('height');
}
function getPreserveAspectRatio()
{
- return $this->getParam('preserve_aspect_ratio', 2, true);
+ return $this->getParam('preserve_aspect_ratio', true);
}
function getSaveMinSize()
{
- return $this->getParam('save_min_size', 3, false);
+ return $this->getParam('save_min_size', false);
}
}
?>
Property changes on: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdResizeImageFilter.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdRotateImageFilter.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdRotateImageFilter.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdRotateImageFilter.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -21,10 +21,11 @@
class lmbGdRotateImageFilter extends lmbAbstractImageFilter
{
- function run(lmbAbstractImageContainer $container)
+ function apply(lmbAbstractImageContainer $container)
{
$angle = $this->getAngle();
- if(!$angle) return;
+ if(!$angle)
+ return;
$bgcolor = $this->getBgColor();
$cur_im = $container->getResource();
$bg = imagecolorallocate($cur_im, $bgcolor['red'], $bgcolor['green'], $bgcolor['blue']);
@@ -39,7 +40,7 @@
function getBgColor()
{
- $bgcolor = $this->getParam('bgcolor', 1, 'FFFFFF');
+ $bgcolor = $this->getParam('bgcolor', 'FFFFFF');
return $this->parseHexColor($bgcolor);
}
}
Property changes on: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdRotateImageFilter.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdWaterMarkImageFilter.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdWaterMarkImageFilter.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdWaterMarkImageFilter.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -21,41 +21,45 @@
class lmbGdWaterMarkImageFilter extends lmbAbstractImageFilter
{
- function run(lmbAbstractImageContainer $container)
+ function apply(lmbAbstractImageContainer $container)
{
$width = $container->getWidth();
$height = $container->getHeight();
- $wm_cont = new lmbGdImageContainer($this->getWaterMark());
+ $wm_cont = new lmbGdImageContainer();
+ $wm_cont->load($this->getWaterMark());
list($x, $y) = $this->calcPosition($this->getX(), $this->getY(), $width, $height);
imagecopymerge($container->getResource(), $wm_cont->getResource(), $x, $y, 0, 0, $wm_cont->getWidth(), $wm_cont->getHeight(), 100 - $this->getOpacity());
}
function calcPosition($x, $y, $width, $height)
{
- if($x >= 0 && $y >= 0) return array($x, $y);
- if($x < 0) $x += $width;
- if($y < 0) $y += $height;
+ if($x >= 0 && $y >= 0)
+ return array($x, $y);
+ if($x < 0)
+ $x += $width;
+ if($y < 0)
+ $y += $height;
return array($x, $y);
}
function getWaterMark()
{
- return $this->getParam('water_mark', 0);
+ return $this->getParam('water_mark');
}
function getX()
{
- return $this->getParam('x', 1, 0);
+ return $this->getParam('x', 0);
}
function getY()
{
- return $this->getParam('y', 2, 0);
+ return $this->getParam('y', 0);
}
function getOpacity()
{
- return $this->getParam('opacity', 3, 0);
+ return $this->getParam('opacity', 0);
}
}
?>
\ No newline at end of file
Property changes on: 3.x/trunk/limb/imagekit/src/gd/filters/lmbGdWaterMarkImageFilter.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/src/gd/lmbGdImageContainer.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/lmbGdImageContainer.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/src/gd/lmbGdImageContainer.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -42,17 +42,29 @@
protected $img;
protected $img_type;
protected $pallete;
+ protected $out_type;
+ function setOutputType($type)
+ {
+ if($type)
+ if(!self::supportSaveType($type))
+ throw new lmbImageTypeNotSupportException($type);
+
+ parent::setOutputType($type);
+ }
+
function load($file_name, $type = '')
{
+ $this->destroyImage();
+
$imginfo = @getimagesize($file_name);
- if(!$imginfo)
+ if(!$imginfo)
throw new lmbFileNotFoundException($file_name);
- if(!$type)
+ if(!$type)
$type = self::convertImageType($imginfo[2]);
- if(!self::supportLoadType($type))
+ if(!self::supportLoadType($type))
throw new lmbImageTypeNotSupportException($type);
$createfunc = 'imagecreatefrom'.$type;
@@ -62,8 +74,9 @@
$this->img_type = $type;
}
- function save($file_name = null, $type = '')
+ function save($file_name = null)
{
+ $type = $this->output_type;
if(!$type)
$type = $this->img_type;
@@ -111,6 +124,8 @@
$this->img = null;
}
+
+
static function supportLoadType($type)
{
return self::supportType($type);
Property changes on: 3.x/trunk/limb/imagekit/src/gd/lmbGdImageContainer.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/src/gd/lmbGdImageConvertor.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/gd/lmbGdImageConvertor.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/src/gd/lmbGdImageConvertor.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -21,7 +21,7 @@
* @package imagekit
* @version $Id$
*/
-class lmbGdImageConvertor extends lmbAbstractImageConvertor
+class lmbGdImageConvertor extends lmbAbstractImageConvertor
{
protected function createFilter($name, $params)
{
@@ -31,12 +31,14 @@
protected function createImageContainer($file_name, $type = '')
{
- return new lmbGdImageContainer($file_name, $type);
+ $container = new lmbGdImageContainer();
+ $container->load($file_name, $type);
+ return $container;
}
function isSupportConversion($file, $src_type = '', $dest_type = '')
{
- if(!$src_type)
+ if(!$src_type)
{
$imginfo = @getimagesize($file);
if(!$imginfo)
Property changes on: 3.x/trunk/limb/imagekit/src/gd/lmbGdImageConvertor.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/src/lmbAbstractImageContainer.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/lmbAbstractImageContainer.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/src/lmbAbstractImageContainer.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -13,17 +13,24 @@
* @package imagekit
* @version $Id$
*/
-abstract class lmbAbstractImageContainer
+abstract class lmbAbstractImageContainer
{
- function __construct($file_name, $type = '')
+ protected $output_type = '';
+
+ function setOutputType($type)
{
- $this->load($file_name, $type);
+ $this->output_type = $type;
}
+ function getOutputType()
+ {
+ return $this->output_type;
+ }
+
abstract function load($file_name, $type = '');
- abstract function save($file_name = null, $type = '');
+ abstract function save($file_name = null);
}
?>
\ No newline at end of file
Property changes on: 3.x/trunk/limb/imagekit/src/lmbAbstractImageContainer.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/src/lmbAbstractImageConvertor.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/lmbAbstractImageConvertor.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/src/lmbAbstractImageConvertor.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -15,34 +15,21 @@
*/
abstract class lmbAbstractImageConvertor
{
- protected $filters = array();
protected $container = null;
- function addFilter($name, $params)
+ function __call($name, $args)
{
- $this->filters[] = $this->createFilter($name, $params);
+ $params = (isset($args[0]) && is_array($args[0])) ? $args[0] : array();
+ return $this->applyFilter($name, $params);
}
- function __call($name, $params)
+ protected function applyFilter($name, $params)
{
- return $this->runFilter($name, $params);
- }
-
- protected function runFilter($name, $params)
- {
$filter = $this->createFilter($name, $params);
- $filter->run($this->container);
+ $filter->apply($this->container);
return $this;
}
- function run($src, $dest = null, $src_type = '', $dest_type = '')
- {
- $container = $this->createImageContainer($src, $src_type);
- foreach($this->filters as $filter)
- $filter->run($container);
- $container->save($dest, $dest_type);
- }
-
function load($file_name, $type = '')
{
$this->container = $this->createImageContainer($file_name, $type);
@@ -52,14 +39,27 @@
function apply($name)
{
$args = func_get_args();
- $params = array_slice($args, 1);
- return $this->runFilter($name, $params);
+ $params = (isset($args[1]) && is_array($args[1])) ? $args[1] : array();
+ return $this->applyFilter($name, $params);
}
+ function applyBatch($batch)
+ {
+ foreach($batch as $filter)
+ {
+ list($name, $params) = each($filter);
+ $this->applyFilter($name, $params);
+ }
+ return $this;
+ }
+
function save($file_name = null, $type = '')
{
- $this->container->save($file_name, $type);
+ if($type)
+ $this->container->setOutputType($type);
+ $this->container->save($file_name);
$this->container = null;
+ return $this;
}
protected function loadFilter($dir, $name, $prefix)
Property changes on: 3.x/trunk/limb/imagekit/src/lmbAbstractImageConvertor.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/src/lmbAbstractImageFilter.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/src/lmbAbstractImageFilter.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/src/lmbAbstractImageFilter.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -79,16 +79,14 @@
return array($w, $h);
}
- function getParam($name, $num, $default = null)
+ function getParam($name, $default = null)
{
$param = $default;
if(isset($this->params[$name]))
$param = $this->params[$name];
- elseif(isset($this->params[$num]))
- $param = $this->params[$num];
return $param;
}
- abstract function run(lmbAbstractImageContainer $container);
+ abstract function apply(lmbAbstractImageContainer $container);
}
?>
Property changes on: 3.x/trunk/limb/imagekit/src/lmbAbstractImageFilter.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: 3.x/trunk/limb/imagekit/src/lmbImageKit.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Added: 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdOutputImageFilterTest.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdOutputImageFilterTest.class.php (rev 0)
+++ 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdOutputImageFilterTest.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -0,0 +1,27 @@
+<?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__).'/../../../../src/gd/lmbGdImageContainer.class.php');
+lmb_require(dirname(__FILE__).'/../../../../src/gd/filters/lmbGdOutputImageFilter.class.php');
+
+class lmbGdOutputImageFilterTest extends UnitTestCase {
+
+ function testChangeOutput()
+ {
+ $cont = new lmbGdImageContainer();
+ $cont->setOutputType('gif');
+
+ $filter = new lmbGdOutputImageFilter(array('type' => 'jpeg'));
+ $filter->apply($cont);
+
+ $this->assertEqual($cont->getOutputType(), 'jpeg');
+ }
+
+}
+?>
\ No newline at end of file
Property changes on: 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdOutputImageFilterTest.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdResizeImageFilterTest.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdResizeImageFilterTest.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdResizeImageFilterTest.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -25,7 +25,9 @@
function _getContainer()
{
- return new lmbGdImageContainer($this->_getInputImage());
+ $cont = new lmbGdImageContainer();
+ $cont->load($this->_getInputImage());
+ return $cont;
}
function testSimpleResize()
@@ -33,7 +35,7 @@
$cont = $this->_getContainer();
$filter = new lmbGdResizeImageFilter(array('width' => 50, 'height' => 70, 'preserve_aspect_ratio' => false));
- $filter->run($cont);
+ $filter->apply($cont);
$cont->save($this->_getOutputImage());
list($width, $height, $type) = getimagesize($this->_getOutputImage());
$this->assertEqual($width, 50);
@@ -86,13 +88,6 @@
$this->assertEqual($filter->getHeight(), 100);
$this->assertFalse($filter->getPreserveAspectRatio());
$this->assertTrue($filter->getSaveMinSize());
-
- $filter = new lmbGdResizeImageFilter(array(10, 50, true, false));
-
- $this->assertEqual($filter->getWidth(), 10);
- $this->assertEqual($filter->getHeight(), 50);
- $this->assertTrue($filter->getPreserveAspectRatio());
- $this->assertFalse($filter->getSaveMinSize());
}
function tearDown()
Property changes on: 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdResizeImageFilterTest.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdRotateImageFilterTest.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdRotateImageFilterTest.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdRotateImageFilterTest.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -24,7 +24,9 @@
function _getContainer()
{
- return new lmbGdImageContainer($this->_getInputImage());
+ $cont = new lmbGdImageContainer();
+ $cont->load($this->_getInputImage());
+ return $cont;
}
function testRotate()
@@ -32,7 +34,7 @@
$cont = $this->_getContainer();
$filter = new lmbGdRotateImageFilter(array('angle' => 90));
- $filter->run($cont);
+ $filter->apply($cont);
$cont->save($this->_getOutputImage());
list($width, $height, $type) = getimagesize($this->_getInputImage());
list($width2, $height2, $type2) = getimagesize($this->_getOutputImage());
@@ -50,14 +52,6 @@
$this->assertEqual($bgcolor['red'], 255);
$this->assertEqual($bgcolor['green'], 0);
$this->assertEqual($bgcolor['blue'], 0);
-
- $filter = new lmbGdRotateImageFilter(array(100, 'bgcolor' => '00FF00'));
-
- $this->assertEqual($filter->getAngle(), 100);
- $bgcolor = $filter->getBgColor();
- $this->assertEqual($bgcolor['red'], 0);
- $this->assertEqual($bgcolor['green'], 255);
- $this->assertEqual($bgcolor['blue'], 0);
}
function tearDown()
Property changes on: 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdRotateImageFilterTest.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdWaterMarkImageFilterTest.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdWaterMarkImageFilterTest.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdWaterMarkImageFilterTest.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -30,7 +30,9 @@
function _getContainer()
{
- return new lmbGdImageContainer($this->_getInputImage());
+ $cont = new lmbGdImageContainer();
+ $cont->load($this->_getInputImage());
+ return $cont;
}
function testWaterMark()
@@ -38,7 +40,7 @@
$cont = $this->_getContainer();
$filter = new lmbGdWaterMarkImageFilter(array('water_mark' => $this->_getWaterMarkImage(), 'x' => 5, 'y' => 6));
- $filter->run($cont);
+ $filter->apply($cont);
$cont->save($this->_getOutputImage());
list($width, $height, $type) = getimagesize($this->_getInputImage());
list($width2, $height2, $type2) = getimagesize($this->_getOutputImage());
@@ -55,13 +57,6 @@
$this->assertEqual($filter->getX(), 90);
$this->assertEqual($filter->getY(), 100);
$this->assertEqual($filter->getOpacity(), 20);
-
- $filter = new lmbGdWaterMarkImageFilter(array('input.jpg', 10, 50, 30));
-
- $this->assertEqual($filter->getWaterMark(), 'input.jpg');
- $this->assertEqual($filter->getX(), 10);
- $this->assertEqual($filter->getY(), 50);
- $this->assertEqual($filter->getOpacity(), 30);
}
function testCalcPosition()
Property changes on: 3.x/trunk/limb/imagekit/tests/cases/gd/filters/lmbGdWaterMarkImageFilterTest.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/tests/cases/gd/lmbGdImageContainerTest.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/tests/cases/gd/lmbGdImageContainerTest.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/tests/cases/gd/lmbGdImageContainerTest.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -26,9 +26,10 @@
return dirname(__FILE__).'/../../var/output.jpg';
}
- function testConstructSave()
+ function testLoadSave()
{
- $cont = new lmbGdImageContainer($this->_getInputImage());
+ $cont = new lmbGdImageContainer();
+ $cont->load($this->_getInputImage());
$cont->save($this->_getOutputImage());
list($width, $height, $type) = getimagesize($this->_getInputImage());
@@ -40,8 +41,10 @@
function testChangeType()
{
- $cont = new lmbGdImageContainer($this->_getInputImage(), 'jpeg');
- $cont->save($this->_getOutputImage(), 'gif');
+ $cont = new lmbGdImageContainer();
+ $cont->load($this->_getInputImage(), 'jpeg');
+ $cont->setOutputType('gif');
+ $cont->save($this->_getOutputImage());
list($width, $height, $type) = getimagesize($this->_getInputImage());
list($width2, $height2, $type2) = getimagesize($this->_getOutputImage());
$this->assertEqual($width, $width2);
@@ -53,7 +56,8 @@
function testGetSize()
{
- $cont = new lmbGdImageContainer($this->_getInputImage());
+ $cont = new lmbGdImageContainer();
+ $cont->load($this->_getInputImage());
$this->assertEqual($cont->getWidth(), 100);
$this->assertEqual($cont->getHeight(), 137);
@@ -61,13 +65,22 @@
function testIsPallete()
{
- $cont = new lmbGdImageContainer($this->_getInputImage());
+ $cont = new lmbGdImageContainer();
+ $cont->load($this->_getInputImage());
$this->assertFalse($cont->isPallete());
- $cont = new lmbGdImageContainer($this->_getPalleteImage());
+ $cont->load($this->_getPalleteImage());
$this->assertTrue($cont->isPallete());
}
+ function testSetGetOutputType()
+ {
+ $cont = new lmbGdImageContainer();
+ $cont->setOutputType('gif');
+
+ $this->assertEqual($cont->getOutputType(), 'gif');
+ }
+
function tearDown()
{
@unlink($this->_getOutputImage());
Property changes on: 3.x/trunk/limb/imagekit/tests/cases/gd/lmbGdImageContainerTest.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/tests/cases/gd/lmbGdImageConvertorTest.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/tests/cases/gd/lmbGdImageConvertorTest.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/tests/cases/gd/lmbGdImageConvertorTest.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -26,17 +26,46 @@
return new lmbGdImageConvertor();
}
- function testSimpleResize()
+ function testApply()
{
$conv = $this->_getConvertor();
- $conv->addFilter('resize', array('width' => 50, 'height' => 70, 'preserve_aspect_ratio' => false));
+ $conv->load($this->_getInputImage());
+ $conv->apply('resize', array('width' => 50, 'height' => 70, 'preserve_aspect_ratio' => false));
- $conv->run($this->_getInputImage(), $this->_getOutputImage());
+ $conv->save($this->_getOutputImage());
list($width, $height, $type) = getimagesize($this->_getOutputImage());
$this->assertEqual($width, 50);
$this->assertEqual($height, 70);
}
+ function testApplyByOverload()
+ {
+ $conv = $this->_getConvertor();
+ $conv->load($this->_getInputImage());
+ $conv->resize(array('width' => 50, 'height' => 70, 'preserve_aspect_ratio' => false));
+
+ $conv->save($this->_getOutputImage());
+ list($width, $height, $type) = getimagesize($this->_getOutputImage());
+ $this->assertEqual($width, 50);
+ $this->assertEqual($height, 70);
+ }
+
+ function testApplyBatch()
+ {
+ $batch = array(
+ array('resize' => array('width' => 50, 'height' => 60, 'preserve_aspect_ratio' => false)),
+ array('rotate' => array('angle' => 90))
+ );
+ $conv = $this->_getConvertor();
+ $conv->load($this->_getInputImage());
+ $conv->applyBatch($batch);
+
+ $conv->save($this->_getOutputImage());
+ list($width, $height, $type) = getimagesize($this->_getOutputImage());
+ $this->assertEqual($width, 60);
+ $this->assertEqual($height, 50);
+ }
+
function testCheckSupportConv()
{
$conv = $this->_getConvertor();
Property changes on: 3.x/trunk/limb/imagekit/tests/cases/gd/lmbGdImageConvertorTest.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: 3.x/trunk/limb/imagekit/tests/cases/lmbImageKitTest.class.php
===================================================================
--- 3.x/trunk/limb/imagekit/tests/cases/lmbImageKitTest.class.php 2007-09-24 12:55:41 UTC (rev 6332)
+++ 3.x/trunk/limb/imagekit/tests/cases/lmbImageKitTest.class.php 2007-09-24 16:38:22 UTC (rev 6333)
@@ -30,16 +30,16 @@
function testTraversing()
{
- lmbImageKit::load($this->_getInputImage())->apply('resize', 50, 60, false)->apply('rotate', 90)->save($this->_getOutputImage());
+ lmbImageKit::load($this->_getInputImage())->apply('resize', array('width' => 50, 'height' => 60, 'preserve_aspect_ratio' => false))->apply('rotate', array('angle' => 90))->save($this->_getOutputImage());
list($width, $height, $type) = getimagesize($this->_getOutputImage());
$this->assertEqual($width, 60);
$this->assertEqual($height, 50);
}
- function testOtherTraversing()
+ function testTraversingByOverloading()
{
- lmbImageKit::load($this->_getInputImage())->resize(50, 60, false)->rotate(90)->save($this->_getOutputImage());
+ lmbImageKit::load($this->_getInputImage())->resize(array('width' => 50, 'height' => 60, 'preserve_aspect_ratio' => false))->rotate(array('angle' => 90))->save($this->_getOutputImage());
list($width, $height, $type) = getimagesize($this->_getOutputImage());
$this->assertEqual($width, 60);
Property changes on: 3.x/trunk/limb/imagekit/tests/cases/lmbImageKitTest.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
More information about the limb-svn
mailing list