Jump to content
Sign in to follow this  


Recommended Posts


is it possible to find the width and height of an image?

if yes can you show how it can be done please? ive been searching for like 2 days ...

Share this post

Link to post
Share on other sites

Do you need autoit to get the width and height of an image, or do you need the image width and height to add an image into a script?

if it's the latter case, then you can open the image in a paint program, most will give you the width and height.

To have autoit get the with and height, you might have to use a color of reference to find the top left corner add the coordinents to a variable, then find the top right corner and add to another variable and there is your width, then find your bottom left corner and add to a 3rd variable, the first and 3rd variable become the image height.

if it's from a web page, then you can probably have autoit search the source file for the image width and height as that info is in the html code.


or what John1 said

Edited by kaotkbliss



My Android cat and mouse game

We're gonna need another Timmy!

Share this post

Link to post
Share on other sites

im doing this.. but the msg box with the values is not displayed...

i need autoit to open an image (@DesktopDir & "\screenshot.jpg") then display its dimensions for example... 1024 by 768

#include <GDIPlus.au3>
#include <WinAPI.au3>

$hImage = @DesktopDir & "\screenshot.jpg"


Func _GDIPlus_ImageGetDimension($hImage)
    Local $aSize[2], $aResult

    $aResult = DllCall($ghGDIPDll, "uint", "GdipGetImageDimension", "hwnd", $hImage, "float*", 0, "float*", 0)
    If @error Then Return SetError(@error, @extended, -1)

    $GDIP_STATUS = $aResult[0]
    If $GDIP_STATUS Then Return -1

    $aSize[0] = $aResult[2]
    $aSize[1] = $aResult[3]
    MsgBox(1,"test",$aSize[0]&" - "&$aSize[1])

    Return $aSize

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.