Option Explicit Public Sub Datei_Auswahl() Dim strDatei As String Dim strDummy As String Dim ff As Integer Dim c As Integer Dim S As String Dim L As Long Dim JPGWidth As Long Dim JPGHeight As Long With Application.FileDialog(msoFileDialogFilePicker) .InitialFileName = "C:\" .Title = "Dateiauswahl" .ButtonName = "Auswahl..." .Filters.Add "JPG-Dateien", "*.jpg; *.jpeg", 1 .InitialView = msoFileDialogViewList If .Show = -1 Then strDatei = .SelectedItems(1) Else MsgBox "Es wurde keine Datei ausgewaehlt!" Exit Sub End If End With ff = FreeFile() Open strDatei For Binary Access Read As #ff If Input(2, #ff) <> (Chr$(&HFF) & Chr$(&HD8)) Then Close #ff Exit Sub End If strDummy = Input(2, #ff) Do L = Asc(Input(1, #ff)) L = L * 256 + Asc(Input(1, #ff)) S = Input(L - 2, #ff) If c = &HC0 Or c = &HC2 Then JPGWidth = Asc(Mid$(S, 4, 1)) JPGWidth = JPGWidth * 256 + Asc(Mid$(S, 5, 1)) JPGHeight = Asc(Mid$(S, 2, 1)) JPGHeight = JPGHeight * 256 + Asc(Mid$(S, 3, 1)) End If If Input(1, #ff) <> Chr$(255) Then Exit Do End If c = Asc(Input(1, #ff)) Loop While c <> &HD9 Close #ff MsgBox "Die Grafik " & strDatei & " ist " & vbNewLine & _ CStr(JPGWidth) & " Pixel breit und " & vbNewLine & _ CStr(JPGHeight) & " Pixel hoch.", _ vbInformation, "JPG-Analyse" End Sub
58.4k Fragen
249k Antworten
7k Nutzer