Sign in to follow this  
Followers 0
Info

Get picture size

9 posts in this topic

#1 ·  Posted (edited)

How can I get the size of a picture?

Edited by Info

Share this post


Link to post
Share on other sites



dimensions??

_GDIPlus_ImageGetHeight
_GDIPlus_ImageGetWidth

Share this post


Link to post
Share on other sites

http://dundats.mvps.org/AutoIt/udf_code.aspx?udf=filex

_File_Ext_PropertiesGet() function


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

dimensions??

_GDIPlus_ImageGetHeight
_GDIPlus_ImageGetWidth

Tried that, got an error. (-1)

#include <GDIPlus.au3>
$FileLoad = _GDIPlus_ImageLoadFromFile("C:\Documents and Settings\אלון\My Documents\sea_003.jpg")
$h = _GDIPlus_ImageGetHeight($FileLoad)
$w = _GDIPlus_ImageGetWidth($FileLoad)
MsgBox(0,"",$h&@CRLF&$w)

http://dundats.mvps.org/AutoIt/udf_code.aspx?udf=filex

_File_Ext_PropertiesGet() function

The returned value I get is 0.

$i = _File_Ext_PropertiesGet("Image.jpg","Size")
MsgBox(0,"",$i)

Func _File_Ext_PropertiesGet($sFile, $sDetail, $wName = 0)
   If NOT FileExists($sFile) Then
      If FileExists(FileGetShortName($sFile & ".lnk")) Then
         $sc = FileGetShortcut($sFile)
         $sFile = $sc[0]
      Else
         Return SetError(3, 3, "The file " & FileGetLongName($sFile) & " does not exist")
      EndIf
   EndIf
   $sFile = StringSplit($sFile, "\")
   Local $fName = $sFile[$sFile[0]], $Path = "", $All, $Dtl,  $Rtn = "", $I
   For $I = 1 To $sFile[0]-1
      $Path &= $sFile[$I] & "\"
   Next
   $objShell = ObjCreate("Shell.Application")
   Local $objFolder = $objShell.Namespace(StringTrimRight($Path, 1))
   Switch $sDetail
      Case "Name"
         $Dtl = 0
      Case "Size"
         $Dtl = 1
      Case "Type"
         $Dtl = 2
      Case "Status"
         $Dtl = 7
      Case "Owner"
         $Dtl = 8
      Case "Author"
         $Dtl = 9
      Case "Title"
         $Dtl = 10
      Case "Subject"
         $Dtl = 11
      Case "Category"
         $Dtl = 12
      Case "Pages"
         $Dtl = 13
      Case "Comments"
         $Dtl = 14
      Case "Copyright"
         $Dtl = 15
      Case "Artist"
         $Dtl = 16
      Case "Album Title"
         $Dtl = 17
      Case "Year"
         $Dtl = 18
      Case "Track Number"
         $Dtl = 19
      Case "Genre"
         $Dtl = 20
      Case "Duration"
         $Dtl = 21
      Case "Bit Rate"
         $Dtl = 22
      Case "Protected"
         $Dtl = 23
      Case "Camera"
         $Dtl = 24
      Case "Date Taken"
         $Dtl = 25
      Case "Dimensions"
         $Dtl = 26
      Case "Episode"
         $Dtl = 29
      Case "Company"
         $Dtl = 30
      Case "Description"
         $Dtl = 30
      Case "File Version", "Sample Size"
         $Dtl = 32
      Case "Product Name", "Sample Rate"
         $Dtl = 33
      Case "Product Version", "Audio Channels"
         $Dtl = 34
      Case "All"
         $All = StringSplit("0,1,2,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,29,30,32,33,34", ",")
      Case Else
         Return SetError(1, 1, "Unrecognized property")
   EndSwitch
   If NOT IsArray($All) Then
      For $Filename In $objFolder.Items
         If $objFolder.GetDetailsOf($Filename, 0) = $fName Then
            $Rtn = $objFolder.GetDetailsOf($Filename, $Dtl)
            If $Rtn = "" Then Return SetError(2, 2, "Property " & $objFolder.GetDetailsOf($objFolder.Items, $Dtl) & " is unknown for this file")
            If $wName <> 0 Then $Rtn = $objFolder.GetDetailsOf($objFolder.Items, $Dtl) & " : " & $Rtn
            Return String($Rtn)
         EndIf
      Next
   Else
      For $Filename In $objFolder.Items
         If $objFolder.GetDetailsOf($Filename, 0) = $fName Then
            For $I = 1 TO $All[0]
               If $objFolder.GetDetailsOf($Filename, $All[$i]) = "" Then ContinueLoop
               $Rtn &= $objFolder.GetDetailsOf($objFolder.Items, $All[$i]) & " : " & $objFolder.GetDetailsOf($Filename, $All[$I]) & @CRLF
            Next
         EndIf
      Next
      Return StringStripWS($Rtn, 2)
   EndIf
EndFunc   ;;<==>_File_Ext_PropertiesGet()

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$i = _File_Ext_PropertiesGet("C:\Full\Path\To\Image.jpg","Dimensions")

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

If you want to use gdip functions you have to call _GDIPlus_Startup() first.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

$i = _File_Ext_PropertiesGet("C:\sea_003.jpg","Dimensions") 
MsgBox(0,"",$i)

Still not working. >_<

Share this post


Link to post
Share on other sites

#include <GDIPlus.au3>

$PATH = FileOpenDialog("Select",@ScriptDir,"Pictures (*.bmp;*.jpg;*.png)",1)
If Not @error Then
    _GDIPlus_Startup()
    $IMG = _GDIPlus_ImageLoadFromFile($PATH)
    $W = _GDIPlus_ImageGetWidth($IMG)
    $H = _GDIPlus_ImageGetHeight($IMG)
    _GDIPlus_ImageDispose($IMG)
    _GDIPlus_Shutdown()
    MsgBox(0,$PATH,$W & @CRLF & $H)
EndIf


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Thanks. >_

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  
Followers 0