Hello Kim,
Could you try JA following:
// BEGIN USER CODE
try {
if (img == null)
throw new Exception("Image was be null.");
InputStream is = Core.getFileDocumentContent(getContext(), __img);
BufferedImage bimg = ImageIO.read(is);
int width = bimg.getWidth();
int height = bimg.getHeight();
ImageDimension imgDimension = new ImageDimension(getContext());
imgDimension.setWidth(width);
imgDimension.setHeight(height);
return imgDimension.getMendixObject();
} catch (Exception e) {
throw new com.mendix.systemwideinterfaces.MendixRuntimeException(e);
}
// END USER CODE
Note: The "__img" is IMendixObject.