Advertisement
Guest User

Untitled

a guest
Sep 29th, 2014
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.13 KB | None | 0 0
  1. #include <GDIPlus.au3>
  2. #include <MsgBoxConstants.au3>
  3. #include <Constants.au3>
  4.  
  5. If $CmdLine[0] == 1 Then
  6.    FindImageOfMaxWidthAndMaxHeight($CmdLine[1])
  7. EndIf
  8.  
  9. Func FindImageOfMaxWidthAndMaxHeight($sPath)
  10.     If Not FileExists($sPath) Then
  11.        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "Chyba", "Nesprávna cesta: " & $sPath)
  12.     EndIf
  13.  
  14.     ; Assign a Local variable the search handle of all files in the current directory.
  15.     Local $hSearch = FileFindFirstFile($sPath & "*.png")
  16.  
  17.     ; Check if the search was successful, if not display a message and return False.
  18.     If $hSearch = -1 Then
  19.         MsgBox($MB_SYSTEMMODAL, "Info", "Žiadny súbor PNG nebol nájdený.")
  20.         Return False
  21.     EndIf
  22.  
  23.     ; Assign a Local variable the empty string which will contain the files names found.
  24.     Local $sFileName = "", $iResult = 0, $sFile
  25.     Local $hImage, $iImgW, $iImgH, $fCount = 0, $fCountTested = 0, $maxW = 0, $maxH = 0, $sFileNameMaxW = "N/A", $sFileNameMaxH = "N/A"
  26.  
  27.     ; Initialize GDI+ library
  28.     _GDIPlus_Startup()
  29.  
  30.     While 1
  31.         $sFileName = FileFindNextFile($hSearch)
  32.         ; If there is no more file matching the search.
  33.         If @error Then ExitLoop
  34.  
  35.         $sFile = $sPath & $sFileName
  36.  
  37.         If FileExists($sFile) Then
  38.               $hImage = _GDIPlus_ImageLoadFromFile($sFile)
  39.  
  40.               If $hImage <> -1 Then
  41.                  $iImgW  = _GDIPlus_ImageGetWidth($hImage)
  42.                  $iImgH  = _GDIPlus_ImageGetHeight($hImage)
  43.                  $fCountTested = $fCountTested + 1
  44.  
  45.                  If $iImgW > $maxW Then
  46.                     $maxW = $iImgW
  47.                     $sFileNameMaxW = $sFileName
  48.                  EndIf
  49.  
  50.                  If $iImgH > $maxH Then
  51.                     $maxH = $iImgH
  52.                     $sFileNameMaxH = $sFileName
  53.                  EndIf
  54.  
  55.                 _GDIPlus_ImageDispose($hImage)
  56.               EndIf
  57.         EndIf
  58.  
  59.         $fCount = $fCount + 1
  60.     WEnd
  61.  
  62.     ; Close the search handle.
  63.     FileClose($hSearch)
  64.  
  65.     ; Shut down GDI+ library
  66.     _GDIPlus_Shutdown()
  67.  
  68.     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 & ")" )
  69.  
  70. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement