Hi Per,
I think you just have a syntax error in the test:
javafx.scene.image.Image has a method named getHeight(), so you should access it as a property, for example "img$height". If you want to call the method directly, then you can write "img$getHeight()", but as the error message says, "typeof(img$height)" is "double", and not "function"
If you evaluate this script with the RenjinScriptEngine, the test won't actually be invoked: the test runner takes the additional step of looking for all defined variables of type function that start with "test." and then executes them with no arguments. That would explain why you were getting different results.
Best,
Alex