Author: Tobias Schlitt
Date: 2006-01-13 12:08:51 +0100 (Fri, 13 Jan 2006)
New Revision: 1817
Log:
- Rename parameters of the "crop" filter. The crop filter is now used with
start-coordinates and width/height, instead of start and end coordinates.
# Request by Bard and makes sense.
Modified:
packages/ImageConversion/trunk/src/filters/gd.php
packages/ImageConversion/trunk/src/filters/imagemagick.php
packages/ImageConversion/trunk/src/interfaces/geometry.php
packages/ImageConversion/trunk/tests/filtersgd_test.php
packages/ImageConversion/trunk/tests/filtersshell_test.php
packages/ImageConversion/trunk/tests/handlergd_test.php
packages/ImageConversion/trunk/tests/handlershell_test.php
packages/ImageConversion/trunk/tests/transformation_test.php
Modified: packages/ImageConversion/trunk/src/filters/gd.php
===================================================================
--- packages/ImageConversion/trunk/src/filters/gd.php 2006-01-13 11:06:24 UTC
(rev 1816)
+++ packages/ImageConversion/trunk/src/filters/gd.php 2006-01-13 11:08:51 UTC
(rev 1817)
@@ -232,10 +232,10 @@
* [EMAIL PROTECTED] ezcImageConverter}). Coordinates are given as
integer values and
* are measured from the top left corner.
*
- * @param int $xStart Start cropping, x coordinate.
- * @param int $yStart Start cropping, y coordinate.
- * @param int $xEnd End cropping, x coordinate.
- * @param int $yEnd End cropping, y coordinate.
+ * @param int $x Start cropping, x coordinate.
+ * @param int $y Start cropping, y coordinate.
+ * @param int $width Width of cropping area.
+ * @param int $height Height of cropping area.
* @return void
*
* @throws ezcImageInvalidReferenceException
@@ -243,18 +243,18 @@
* @throws ezcImageFilterFailedException
* If the operation performed by the the filter failed.
*/
- function crop( $xStart, $yStart, $xEnd, $yEnd )
+ function crop( $x, $y, $width, $height )
{
$oldResource = $this->handler->getActiveResource();
$dimensions = array(
- 'x' => abs( $xEnd - $xStart ),
- 'y' => abs( $yEnd - $yStart ),
+ 'x' => abs( $width ),
+ 'y' => abs( $height ),
);
$coords = array(
- 'xStart' => min( $xStart, $xEnd ),
- 'xEnd' => max( $xStart, $xEnd ),
- 'yStart' => min( $yStart, $yEnd ),
- 'yEnd' => max( $yStart, $yEnd ),
+ 'xStart' => min( $x, $x + $width ),
+ 'xEnd' => max( $x, $x + $width ),
+ 'yStart' => min( $y, $y + $height ),
+ 'yEnd' => max( $y, $y + $height ),
);
if ( imageistruecolor( $oldResource ) )
{
Modified: packages/ImageConversion/trunk/src/filters/imagemagick.php
===================================================================
--- packages/ImageConversion/trunk/src/filters/imagemagick.php 2006-01-13
11:06:24 UTC (rev 1816)
+++ packages/ImageConversion/trunk/src/filters/imagemagick.php 2006-01-13
11:08:51 UTC (rev 1817)
@@ -179,25 +179,23 @@
* [EMAIL PROTECTED] ezcImageConverter}). Coordinates are given as
integer values and
* are measured from the top left corner.
*
- * @param int $xStart Start cropping, x coordinate.
- * @param int $yStart Start cropping, y coordinate.
- * @param int $xEnd End cropping, x coordinate.
- * @param int $yEnd End cropping, y coordinate.
+ * @param int $x Start cropping, x coordinate.
+ * @param int $y Start cropping, y coordinate.
+ * @param int $width Width of cropping area.
+ * @param int $height Height of cropping area.
* @return void
*
* @throws ezcImageInvalidReferenceException
* No loaded file could be found or an error destroyed a loaded
reference.
*/
- public function crop( $xStart, $yStart, $xEnd, $yEnd )
+ public function crop( $x, $y, $width, $height )
{
- $width = abs( $xEnd - $xStart );
- $height = abs( $xEnd - $xStart );
- $xStart = ( $xStart > 0 ) ? '+'.$xStart : $xStart;
- $yStart = ( $yStart > 0 ) ? '+'.$yStart : $yStart;
+ $xStart = ( $xStart = min( $x, $x + $width ) ) > 0 ? '+'.$xStart :
$xStart;
+ $yStart = ( $yStart = min( $y, $y + $height ) ) > 0 ? '+'.$yStart :
$yStart;
$this->handler->addFilterOption(
$this->handler->getActiveReference(),
'-crop ',
- $width.'x'.$height.$xStart.'x'.$yStart
+ abs( $width ).'x'.abs( $height ).$xStart.'x'.$yStart
);
}
Modified: packages/ImageConversion/trunk/src/interfaces/geometry.php
===================================================================
--- packages/ImageConversion/trunk/src/interfaces/geometry.php 2006-01-13
11:06:24 UTC (rev 1816)
+++ packages/ImageConversion/trunk/src/interfaces/geometry.php 2006-01-13
11:08:51 UTC (rev 1817)
@@ -150,10 +150,10 @@
* [EMAIL PROTECTED] ezcImageConverter}). Coordinates are given as
integer values and
* are measured from the top left corner.
*
- * @param int $xStart Start cropping, x coordinate.
- * @param int $yStart Start cropping, y coordinate.
- * @param int $xEnd End cropping, x coordinate.
- * @param int $yEnd End cropping, y coordinate.
+ * @param int $x Start cropping, x coordinate.
+ * @param int $y Start cropping, y coordinate.
+ * @param int $width Width of cropping area.
+ * @param int $height Height of cropping area.
* @return void
*
* @throws ezcImageInvalidReferenceException
@@ -162,6 +162,6 @@
* If the operation performed by the the filter failed
* [EMAIL PROTECTED] ezcImageFiltersException::FAILED}.
*/
- function crop( $xStart, $yStart, $xEnd, $yEnd );
+ function crop( $x, $y, $width, $height );
}
?>
Modified: packages/ImageConversion/trunk/tests/filtersgd_test.php
===================================================================
--- packages/ImageConversion/trunk/tests/filtersgd_test.php 2006-01-13
11:06:24 UTC (rev 1816)
+++ packages/ImageConversion/trunk/tests/filtersgd_test.php 2006-01-13
11:08:51 UTC (rev 1817)
@@ -456,7 +456,7 @@
public function testCrop_1()
{
$filters = new ezcImageGdFilters( $this->handler );
- $filters->crop( 50, 38, 100, 75 );
+ $filters->crop( 50, 38, 50, 37 );
$this->handler->save( $this->imageReference, $this->tmpPath .
'testCrop_1.jpg' );
$this->assertEquals(
'437f836552da040a4571f114aee95315',
@@ -468,7 +468,7 @@
public function testCrop_2()
{
$filters = new ezcImageGdFilters( $this->handler );
- $filters->crop( 100, 75, 50, 38 );
+ $filters->crop( 100, 75, -50, -37 );
$this->handler->save( $this->imageReference, $this->tmpPath .
'testCrop_2.jpg' );
$this->assertEquals(
'437f836552da040a4571f114aee95315',
@@ -480,7 +480,7 @@
public function testCrop_3()
{
$filters = new ezcImageGdFilters( $this->handler );
- $filters->crop( 50, 75, 250, 38 );
+ $filters->crop( 50, 75, 200, -37 );
$this->handler->save( $this->imageReference, $this->tmpPath .
'testCrop_3.jpg' );
$this->assertEquals(
'acbcb000f1e1ec1d7b727b30f30aebb0',
Modified: packages/ImageConversion/trunk/tests/filtersshell_test.php
===================================================================
--- packages/ImageConversion/trunk/tests/filtersshell_test.php 2006-01-13
11:06:24 UTC (rev 1816)
+++ packages/ImageConversion/trunk/tests/filtersshell_test.php 2006-01-13
11:08:51 UTC (rev 1817)
@@ -31,46 +31,37 @@
);
protected $expectedResults = array(
- 'testScaleBoth' => 'd0969b833c95c0cabb4e5dbf0100eaa7',
+ 'testBorder_2' => 'e84cdc684fdc90d3a8bde7abde3538c0',
+ 'testBorder_5' => 'f26ab77fc309e38fce4788aed70348a2',
+ 'testColorspaceGrey' => '57d8e16a4a01131fbaecd519162aa095',
+ 'testColorspaceMonochrome' => '53bc6b9f9e012e875b27143bd3e29e21',
+ 'testColorspaceSepia' => '1db4c3a057a2546dd56f0d61f8480911',
+ 'testCrop_1' => 'cbba8251105a848860ef111ed20dacf2',
+ 'testCrop_2' => 'cbba8251105a848860ef111ed20dacf2',
+ 'testCrop_3' => 'aa349d0114ac04540a16f3a77bcd4573',
+ 'testScale' => 'd0969b833c95c0cabb4e5dbf0100eaa7',
'testScaleDown_do' => 'd896401cee2e7e9913fc3e0ac8946d6e',
'testScaleDown_dont' => '902e24014b1d1490a94eaf89be5113a6',
- 'testScaleUp_do' => 'd0969b833c95c0cabb4e5dbf0100eaa7',
- 'testScaleUp_dont' => '902e24014b1d1490a94eaf89be5113a6',
- 'testScaleWidthBoth' => '4850859d12d6acb12ba3d4488b2a80ee',
- 'testScaleWidthUp_1' => '902e24014b1d1490a94eaf89be5113a6',
- 'testScaleWidthUp_2' => '33a84244a4dbe99a6e69fe21f1bae6a4',
- 'testScaleWidthDown_1' => '902e24014b1d1490a94eaf89be5113a6',
- 'testScaleWidthDown_2' => '4850859d12d6acb12ba3d4488b2a80ee',
+ 'testScaleExact_1' => '29814bd3aba32b5e4f0f09d980e55523',
+ 'testScaleExact_2' => '3e67f58c4ff4abd9f398cf8b8789aa45',
+ 'testScaleExact_3' => '6963f30c3c8f69e3a86b4d6e3e65b4c6',
'testScaleHeightBoth' => 'a94cdc09c4071c812963b15b76d6c8c7',
- 'testScaleHeightUp_1' => '332817a9d76d1ff786e0c1974211f60f',
- 'testScaleHeightUp_2' => '902e24014b1d1490a94eaf89be5113a6',
'testScaleHeightDown_1' => '902e24014b1d1490a94eaf89be5113a6',
'testScaleHeightDown_2' => '3ce41709bb8df756595942fa5f9b3085',
+ 'testScaleHeightUp_1' => '332817a9d76d1ff786e0c1974211f60f',
+ 'testScaleHeightUp_2' => '902e24014b1d1490a94eaf89be5113a6',
'testScalePercent_1' => 'a94cdc09c4071c812963b15b76d6c8c7',
'testScalePercent_2' => '29814bd3aba32b5e4f0f09d980e55523',
- 'testScaleExact_1' => '29814bd3aba32b5e4f0f09d980e55523',
- 'testScaleExact_2' => '4904df5b10408bdc517be2150d706db4',
- 'testScaleExact_3' => '6963f30c3c8f69e3a86b4d6e3e65b4c6',
- 'testCrop_1' => '4904df5b10408bdc517be2150d706db4',
- 'testCrop_2' => '57d8e16a4a01131fbaecd519162aa095',
- 'testCrop_3' => 'a5c57f1480737ef298eecbfe4a4fc22e',
- 'testColorspaceGrey' => '57d8e16a4a01131fbaecd519162aa095',
- 'testColorspaceMonochrome' => '53bc6b9f9e012e875b27143bd3e29e21',
- 'testColorspaceSepia' => '1db4c3a057a2546dd56f0d61f8480911',
-/*
- 'testNoiseUniform' => 'bebc623c12180137e3db4028c9687c1e',
- 'testNoiseGaussian' => '214604cfc3a8179dcb396ac52d6703e9',
- 'testNoiseMultiplicative' => 'f69c7650df3d1749446c903bc2996543',
- 'testNoiseImpulse' => '2dfd0fe4aa170b078749f82a31e8ba96',
- 'testNoiseLaplacian' => 'c1c720e176debe6a3a36094bf896346b',
- 'testNoisePoisson' => '6e63737d286311fd83c1d381d022aa96',
-
-*/
+ 'testScaleUp_do' => 'd0969b833c95c0cabb4e5dbf0100eaa7',
+ 'testScaleUp_dont' => '902e24014b1d1490a94eaf89be5113a6',
+ 'testScaleWidthBoth' => '4850859d12d6acb12ba3d4488b2a80ee',
+ 'testScaleWidthDown_1' => '902e24014b1d1490a94eaf89be5113a6',
+ 'testScaleWidthDown_2' => '4850859d12d6acb12ba3d4488b2a80ee',
+ 'testScaleWidthUp_1' => '902e24014b1d1490a94eaf89be5113a6',
+ 'testScaleWidthUp_2' => '33a84244a4dbe99a6e69fe21f1bae6a4',
'testSwirl_10' => '842f1639c9b2fad83765b1e36e5e66a3',
- 'testSwirl_50' => '6a55dfa03983bc1849664a7c0212c39b',
'testSwirl_100' => 'c84b8ef31597e64226a3785e5121fb28',
- 'testBorder_2' => 'e84cdc684fdc90d3a8bde7abde3538c0',
- 'testBorder_5' => 'f26ab77fc309e38fce4788aed70348a2',
+ 'testSwirl_50' => '6a55dfa03983bc1849664a7c0212c39b',
);
public static function suite()
@@ -100,7 +91,7 @@
unset( $this->handler );
}
- public function testScaleBoth()
+ public function testScale()
{
$dstPath = $this->createTempDir( str_replace( '::', '_', __METHOD__) .
'_' ) . '/result';
$filters = new ezcImageImagemagickFilters( $this->handler );
@@ -260,22 +251,6 @@
$this->removeTempDir();
}
- public function testScaleHeightBoth()
- {
- $dstPath = $this->createTempDir( str_replace( '::', '_', __METHOD__) .
'_' ) . '/result';
- $filters = new ezcImageImagemagickFilters( $this->handler );
- $filters->scalePercent( 50, 50 );
- $this->handler->save( $this->handler->getActiveReference(), $dstPath );
- // echo "\n'".__FUNCTION__."' => '".md5_file( $dstPath )."',\n";
- $this->assertEquals(
- $this->expectedResults[__FUNCTION__],
- md5_file( $dstPath ),
- 'Filter <'.__METHOD__.'> did not produce correct output.'
- );
- $this->handler->close( $this->handler->getActiveReference() );
- $this->removeTempDir();
- }
-
public function testScaleHeightUp_1()
{
$dstPath = $this->createTempDir( str_replace( '::', '_', __METHOD__) .
'_' ) . '/result';
@@ -392,7 +367,7 @@
{
$dstPath = $this->createTempDir( str_replace( '::', '_', __METHOD__) .
'_' ) . '/result';
$filters = new ezcImageImagemagickFilters( $this->handler );
- $filters->crop( 50, 38, 100, 75 );
+ $filters->scaleExact( 10, 200 );
$this->handler->save( $this->handler->getActiveReference(), $dstPath );
// echo "\n'".__FUNCTION__."' => '".md5_file( $dstPath )."',\n";
$this->assertEquals(
@@ -424,7 +399,7 @@
{
$dstPath = $this->createTempDir( str_replace( '::', '_', __METHOD__) .
'_' ) . '/result';
$filters = new ezcImageImagemagickFilters( $this->handler );
- $filters->crop( 50, 38, 100, 75 );
+ $filters->crop( 50, 38, 50, 37 );
$this->handler->save( $this->handler->getActiveReference(), $dstPath );
// echo "\n'".__FUNCTION__."' => '".md5_file( $dstPath )."',\n";
$this->assertEquals(
@@ -440,7 +415,7 @@
{
$dstPath = $this->createTempDir( str_replace( '::', '_', __METHOD__) .
'_' ) . '/result';
$filters = new ezcImageImagemagickFilters( $this->handler );
- $filters->colorspace( ezcImageColorspaceFilters::COLORSPACE_GREY );
+ $filters->crop( 100, 75, -50, -37 );
$this->handler->save( $this->handler->getActiveReference(), $dstPath );
// echo "\n'".__FUNCTION__."' => '".md5_file( $dstPath )."',\n";
$this->assertEquals(
@@ -458,7 +433,7 @@
$filters = new ezcImageImagemagickFilters( $this->handler );
$filters->crop( 50, 75, 250, 38 );
$this->handler->save( $this->handler->getActiveReference(), $dstPath );
- // echo "\n'".__FUNCTION__."' => '".md5_file( $dstPath )."',\n";
+ echo "\n'".__FUNCTION__."' => '".md5_file( $dstPath )."',\n";
$this->assertEquals(
$this->expectedResults[__FUNCTION__],
md5_file( $dstPath ),
Modified: packages/ImageConversion/trunk/tests/handlergd_test.php
===================================================================
--- packages/ImageConversion/trunk/tests/handlergd_test.php 2006-01-13
11:06:24 UTC (rev 1816)
+++ packages/ImageConversion/trunk/tests/handlergd_test.php 2006-01-13
11:08:51 UTC (rev 1817)
@@ -196,7 +196,7 @@
$ref = $this->handler->load( $srcPath );
$this->handler->applyFilter( $ref, new ezcImageFilter( 'scale', array(
'width' => 200, 'height' => 200, 'direction' =>
ezcImageGeometryFilters::SCALE_BOTH ) ) );
- $this->handler->applyFilter( $ref, new ezcImageFilter( 'crop', array(
'xStart' => 50, 'xEnd' => 150, 'yStart' => 50, 'yEnd' => 150 ) ) );
+ $this->handler->applyFilter( $ref, new ezcImageFilter( 'crop', array(
'x' => 50, 'width' => 100, 'y' => 50, 'height' => 100 ) ) );
$this->handler->applyFilter( $ref, new ezcImageFilter( 'colorspace',
array( 'space' => ezcImageColorspaceFilters::COLORSPACE_SEPIA ) ) );
$this->handler->save( $ref, $dstPath );
Modified: packages/ImageConversion/trunk/tests/handlershell_test.php
===================================================================
--- packages/ImageConversion/trunk/tests/handlershell_test.php 2006-01-13
11:06:24 UTC (rev 1816)
+++ packages/ImageConversion/trunk/tests/handlershell_test.php 2006-01-13
11:08:51 UTC (rev 1817)
@@ -212,7 +212,7 @@
$ref = $this->handler->load( $srcPath );
$this->handler->applyFilter( $ref, new ezcImageFilter( 'scale', array(
'width' => 200, 'height' => 200, 'direction' =>
ezcImageGeometryFilters::SCALE_BOTH ) ) );
- $this->handler->applyFilter( $ref, new ezcImageFilter( 'crop', array(
'xStart' => 50, 'xEnd' => 150, 'yStart' => 50, 'yEnd' => 150 ) ) );
+ $this->handler->applyFilter( $ref, new ezcImageFilter( 'crop', array(
'x' => 50, 'width' => 100, 'y' => 50, 'height' => 100 ) ) );
$this->handler->applyFilter( $ref, new ezcImageFilter( 'colorspace',
array( 'space' => ezcImageColorspaceFilters::COLORSPACE_SEPIA ) ) );
$this->handler->save( $ref, $dstPath );
Modified: packages/ImageConversion/trunk/tests/transformation_test.php
===================================================================
--- packages/ImageConversion/trunk/tests/transformation_test.php
2006-01-13 11:06:24 UTC (rev 1816)
+++ packages/ImageConversion/trunk/tests/transformation_test.php
2006-01-13 11:08:51 UTC (rev 1817)
@@ -60,10 +60,10 @@
1 => new ezcImageFilter(
'crop',
array(
- 'xStart' => 10,
- 'xEnd' => 40,
- 'yStart' => 10,
- 'yEnd' => 40,
+ 'x' => 10,
+ 'width' => 30,
+ 'y' => 10,
+ 'height'=> 30,
)
),
2 => new ezcImageFilter(
@@ -119,10 +119,10 @@
1 => new ezcImageFilter(
'crop',
array(
- 'xStart' => 10,
- 'xEnd' => 40,
- 'yStart' => 10,
- 'yEnd' => 40,
+ 'x' => 10,
+ 'width' => 30,
+ 'y' => 10,
+ 'height'=> 30,
)
),
2 => new ezcImageFilter(
@@ -192,10 +192,10 @@
2 => new ezcImageFilter(
'crop',
array(
- 'xStart' => 10,
- 'xEnd' => 30,
- 'yStart' => 10,
- 'yEnd' => 30,
+ 'xStart' => 10,
+ 'xEnd' => 40,
+ 'yStart' => 10,
+ 'yEnd' => 40,
)
),
);
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components