codice:
Function ImageSize(immagine)
Dimensione = Array("","")
Formato = Right(uCase(immagine), 3)
Select Case Formato
Case "JPG"
Start = 167
max = 4
xs = 3
xe = 4
ys = 1
ye = 2
Case "PNG"
Start = 24
max = 8
xs = 3
xe = 4
ys = 7
ye = 8
Case "GIF"
Start = 10
max = 4
xs = 2
xe = 1
ys = 4
ye = 3
Case "BMP"
Start = 24
max = 8
xs = 4
xe = 3
ys = 8
ye = 7
Case "WMF"
Start = 14
max = 4
xs = 2
xe = 1
ys = 4
ye = 3
End Select
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(Server.MapPath(immagine)) Then
Set ts = fso.OpenTextFile(Server.MapPath(immagine))
s = Right(ts.Read(Start), max)
if HexToDec(HexAt(s,xs) & HexAt(s,xe)) => HexToDec(HexAt(s,ys) & HexAt(s,ye)) then
if HexToDec(HexAt(s,xs) & HexAt(s,xe)) <= mx then
Dimensione(0) = HexToDec(HexAt(s,xs) & HexAt(s,xe))
Dimensione(1) = HexToDec(HexAt(s,ys) & HexAt(s,ye))
else
Dimensione(0) = mx
Dimensione(1) = HexToDec(HexAt(s,ys) & HexAt(s,ye)) * mx / HexToDec(HexAt(s,xs) & HexAt(s,xe))
end if
end if
if HexToDec(HexAt(s,xs) & HexAt(s,xe)) <= HexToDec(HexAt(s,ys) & HexAt(s,ye)) then
if HexToDec(HexAt(s,ys) & HexAt(s,ye)) <= mx then
Dimensione(0) = HexToDec(HexAt(s,xs) & HexAt(s,xe))
Dimensione(1) = HexToDec(HexAt(s,ys) & HexAt(s,ye))
else
Dimensione(0) = HexToDec(HexAt(s,xs) & HexAt(s,xe)) * mx / HexToDec(HexAt(s,ys) & HexAt(s,ye))
Dimensione(1) = mx
end if
end if
ts.Close
ImageSize = Dimensione
else
s = mx
Dimensione(0) = 0
Dimensione(1) = 0
ImageSize = Dimensione
end if
End Function
Function HexAt(s, n)
HexAt = Hex(Asc(Mid(s, n, 1)))
If Len(HexAt) = 1 Then HexAt = "0" & HexAt
End Function
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
la richiami con:
immagine="urlimmagine"
mx="dimensione a cui vuoi portare il lato piu grande"