Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 72056 invoked from network); 8 Jul 2008 21:40:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Jul 2008 21:40:20 -0000 Received: (qmail 6141 invoked by uid 500); 8 Jul 2008 21:40:21 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 6031 invoked by uid 500); 8 Jul 2008 21:40:21 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 6021 invoked by uid 99); 8 Jul 2008 21:40:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2008 14:40:21 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2008 21:39:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 04B052388A22; Tue, 8 Jul 2008 14:39:30 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r674973 - in /cocoon/branches/BRANCH_2_1_X: src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java status.xml Date: Tue, 08 Jul 2008 21:39:29 -0000 To: cvs@cocoon.apache.org From: anathaniel@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080708213930.04B052388A22@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: anathaniel Date: Tue Jul 8 14:39:29 2008 New Revision: 674973 URL: http://svn.apache.org/viewvc?rev=674973&view=rev Log: ImageOp block: If parameter width or height in resize operation is zero, use the original image size. If both are zero, then handle as no-op. Set default values to zero to allow using that feature by leaving out the parameters. Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java cocoon/branches/BRANCH_2_1_X/status.xml Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java?rev=674973&r1=674972&r2=674973&view=diff ============================================================================== --- cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/blocks/imageop/java/org/apache/cocoon/reading/imageop/ResizeOperation.java Tue Jul 8 14:39:29 2008 @@ -40,11 +40,11 @@ public void setup( Parameters params ) throws ProcessingException { enabled = params.getParameterAsBoolean( prefix + "enabled", true); - height = params.getParameterAsInteger( prefix + "height", 200 ); + height = params.getParameterAsInteger( prefix + "height", 0 ); if( height < 0 ) { throw new ProcessingException( "Negative Height is not allowed: " + height ); } - width = params.getParameterAsInteger( prefix + "width", 300 ); + width = params.getParameterAsInteger( prefix + "width", 0 ); if( width < 0 ) { throw new ProcessingException( "Negative Width is not allowed: " + width ); } @@ -57,13 +57,17 @@ if( ! enabled ) { return image; } - if ( this.width == 0 && this.height == 0 ) { + + // If parameter width or height is zero, use the original image size. + // Therefore, if both are zero, the image is returned unchanged. + + if ( width == 0 && height == 0 ) { return image; } - double height = image.getHeight(); - double width = image.getWidth(); - double xScale = this.width / width; - double yScale = this.height / height; + + double xScale = width == 0 ? 1 : width / (double) image.getWidth(); + double yScale = height == 0 ? 1 : height / (double) image.getHeight(); + if (allowEnlarge || (xScale <= 1 && yScale <= 1)) { if( preserveRatio ) Modified: cocoon/branches/BRANCH_2_1_X/status.xml URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?rev=674973&r1=674972&r2=674973&view=diff ============================================================================== --- cocoon/branches/BRANCH_2_1_X/status.xml (original) +++ cocoon/branches/BRANCH_2_1_X/status.xml Tue Jul 8 14:39:29 2008 @@ -186,8 +186,10 @@ Starting with 2.1.12 the minimum required Java version will be 1.4.2. - - ImageOp block: Make resize a no-op if width and height are zero. + + ImageOp block: If parameter width or height in resize operation is zero, use the original image size. + If both are zero, then handle as no-op. Set default values to zero to allow using that feature by + leaving out the parameters. ImageOp block: Addition of "allow-enlarge" parameter to resize operation.