ciao,
uso questa funzione trovata sul forum per calcolare le dimensioni delle img che poi passo a un altra funzione js che mi apre una popup.
il problema è che a volte su alcune img mi calcola delle dimensioni completamente sballate....
ecco la funzione:
la foto e in jpg..se la importo im macromedia fireworks e poi la esporto senza fare niente mi funziona...che può essere... :master:codice:<% ' Calcolo le dim delle img da passare alla funzione js 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 = "/db_documents/images/products/"& prodotto.fields("image") Dimensione = ImageSize(Immagine) Dim w, h w = Dimensione(0) + 15 h = Dimensione(1) + 15 %>

Rispondi quotando
