cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anathan...@apache.org
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 GMT
Author: anathaniel
Date: Tue Jul  8 14:39:29 2008
New Revision: 674973

URL: http://svn.apache.org/viewvc?rev=674973&view=rev
Log:
    <action dev="AN" type="fix" fixes-bug="COCOON-2169" due-to="Mark Lundquist" due-to-email="lundquist.mark@gmail.com">
      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.
    </action>

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 @@
     <action dev="all" type="update">
       Starting with 2.1.12 the minimum required Java version will be 1.4.2.
     </action>
-    <action dev="AN" type="fix" fixes-bug="COCOON-2177" due-to="Mark Lundquist" due-to-email="lundquist.mark@gmail.com">
-      ImageOp block: Make resize a no-op if width and height are zero.
+    <action dev="AN" type="fix" fixes-bug="COCOON-2169" due-to="Mark Lundquist" due-to-email="lundquist.mark@gmail.com">
+      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.
     </action>
     <action dev="AN" type="add" fixes-bug="COCOON-2133" due-to="Robin Wyles" due-to-email="reb@robinwyles.com">
       ImageOp block: Addition of "allow-enlarge" parameter to resize operation.



Mime
View raw message