[thelist] tip
ashok at magicalkenya.com
ashok at magicalkenya.com
Thu Jun 13 10:27:00 CDT 2002
<tip type="Calculating dimensions of JPG and GIF files using VB" author
="Junglee">
When images are stored in a database table as blobs it makes sense to
calculate and store
the original dimensions of the image in the table. an upload program can
calculate the dimension
of the images , for e.g. in vb it could look like :
'--code begin
Dim header As String
Dim f As Integer
filename="c:\top_e.gif"
Open filename For Input As #f
If Lcase(Right(filename, 3))="gif" Then
header = Input(10, f)
Close #f
wHi = Mid(header, 8, 1)
wLo = Mid(header, 7, 1)
hHi = Mid(header, 10, 1)
hLo = Mid(header, 9, 1)
w = Asc(wHi) * 256 + Asc(wLo)
h = Asc(hHi) * 256 + Asc(hLo)
Elseif Lcase(Right(filename, 3))="jpg" Then
header = Input(167, f)
Close #f
wHi = Asc(Midbp(header, 166, 1))
wLo = Asc(Midbp(header, 167, 1))
hHi = Asc(Midbp(header, 164, 1))
hLo = Asc(Midbp(header, 165, 1))
w = (wHi) * 256 + (wLo)
h = (hHi) * 256 + (hLo)
End If
'--code end
</tip>
------
Ashok Hariharan
http://www.unganisha.org
Disclaimer : The contents of this mail should not be construed as a "if
you attack me, I'll blast your arse" veiled threat
------
More information about the thelist
mailing list