Add detection of image dimensions for images

fixes #612