Jump to content

Retrieving image dimensions


Recommended Posts

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...