From: Alan H. <min...@us...> - 2004-12-31 07:13:38
|
Update of /cvsroot/gallery/gallery2/modules/imagemagick/test/phpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25631/imagemagick/test/phpunit Modified Files: ImEnvironments.inc ImageMagickToolkitTest.class Log Message: implement compress operation Index: ImEnvironments.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/imagemagick/test/phpunit/ImEnvironments.inc,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- ImEnvironments.inc 10 Nov 2004 02:10:00 -0000 1.9 +++ ImEnvironments.inc 31 Dec 2004 07:13:08 -0000 1.10 @@ -4,17 +4,17 @@ * * Gallery - a web based photo album viewer and editor * Copyright (C) 2000-2004 Bharat Mediratta - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -63,6 +63,9 @@ 'select-page' => array( 'convert' => array('%src%', '%dst%'), ), + 'compress' => array( + 'convert' => array('%src%', '%dst%'), + ), ); /* -------------------------------------------------------------------------- @@ -259,7 +262,7 @@ Where options include: -authenticate value decrypt image with this password - -channel type Red, Green, Blue, Opacity, Index, Cyan, Yellow, + -channel type Red, Green, Blue, Opacity, Index, Cyan, Yellow, Magenta, Black, or All -debug events display copious debugging information -define format:option Index: ImageMagickToolkitTest.class =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/imagemagick/test/phpunit/ImageMagickToolkitTest.class,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- ImageMagickToolkitTest.class 30 Dec 2004 23:10:27 -0000 1.43 +++ ImageMagickToolkitTest.class 31 Dec 2004 07:13:08 -0000 1.44 @@ -102,8 +102,6 @@ * */ function tearDown() { - global $gallery; - foreach ($this->_save as $key => $value) { $ret = GalleryCoreApi::setPluginParameter('module', 'imagemagick', $key, $value); if ($ret->isError()) { @@ -160,7 +158,8 @@ * @access private * @return object GalleryStatus */ - function _testOperation($mimeType, $operation, $src, $dst, $params, $namedParams) { + function _testOperation($mimeType, $operation, $src, $dst, $params, $namedParams, + $quality=null) { list ($ret, $outputMimeType) = $this->_toolkit->performOperation($mimeType, $operation, $src, $dst, $params); @@ -195,12 +194,14 @@ } if ($outputMimeType == 'image/jpeg' || $outputMimeType == 'image/png') { + if (!isset($quality)) { + $quality = '75'; + } foreach (array_keys($expected) as $key) { - $expected[$key] = array_merge(array('-quality', '75'), $expected[$key]); + $expected[$key] = array_merge(array('-quality', $quality), $expected[$key]); } } - global $_ImPlatformFiles; $this->assertEquals($expected, $this->_files[$dst]['operation'], $this->_currentEnvironment['path'] . " $operation " . implode(' ', $params)); @@ -302,6 +303,17 @@ return $this->failWithStatus($ret->wrap(__FILE__, __LINE__)); } + // Test compress + $this->_files['compressMe.jpg']['size'] = 250 << 10; + $gallery->_platform->_counter = 2; + $ret = $this->_testOperation('image/jpeg', 'compress', + 'compressMe.jpg', 'compressed.jpg', + array(150), + array(), 58); + if ($ret->isError()) { + return $this->failWithStatus($ret->wrap(__FILE__, __LINE__)); + } + list ($ret, $mimeType) = $this->_toolkit->performOperation('image/png', 'BOGUS', 'BOGUS', @@ -796,8 +808,6 @@ } function exec($cmd) { - global $gallery; - global $_ImPlatformFiles; list ($ret, $imageMagickPath) = GalleryCoreApi::getPluginParameter('module', 'imagemagick', 'path'); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); @@ -865,7 +875,6 @@ } function rename($oldName, $newName) { - global $_ImPlatformFiles; $oldBase = basename($oldName); $newBase = basename($newName); if (isset($this->_files[$oldBase])) { @@ -946,11 +955,20 @@ } function filesize($file) { - global $_ImPlatformFiles; $basename = basename($file); if ($basename == 'testProfile.jpg') { return 100000; } + if ($basename == 'compressed.jpg') { + switch ($this->_counter--) { + case 2: + return 200 << 10; + case 1: + return 100 << 10; + case 0: + return 150 << 10; + } + } if (isset($this->_files[$basename]['size'])) { return $this->_files[$basename]['size']; } @@ -965,7 +983,6 @@ } function unlink($path) { - global $_ImPlatformFiles; $baseName = basename($path); if (isset($this->_files[$baseName])) { unset($this->_files[$baseName]); |