d3mon Posted June 15, 2008 Posted June 15, 2008 Hello Everybody, Can i have Width & Height of picture by FileOpenDialog ? Thanks No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE
JesseBarnett Posted June 15, 2008 Posted June 15, 2008 This thread should help:http://www.autoitscript.com/forum/index.php?showtopic=2523
d3mon Posted June 15, 2008 Author Posted June 15, 2008 This thread should help:http://www.autoitscript.com/forum/index.php?showtopic=2523Hum that's not what I wanted...AnyHelp ? No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE
ProgAndy Posted June 15, 2008 Posted June 15, 2008 OPen the image with GDIplus and use _GDIplus_ImageGetWidth / _GDIplus_ImageGetHeight. OPen/Close: _GDIplus_ImageLoadFromFile _GDIplus_ImageDispose *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
martin Posted June 15, 2008 Posted June 15, 2008 OPen the image with GDIplus and use _GDIplus_ImageGetWidth / _GDIplus_ImageGetHeight. OPen/Close: _GDIplus_ImageLoadFromFile _GDIplus_ImageDisposeI've just been trying to do just that and failed. My understanding of images and graphic objects is awful so this sort of thing could help me learn. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <staticconstants.au3> #include <gdiplus.au3> Const $SS_REALSIZEIMAGE = 0x800 #Region ### START Koda GUI section ### Form= $Form3 = GUICreate("Form3", 413, 298, 303, 219) $Pic1 = GUICtrlCreatePic("", 48, 16, 100, 100, BitOR($SS_NOTIFY,$SS_REALSIZEIMAGE,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $sFileName = FileOpenDialog("pic","\","jpg(*.jpg)");tried bmp but no better ConsoleWrite($sFileName & @CRLF) $hImage = _GDIPlus_ImageLoadFromFile($sFileName);AutoIt crashes ConsoleWrite("stage 1" & @CRLF) $ht = _GDIPlus_ImageGetHeight($hImage) ConsoleWrite("stage 2" & @CRLF) $wd = _GDIPlus_ImageGetWidth($hImage) ConsoleWrite($ht & ', ' & $wd & @CRLF) ;GUICtrlSetImage($pic1,$sFileName ) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Any suggestions? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
ProgAndy Posted June 15, 2008 Posted June 15, 2008 You need to enclose the GDI+ Functions between _GDIPlus_Startup() and _GDIPLus_ShutDown() *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
martin Posted June 15, 2008 Posted June 15, 2008 (edited) You need to enclose the GDI+ Functions between _GDIPlus_Startup() and _GDIPLus_ShutDown()Oh yes, thanks, I completely forgot about that. EDIT: Yup, works now. #include <gdiplus.au3> $sFileName = FileOpenDialog("pic","\","jpg(*.jpg)") _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sFileName) $ht = _GDIPlus_ImageGetHeight($hImage) $wd = _GDIPlus_ImageGetWidth($hImage) msgbox(262144,'Size of ' & $sFileName & ' is', $ht & ' x ' & $wd);ConsoleWrite($ht & ', ' & $wd & @CRLF) _GDIPlus_ImageDispose($hImage);added after reminder from progAndy _GDIPLus_ShutDown() EDIT 2: added _GDIPlus_ImageDispose($hImage) EDIT 3!: Moved _GDIPLus_ShutDown() to end of script. Edited June 15, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
ProgAndy Posted June 15, 2008 Posted June 15, 2008 Don't forget _GDIPlus_ImageDispose($hImage) ! *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
ResNullius Posted June 15, 2008 Posted June 15, 2008 (edited) This also works if you have the Windows Image Acqusition Library installedhttp://www.microsoft.com/downloads/details...lang=ennstalled #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <staticconstants.au3> Const $SS_REALSIZEIMAGE = 0x800 #Region ### START Koda GUI section ### Form= $Form3 = GUICreate("Form3", 413, 298, 303, 219) $Pic1 = GUICtrlCreatePic("", 48, 16, 100, 100, BitOR($SS_NOTIFY,$SS_REALSIZEIMAGE,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $sFileName = FileOpenDialog("pic","\","jpg(*.jpg)");tried bmp but no better ConsoleWrite($sFileName & @CRLF) $objImage = ObjCreate("WIA.ImageFile") $objImage.LoadFile ($sFileName) $ht = $objImage.Height $wd = $objImage.Width ConsoleWrite($ht & ', ' & $wd & @CRLF) GUICtrlSetImage($pic1,$sFileName ) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited June 15, 2008 by ResNullius
ProgAndy Posted June 15, 2008 Posted June 15, 2008 I think Windows Image Acqusition Library works with GDI+, too because it needs Win XP, where GDI+ is available too. So GDI+ is the better solution, you don't have to install any additional software *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
ResNullius Posted June 15, 2008 Posted June 15, 2008 Oh yes, thanks, I completely forgot about that. EDIT: Yup, works now. #include <gdiplus.au3> $sFileName = FileOpenDialog("pic","\","jpg(*.jpg)") _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sFileName) $ht = _GDIPlus_ImageGetHeight($hImage) $wd = _GDIPlus_ImageGetWidth($hImage) _GDIPLus_ShutDown() msgbox(262144,'Size of ' & $sFileName & ' is', $ht & ' x ' & $wd);ConsoleWrite($ht & ', ' & $wd & @CRLF) _GDIPlus_ImageDispose($hImage);added after reminder from progAndy EDIT 2: added _GDIPlus_ImageDispose($hImage)AutoIt crashes for me after the msgbox display...
martin Posted June 15, 2008 Posted June 15, 2008 Don't forget _GDIPlus_ImageDispose($hImage) !Of course I did. The benefit of not knowing much about something is that it should be easy to improve.Post now corrected, thanks again. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
JesseBarnett Posted June 15, 2008 Posted June 15, 2008 Anyway to use gdiplus or an alternative to get the info for a pdf? I have it working using the following code, but of course smaller would be better. $file = FileOpenDialog("Please select file", "", "Image files (*.jpg;*.tif;*.gif;*.bmp;*.png;*.pdf)"); RunWait("C:\Program Files\IrfanView\i_view32.exe " & $file & "/info=" & $file & ".txt") $dims = FileReadLine($file & ".txt", 6) $cnt = StringInStr($dims, "=") $dims = StringTrimLeft($dims, $cnt + 1) $cnt = StringInStr($dims, "P") $cnt = StringLen($dims) - $cnt $dims = StringTrimRight($dims, $cnt + 2) FileDelete($file & ".txt") MsgBox("","",$dims)
martin Posted June 15, 2008 Posted June 15, 2008 AutoIt crashes for me after the msgbox display... That's because I put the ImageDispose after the _GDIPLus_ShutDown(). Not having a good day with this one. Thanks ResNullius, I'll correct it again. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
ludocus Posted June 15, 2008 Posted June 15, 2008 This code is much smaller, although also much bigger : expandcollapse popup$sfile = @DesktopDir&'\pic.bmp' msgbox ( 0, 'width, height', 'width: '&_GetExtProperty($sfile, 27)&' height: '&_GetExtProperty($sfile, 27)) ;=============================================================================== ; Function Name: GetExtProperty($sPath,$iProp) ; Description: Returns an extended property of a given file. ; Parameter(s): $sPath - The path to the file you are attempting to retrieve an extended property from. ; $iProp - The numerical value for the property you want returned. If $iProp is is set ; to -1 then all properties will be returned in a 1 dimensional array in their corresponding order. ; The properties are as follows: ; Name = 0 ; Size = 1 ; Type = 2 ; DateModified = 3 ; DateCreated = 4 ; DateAccessed = 5 ; Attributes = 6 ; Status = 7 ; Owner = 8 ; Author = 9 ; Title = 10 ; Subject = 11 ; Category = 12 ; Pages = 13 ; Comments = 14 ; Copyright = 15 ; Artist = 16 ; AlbumTitle = 17 ; Year = 18 ; TrackNumber = 19 ; Genre = 20 ; Duration = 21 ; BitRate = 22 ; Protected = 23 ; CameraModel = 24 ; DatePictureTaken = 25 ; Dimensions = 26 ; Width = 27 ; Height = 28 ; Company = 30 ; Description = 31 ; FileVersion = 32 ; ProductName = 33 ; ProductVersion = 34 ; Requirement(s): File specified in $spath must exist. ; Return Value(s): On Success - The extended file property, or if $iProp = -1 then an array with all properties ; On Failure - 0, @Error - 1 (If file does not exist) ; Author(s): Simucal (Simucal@gmail.com) ; Note(s): ; ;=============================================================================== Func _GetExtProperty($sPath, $iProp) Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty $iExist = FileExists($sPath) If $iExist = 0 Then SetError(1) Return "No file loaded" Else $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) If $iProp = -1 Then Local $aProperty[35] For $i = 0 To 34 $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i) Next Return $aProperty Else $sProperty = $oDir.GetDetailsOf ($oFile, $iProp) If $sProperty = "" Then Return "None" Else Return $sProperty EndIf EndIf EndIf EndFunc ;==>_GetExtProperty
JesseBarnett Posted June 15, 2008 Posted June 15, 2008 Thanks Ludocus! I'll add it to my slowly expanding knowledge base.
d3mon Posted June 16, 2008 Author Posted June 16, 2008 (edited) Thanks everybody for your help but for witdth and height that wrote pixel but i don't know how to fix it... Edited June 16, 2008 by d3mon No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now