Author: michiel
Date: 2009-07-06 23:55:03 +0200 (Mon, 06 Jul 2009)
New Revision: 36599
Modified:
mmbase/trunk/applications/resources/src/main/java/org/mmbase/util/images/Imaging.java
mmbase/trunk/applications/resources/src/main/java/org/mmbase/util/images/NodeReceiver.java
Log:
The 'trim' option of imagemagick makes dimension prediction fundamentely
impossible. Acknowledged this in the code.
Modified:
mmbase/trunk/applications/resources/src/main/java/org/mmbase/util/images/Imaging.java
===================================================================
---
mmbase/trunk/applications/resources/src/main/java/org/mmbase/util/images/Imaging.java
2009-07-06 21:46:59 UTC (rev 36598)
+++
mmbase/trunk/applications/resources/src/main/java/org/mmbase/util/images/Imaging.java
2009-07-06 21:55:03 UTC (rev 36599)
@@ -172,6 +172,8 @@
*
* Probably because of different rounding strategies, there is sometimes a
difference of one or
* two pixels beteen the prediction and/or the result of ImageMagick
and/or JAI.
+ * @return A reasonable prediction of the new dimension or
<code>Dimension.UNDETERMINED</code> if that really is
+ * not possible
*/
public static Dimension predictDimension(Dimension originalSize,
List<String> params) {
@@ -295,6 +297,14 @@
dim.x = x2 - x1;
dim.y = y2 - y1;
}
+ } else {
+ // options without arguments
+
+ if (key.equals("trim")) {
+ // This requires information about the content of the image
+ log.service("Trimming makes the dimension impossible to
predict " + params);
+ return Dimension.UNDETERMINED;
+ }
}
}
Modified:
mmbase/trunk/applications/resources/src/main/java/org/mmbase/util/images/NodeReceiver.java
===================================================================
---
mmbase/trunk/applications/resources/src/main/java/org/mmbase/util/images/NodeReceiver.java
2009-07-06 21:46:59 UTC (rev 36598)
+++
mmbase/trunk/applications/resources/src/main/java/org/mmbase/util/images/NodeReceiver.java
2009-07-06 21:55:03 UTC (rev 36599)
@@ -58,16 +58,15 @@
}
public void setDimension(Dimension dim) {
Dimension predicted = (Dimension)
icacheNode.getFunctionValue("dimension", null);
- if (log.isDebugEnabled()) {
+ if (! predicted.equals(Dimension.UNDETERMINED)) {
if (! predicted.equals(dim)) {
log.warn("Predicted dimension " + predicted + " was not equal
to resulting dimension " + dim + " for icache " + icacheNode);
+ } else {
+ if (! predicted.equalsIgnoreRound(dim, 1)) {
+ log.warn("Predicted dimension " + predicted + " was not
equal to resulting dimension " + dim + " for icache " + icacheNode);
+ }
}
}
- else {
- if (! predicted.equalsIgnoreRound(dim, 1)) {
- log.warn("Predicted dimension " + predicted + " was not equal
to resulting dimension " + dim + " for icache " + icacheNode);
- }
- }
icacheNode.setValue("height", dim.y);
icacheNode.setValue("width", dim.x);
}
@@ -93,4 +92,4 @@
public String toString() {
return icacheNode.getStringValue("id") + " --> " +
icacheNode.getNumber() + " " + icacheNode.getStringValue(Imaging.FIELD_CKEY);
}
-}
\ No newline at end of file
+}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs