Mehoron Posted April 26, 2011 Posted April 26, 2011 Hey Guys, So I'm trying to split a string into int's so I can run some math on the results. I've tried converting the strings using Int($string), but this simply returns zero, calling just $string will still give me the proper number. Could I be doing something wrong or is there a bug here. $tile_dimension = StringSplit(_GetFileProperty("C:\Image.jpg", "Dimensions"), " x ", 1) $tile_width = $tile_dimension[1] $tile_height = $tile_dimension[2] $number_of_tiles = $tile_width/64 Again I have already tried by doing $number_of_tiles = Int($tile_width), and $number_of_tiles returns 0.
wakillon Posted April 26, 2011 Posted April 26, 2011 Where did you find _GetFileProperty function ? AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
Mehoron Posted April 26, 2011 Author Posted April 26, 2011 Where did you find _GetFileProperty function ?
wakillon Posted April 26, 2011 Posted April 26, 2011 When i try #include <GetFileProperty.au3> $tile_dimension = StringSplit(_GetFileProperty("D:\Wallpapers\041_abstract-wallpapers.jpg", "Dimensions"), " x ", 1) $tile_width = $tile_dimension[1] ConsoleWrite ( "$tile_width : " & $tile_width & @Crlf ) $tile_height = $tile_dimension[2] ConsoleWrite ( "$tile_height : " & $tile_height & @Crlf ) $number_of_tiles = $tile_width/64 ConsoleWrite ( "$number_of_tiles : " & $number_of_tiles & @Crlf ) I get : $tile_width : 1440 $tile_height : 900 $number_of_tiles : 22.5 AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
Mehoron Posted April 26, 2011 Author Posted April 26, 2011 When i try #include <GetFileProperty.au3> $tile_dimension = StringSplit(_GetFileProperty("D:\Wallpapers\041_abstract-wallpapers.jpg", "Dimensions"), " x ", 1) $tile_width = $tile_dimension[1] ConsoleWrite ( "$tile_width : " & $tile_width & @Crlf ) $tile_height = $tile_dimension[2] ConsoleWrite ( "$tile_height : " & $tile_height & @Crlf ) $number_of_tiles = $tile_width/64 ConsoleWrite ( "$number_of_tiles : " & $number_of_tiles & @Crlf ) I get : $tile_width : 1440 $tile_height : 900 $number_of_tiles : 22.5 Alright, I'll try updating again. :-\
wakillon Posted April 26, 2011 Posted April 26, 2011 May be your pictures have no properties ? AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
Mehoron Posted April 26, 2011 Author Posted April 26, 2011 May be your pictures have no properties ?No like I said, I can return the strings properly as strings, so width will return the proper number, but if I try to do any math with what I get returned I get 0.Hmm, maybe there are some issues with property format in Vista?
wakillon Posted April 26, 2011 Posted April 26, 2011 (edited) Try number Function ! ( it returns the numeric representation of an expression )#include <GetFileProperty.au3> $tile_dimension = StringSplit(_GetFileProperty("D:\Wallpapers\041_abstract-wallpapers.jpg", "Dimensions"), " x ", 1) $tile_width = Number ( $tile_dimension[1] ) $tile_height = Number ( $tile_dimension[2] ) $number_of_tiles = Number ( $tile_width/64 ) Edited April 26, 2011 by wakillon AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
Mehoron Posted April 29, 2011 Author Posted April 29, 2011 Try number Function ! ( it returns the numeric representation of an expression ) #include <GetFileProperty.au3> $tile_dimension = StringSplit(_GetFileProperty("D:\Wallpapers\041_abstract-wallpapers.jpg", "Dimensions"), " x ", 1) $tile_width = Number ( $tile_dimension[1] ) $tile_height = Number ( $tile_dimension[2] ) $number_of_tiles = Number ( $tile_width/64 ) I've already tried int(str) and number(str) and neither work, infact when I try and output that directly to a MSG box I get 0. This is making me a sad panda. I will try and write it out to a file and see if windows is adding creepy spaces and parse it all out.
Mehoron Posted April 29, 2011 Author Posted April 29, 2011 I've already tried int(str) and number(str) and neither work, infact when I try and output that directly to a MSG box I get 0. This is making me a sad panda. I will try and write it out to a file and see if windows is adding creepy spaces and parse it all out.YEP! So windows vista is outputting a weird character in front of the property so I'm going to have to parse that out, good thing is it's just one character so it's not going to be too difficult.
guinness Posted April 29, 2011 Posted April 29, 2011 I know the answer Check here >> UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
UEZ Posted April 29, 2011 Posted April 29, 2011 If you need to get the dimension of a bitmap you can use GDI+ for example. Here a simple function: expandcollapse popup#include <GDIPlus.au3> Local $file = FileOpenDialog("Select an image", "", "(*.jpg;*.png;*.bmp;*.gif)") If @error Then Exit Local $aDimension = Get_Image_Dimension($file) If @error Then Exit MsgBox(16, "Error", "An error has occured!", 10) MsgBox(0, "Image Dimension", "Filename: " & $file & @LF & @LF & _ "Image Dimension:" & @LF & @LF & _ "Width: " & @TAB & $aDimension[0] & @LF & _ "Height: " & @TAB & $aDimension[1]& @LF & _ "DPI: " & @TAB & $aDimension[2] & "x" & $aDimension[3], 30) Exit ; #FUNCTION# ===================================================================================== ; Name...........: Get_Image_Dimension ; Description ...: Returns the dimension of an image from a file ; Syntax.........: Get_Image_Dimension($file) ; Parameters ....: $file - filename of the image ; Return value ..: Zero based array with the dimensions -> $iDim[0] = width, $iDim[1] = height, $iDim[2] = DPIx, $iDim[3] = DPIy ; Requirements ..: GDIPlus.au3 ; Author ........: UEZ ; Version .......: v0.60 build 2011-04-29 Beta ; ================================================================================================ Func Get_Image_Dimension($file) If Not FileExists($file) Then Return SetError(1, 0, False) Local $declared = 1, $iDim[4] If Not $ghGDIPDll Then _GDIPlus_Startup() $declared = 0 EndIf Local $hImage = _GDIPlus_ImageLoadFromFile($file) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hImage) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipGetImageDimension", "handle", $hImage, "float*", 0, "float*", 0) If @error Then Return SetError(@error, @extended, False) $iDim[0] = $aResult[2] $iDim[1] = $aResult[3] $aResult = DllCall($ghGDIPDll, "uint", "GdipGetDpiX", "handle", $hContext, "float*", 0) If @error Then Return SetError(@error, @extended, False) $iDim[2] = Round($aResult[2], 0) $aResult = DllCall($ghGDIPDll, "uint", "GdipGetDpiY", "handle", $hContext, "float*", 0) If @error Then Return SetError(@error, @extended, False) $iDim[3] = Round($aResult[2], 0) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_ImageDispose($hImage) If Not $declared Then _GDIPlus_Shutdown() Return $iDim EndFunc Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
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