diff --git a/src/main/java/jvc/service/Toolbox.java b/src/main/java/jvc/service/Toolbox.java index e8eb0b8..ece7b70 100644 --- a/src/main/java/jvc/service/Toolbox.java +++ b/src/main/java/jvc/service/Toolbox.java @@ -63,7 +63,12 @@ public class Toolbox { } public static BigDecimal evalBig(String val, Map ctx, JsEngine js) { - return big(eval(val, ctx, js)); + final String resolved = eval(val, ctx, js); + try { + return empty(resolved) ? die("evalBig: error resolving value: '"+val+"'") : big(resolved); + } catch (NumberFormatException nfe) { + return evalBig(resolved, ctx, js); + } } public static BigDecimal evalBig(String val, Map ctx, JsEngine js, BigDecimal defaultValue) { diff --git a/src/test/resources/tests/test_scale.jvc b/src/test/resources/tests/test_scale.jvc index aee0e0c..20fd852 100644 --- a/src/test/resources/tests/test_scale.jvc +++ b/src/test/resources/tests/test_scale.jvc @@ -1,7 +1,7 @@ { "vars": [ {"name": "out_width", "value": "1024"}, - {"name": "out_height", "value": "768"} + {"name": "out_height", "value": "source.height / 2"} ], "assets": [ // wildcard matches multiple files, vid1_splits becomes a "list" asset. resolution is 320x240 @@ -17,8 +17,8 @@ "height": "out_height", // height of scaled asset. if omitted and width is present, height will be proportional // here we reference the `out_height` variable defined above in the `vars` array "validate": [{ - "comment": "expect output resolution of 1024x768", - "test": "output.width === 1024 && output.height === 768" + "comment": "expect output resolution of 1024x(source.height/2)", + "test": "output.width === 1024 && output.height === source.height/2" }] }, {