Kash
Dabei seit: 07.11.2002
Ort: Schopfheim
Alter: 41
Geschlecht:
|
Verfasst Mi 21.05.2008 15:47
Titel
|
|
|
da hätt ich was.
Function
Code: |
public function GetImageSize(ByVal strImagePath)
dim ImageType, arrImageDimensions(2), fso, file, s, ns, n
ImageType = lcase(Right(strImagePath, len(strImagePath) - instrrev(strImagePath, ".", -1)))
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile(strImagePath,1)
Select Case ImageType
Case "jpg", "jpeg"
file.Skip(2)
ns = file.Read(2)
Do While Not (ns = "ÿÀ" Or ns = "ÿÂ")
ns = file.Read(2)
n = HexToDec(HexAt(ns,1) & HexAt(ns,2))
n = n - 2
file.Skip(n)
ns = file.Read(2)
Loop
file.Skip(3)
s = file.Read(4)
arrImageDimensions(0) = HexToDec(HexAt(s,3) & HexAt(s,4))
arrImageDimensions(1) = HexToDec(HexAt(s,1) & HexAt(s,2))
Case "gif"
s = Right(file.Read(10),4)
arrImageDimensions(0) = HexToDec(HexAt(s,2) & HexAt(s,1))
arrImageDimensions(1) = HexToDec(HexAt(s,4) & HexAt(s,3))
case "bmp"
s = Right(file.Read(24), 8)
arrImageDimensions(0) = HexToDec(HexAt(s,4) & HexAt(s,3))
arrImageDimensions(1) = HexToDec(HexAt(s,8) & HexAt(s,7))
case "wmf"
s = Right(file.Read(14), 4)
arrImageDimensions(0) = HexToDec(HexAt(s,1) & HexAt(s,1))
arrImageDimensions(1) = HexToDec(HexAt(s,4) & HexAt(s,3))
case "png"
s = Right(file.Read(24), 8)
arrImageDimensions(0) = HexToDec(HexAt(s,3) & HexAt(s,4))
arrImageDimensions(1) = HexToDec(HexAt(s,7) & HexAt(s,8))
End Select
file.Close
Set file = Nothing
GetImageSize = arrImageDimensions
end function
private function HexAt(s, n)
HexAt = Hex(Asc(Mid(s, n, 1)))
if len(HexAt) = 1 then
HexAt = "0" & HexAt
end if
end function
private function HexToDec(cadhex)
Dim n, i, ch, decimal
decimal = 0
n = Len(cadhex)
For i=1 To n
decimal = decimal * 16
ch = Mid(cadhex, i, 1)
decimal = decimal + inStr("0123456789ABCDEFabcdef", ch) -1
Next
HexToDec = decimal
end function
|
Aufruf
Code: |
Path = Server.MapPath ("../pfad/" & rs("bildurl"))
arrImageDimensions = GetImageSize(Path)
Breite = arrImageDimensions(0)
Hoehe = arrImageDimensions(1)
|
hoffe es hilft dir
|
|