I have found this piece of code, but it doesn't work. It does get the name correctly, it does open the file, it does read the bytes, but it does NOT return the values for height and width, with several JPEGs that I've tried.
Sub GetJpegDims(ByVal strFileName, ByRef lngHeight, ByRef lngWidth)
'on error resume next
Dim stmFile
set stmFile = server.createobject("ADODB.Stream")
Dim bytArr(256)
dim byt
Dim intPos
With stmFile
.Type = 1 'adTypeBinary
.Open
.LoadFromFile strFileName
.Position = 0
for intPos = 0 to 255
.position = intpos
bytArr(intPos) = ascb(.Read(1))
response.write(ascb(.Read(1)))
response.write(" ")
next
.Close
End With
Set stmFile = Nothing
For intPos = 0 To 255
If bytArr(intPos) = &HFF And bytArr(intPos + 1) >= &HC0 _
And bytArr(intPos + 1) <= &HCF Then
lngHeight = bytArr(intPos + 5) * 256 + bytArr(intPos + 6)
lngWidth = bytArr(intPos + 7) * 256 + bytArr(intPos + 8)
Exit For
End If
Next
End Sub
Dim h2, w2, fname
fname = Server.MapPath("img1.jpg")
Response.Write(fname)
Call GetJpegDims(fname,h2,w2)
Response.Write(h2+"<br>")
Response.Write(w2)
regards,
rydel n23