Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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

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
×
×
  • Create New...