#include <Array.au3>
#include <Binary.au3>;http://www.autoitscript.com/forum/topic/131037-binary-udf/ ;эту библиотеку надо скачать и положить в папку ...\AutoIt3\Include
$bChecJPG = Binary('0xFFD8')
$bSearchSOF0 = Binary('0xFFC0')
Dim $aJPG[5][2] = [[4],['Bit', 1],['Height', 2],['Width', 2],['All Comp', 1]]
Dim $aComp[7] = ['', 'Num Comp', 'H', 'V', 'Num Table Quant', 'H_max', 'V_max']
$iStart = 1
$iH_max = 0
$iV_max = 0
$sFile = @ScriptDir & '\1_Test.jpg'
;$sFile = @ScriptDir & '\msn.jpg'
$h_File = FileOpen($sFile, 16)
If FileRead($h_File, 2) <> $bChecJPG Then
ConsoleWrite('No JPG' & @LF)
FileClose($h_File)
Exit
EndIf
$bRead = FileRead($h_File);если файл большой, можно блоками читать
FileClose($h_File)
$iPos = _BinaryInBin($bRead, $bSearchSOF0, 1)
If $iPos Then
$aJPG[0][1] = Dec(Hex(BinaryMid($bRead, $iPos + 2, 2)))
$bSOF0 = BinaryMid($bRead, $iPos + 4, $aJPG[0][1] - 2)
$bRead = 0
For $i = 1 To $aJPG[0][0]
$aJPG[0][1] = $aJPG[$i][1]
$aJPG[$i][1] = Dec(Hex(BinaryMid($bSOF0, $iStart, $aJPG[$i][1])))
$iStart += $aJPG[0][1]
Next
$aJPG[0][1] = $aJPG[$aJPG[0][0]][1]
ReDim $aJPG[$aJPG[0][0] + $aJPG[0][1] * 4 + 3][2]
For $j = 1 To $aJPG[0][1]
For $i = 1 To 3
$aJPG[0][0] += 1
Switch $i
Case 1
$aJPG[$aJPG[0][0]][0] = $aComp[$i]
$aJPG[$aJPG[0][0]][1] = Dec(Hex(BinaryMid($bSOF0, $iStart, 1)))
Case 2
$iPos = Hex(BinaryMid($bSOF0, $iStart, 1))
$aJPG[$aJPG[0][0]][0] = $aComp[$i] & $j
$aJPG[$aJPG[0][0]][1] = Number(StringLeft($iPos, 1))
If $iH_max < $aJPG[$aJPG[0][0]][1] Then $iH_max = $aJPG[$aJPG[0][0]][1]
$aJPG[0][0] += 1
$aJPG[$aJPG[0][0]][0] = $aComp[$i + 1] & $j
$aJPG[$aJPG[0][0]][1] = Number(StringRight($iPos, 1))
If $iV_max < $aJPG[$aJPG[0][0]][1] Then $iV_max = $aJPG[$aJPG[0][0]][1]
Case 3
$aJPG[$aJPG[0][0]][0] = $aComp[$i + 1]
$aJPG[$aJPG[0][0]][1] = Dec(Hex(BinaryMid($bSOF0, $iStart, 1)))
EndSwitch
$iStart += 1
Next
Next
EndIf
$aJPG[0][0] += 2
$aJPG[$aJPG[0][0] - 1][0] = $aComp[5]
$aJPG[$aJPG[0][0] - 1][1] = $iH_max
$aJPG[$aJPG[0][0]][0] = $aComp[6]
$aJPG[$aJPG[0][0]][1] = $iV_max
$iH_max = 0
$iV_max = 0
$aJPG[0][1] = ''
_ArrayDisplay($aJPG, 'SOF0')