# How to get Width and Height of image in perspective

**URL:** <https://forum.inductiveautomation.com/t/how-to-get-width-and-height-of-image-in-perspective/37853>\
**Category:** Ignition\
**Created:** [August 18, 2020, 1:21pm UTC](https://forum.inductiveautomation.com/t/how-to-get-width-and-height-of-image-in-perspective/37853 "2020-08-18T13:21:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 18, 2020, 4:24pm UTC](https://forum.inductiveautomation.com/t/how-to-get-width-and-height-of-image-in-perspective/37853/2 "2020-08-18T16:24:27Z")

</div>

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:

> [@Image Management Tool](http://forum.inductiveautomation.com/t/image-management-tool/37558/2):
>
> from java.awt import Toolkit from java.io import File from org.apache.commons.io import FilenameUtils from com.inductiveautomation.ignition.designer.gateway import DTGatewayInterface gi = DTGatewayInterface.instance filepath = system.file.openFile() if filepath is not None: name = File(filepath).name javaImage = Toolkit.defaultToolkit.getImage(filepath) gi.uploadImage(event.source, name, "Script uploaded image", FilenameUtils.getExtension(filepath), "", javaImage.width, javaImage.height, sy…

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.

---

_[View the full topic](https://forum.inductiveautomation.com/t/how-to-get-width-and-height-of-image-in-perspective/37853)._
