Jump to content
Sign in to follow this  
suthers

Retrieving image dimensions

Recommended Posts

suthers

Hi All,

Is there a way to find the width & height in pixels of the image in a JPG file?

Shalom

Bill

Share this post


Link to post
Share on other sites
Malkey

Hi All,

Is there a way to find the width & height in pixels of the image in a JPG file?

Shalom

Bill

See:-

_GDIPlus_ImageLoadFromFile

_GDIPlus_ImageGetWidth

_GDIPlus_ImageGetHeight

Examples in help file.

Share this post


Link to post
Share on other sites
suthers

Great! Just what I need. I did search the help file, but obviously not using the right terms to find that. Thanks again. Bill

Share this post


Link to post
Share on other sites
NiVZ

If you want to avoid GDI, you can use this (modified from antoher script on this forum - sorry can't remember who's)

$PathToImage = "C:\Test.jpg"

$ImgDimensions = _GetImageDimensions($PathToImage)
Msgbox(0, "Image Dimensions", $ImgDimensions[0] & " x " & $ImgDimensions[1] & @CRLF)

Func _GetImageDimensions($sPath)
        $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
        $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
        $oShellApp = ObjCreate ("shell.application")
        $oDir = $oShellApp.NameSpace ($sDir)
        $oFile = $oDir.Parsename ($sFile)

        Dim $sProperty[2]
        $sProperty[0] = StringTrimRight($oDir.GetDetailsOf ($oFile, 27), 7)
        $sProperty[1] = StringTrimRight($oDir.GetDetailsOf ($oFile, 28), 7)
        
        If $sProperty = "" Then
            Return 0
        Else
            Return $sProperty
        EndIf
EndFunc

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.