Ho provato a utilizzare il seguente codice (non ricordo dove l'ho trovato), per estrarre le dimensioni in pixel di una immagine:
codice:strFoto = request.querystring("foto") strSez = request.querystring("sezione") 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 = "/public/" & strSez & "/" & strfoto Dimensione = ImageSize(Immagine) Response.Write "Larghezza: " & Dimensione(0) & " pixel" & " " Response.Write "Altezza: " & Dimensione(1) & " pixel"
ma il risultato e' alquanto strambo e inaffidabile su 10 immagini, solo 3 - 4 volte ci azzecca, per il resto sembrano numeri a caso, ben lontani dalle dimesioni reali.
qualcuno sa dirmi dove sbaglio, o come usarlo?
Ciao dot.

Rispondi quotando
