You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by jo...@apache.org on 2009/10/14 23:36:56 UTC
svn commit: r825296 -
/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/BasicImageRewriter.java
Author: johnh
Date: Wed Oct 14 21:36:55 2009
New Revision: 825296
URL: http://svn.apache.org/viewvc?rev=825296&view=rev
Log:
Update no_expand variable to mean "don't expand image size in either dimension, ever". This means that passing resize_h and resize_w along with no_expand=1, with an image having one dimension larger than the requested size, yields a proportionally scaled image, treating resize_X as a bounding box.
Modified:
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/BasicImageRewriter.java
Modified: incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/BasicImageRewriter.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/BasicImageRewriter.java?rev=825296&r1=825295&r2=825296&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/BasicImageRewriter.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/BasicImageRewriter.java Wed Oct 14 21:36:55 2009
@@ -143,7 +143,8 @@
ImageInfo imageInfo = Sanselan.getImageInfo(response.getResponse(), uri.getPath());
- if ("1".equals(request.getParam(PARAM_NO_EXPAND)) &&
+ boolean noExpand = "1".equals(request.getParam(PARAM_NO_EXPAND));
+ if (noExpand &&
imageInfo.getHeight() <= requestedHeight &&
imageInfo.getWidth() <= requestedWidth) {
// Don't do anything, since the current image fits within the bounding area.
@@ -194,6 +195,18 @@
int heightAfterStep1 = max(1, (int) (ratio * origHeight));
heightDelta = requestedHeight - heightAfterStep1;
+
+ if (noExpand) {
+ // No expansion requested: make sure not to expand the resulting image on either axis,
+ // even if both resize_[w,h] params are specified.
+ if (widthDelta == 0) {
+ requestedHeight = heightAfterStep1;
+ heightDelta = 0;
+ } else if (heightDelta == 0) {
+ requestedWidth = widthAfterStep1;
+ widthDelta = 0;
+ }
+ }
}
if (resizeQuality == null) {