asp - asp.net - aspcode.it

COMMUNITY - Login
 Username:
 
 Password:
 
Voglio registrarmi!
Password dimenticata?
 Utenti on-line: 0
 Ospiti on-line: 60359
ASPCode.it - Store

  > > Articoli

Ricavare le dimensioni di una immagine (.JPG - .GIF - .BMP)

Data di pubblicazione: 15/03/2002        Voto della community: 3,85 (Votanti: 20)

<%
'##################################
'#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"
%>




Utenti connessi: 60359