Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GDIPlus.au3>
- #include <MsgBoxConstants.au3>
- #include <Constants.au3>
- If $CmdLine[0] == 1 Then
- FindImageOfMaxWidthAndMaxHeight($CmdLine[1])
- EndIf
- Func FindImageOfMaxWidthAndMaxHeight($sPath)
- If Not FileExists($sPath) Then
- MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "Chyba", "Nesprávna cesta: " & $sPath)
- EndIf
- ; Assign a Local variable the search handle of all files in the current directory.
- Local $hSearch = FileFindFirstFile($sPath & "*.png")
- ; Check if the search was successful, if not display a message and return False.
- If $hSearch = -1 Then
- MsgBox($MB_SYSTEMMODAL, "Info", "Žiadny súbor PNG nebol nájdený.")
- Return False
- EndIf
- ; Assign a Local variable the empty string which will contain the files names found.
- Local $sFileName = "", $iResult = 0, $sFile
- Local $hImage, $iImgW, $iImgH, $fCount = 0, $fCountTested = 0, $maxW = 0, $maxH = 0, $sFileNameMaxW = "N/A", $sFileNameMaxH = "N/A"
- ; Initialize GDI+ library
- _GDIPlus_Startup()
- While 1
- $sFileName = FileFindNextFile($hSearch)
- ; If there is no more file matching the search.
- If @error Then ExitLoop
- $sFile = $sPath & $sFileName
- If FileExists($sFile) Then
- $hImage = _GDIPlus_ImageLoadFromFile($sFile)
- If $hImage <> -1 Then
- $iImgW = _GDIPlus_ImageGetWidth($hImage)
- $iImgH = _GDIPlus_ImageGetHeight($hImage)
- $fCountTested = $fCountTested + 1
- If $iImgW > $maxW Then
- $maxW = $iImgW
- $sFileNameMaxW = $sFileName
- EndIf
- If $iImgH > $maxH Then
- $maxH = $iImgH
- $sFileNameMaxH = $sFileName
- EndIf
- _GDIPlus_ImageDispose($hImage)
- EndIf
- EndIf
- $fCount = $fCount + 1
- WEnd
- ; Close the search handle.
- FileClose($hSearch)
- ; Shut down GDI+ library
- _GDIPlus_Shutdown()
- MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OK), "Max šírka a výška PNG", "Adresár: " & $sPath & @CRLF & "Počet obrázkov: " & $fCount & @CRLF & "Testovaných obrázkov: " & $fCountTested & @CRLF & "Max šírka: " & $maxW & " (" & $sFileNameMaxW & ")" & @CRLF & "Max výška: " & $maxH & " (" & $sFileNameMaxH & ")" )
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement