How to get Width and Height of image in perspective

You can't determine the aspect ratio until the image is uploaded. If it's in a common format (PNG, GIF, JPG) then you can borrow from the technique from this post:

Specifically, the Toolkit.getDefaultToolkit().getImage() - once loaded through that mechanism, you can get the width and height of an image, and from there determine the aspect ratio.