SizePics




Option Explicit

Public Sub JPEG_Size(strFile As String, lngHeight As Long, lngWidth As Long)
Dim intFileNumber As Integer
Dim C As Integer
Dim app0 As String
Dim L As Long
Dim S As String
intFileNumber = FreeFile
Open strFile For Binary As #intFileNumber
If Input$(1, #intFileNumber) <> Chr$(255) Then
Close #intFileNumber%
Exit Sub
End If

C = Asc(Input$(1, #intFileNumber))

If C <> &HD8 Then
Close #intFileNumber
Exit Sub
End If

app0$ = Input$(2, #intFileNumber)

Do
L = Asc(Input$(1, intFileNumber))
L = L * 256 + Asc(Input$(1, #intFileNumber))
S = Input$(L - 2, #intFileNumber)

If C = &HC0 Or C = &HC2 Then
lngWidth = Asc(Mid$(S, 4, 1))
lngWidth = lngWidth * 256 + Asc(Mid$(S, 5, 1))
lngHeight = Asc(Mid$(S, 2, 1))
lngHeight = lngHeight * 256 + Asc(Mid$(S, 3, 1))
End If
If Input$(1, #intFileNumber) <> Chr$(255) Then Exit Do
C% = Asc(Input$(1, #intFileNumber))
Loop While C <> &HD9

Close #intFileNumber
End Sub

Public Sub GIF_Size(strFile As String, lngHeight As Long, lngWidth As Long)
Dim intFileNumber As Integer
Dim A As String
intFileNumber = FreeFile
Open strFile For Binary As #intFileNumber

A = Input$(3, #intFileNumber)
If A = "GIF" Then
A = Input$(3, #intFileNumber)
lngWidth = Asc(Input$(1, #intFileNumber))
lngWidth = lngWidth + 256 * Asc(Input$(1, #intFileNumber))
lngHeight = Asc(Input$(1, #intFileNumber))
lngHeight = lngHeight + 256 * Asc(Input$(1, #intFileNumber))
End If
Close #intFileNumber
End Sub











( sizepics.html )- by Paolo Puglisi - Modifica del 17/12/2023