> > Articoli
Ricavare le dimensioni di una immagine (.JPG - .GIF - .BMP)
<%
'##################################
'#Come ricavare la dimensione in
'#pixel di una immagine .jpg .gif
'#.bmp
'##################################
Dim Dimensione
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"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
End Select
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath(Immagine),1)
s = Right(ts.Read(start), max)
Dimensione(0) = hextodec(hexat(s,xs) & hexat(s,xe))
Dimensione(1) = hextodec(hexat(s,ys) & hexat(s,ye))
ts.Close
ImageSize = Dimensione
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
Immagine = "tuaimmagine.jpg" 'qui il path virtuale dell'immagine
Dimensione = ImageSize(Immagine)
Response.Write "Larghezza: " & Dimensione(0) & " pixel" & "<br>"
Response.Write "Altezza: " & Dimensione(1) & " pixel"
%>
 |
Copyright © 2001-2018 ASPCode.it
- Riproduzione vietata - v. 3.0
- Capitani Paolo - P.IVA: 03300740408
- Contact
|
 |