Ho trovato questa classe su un sito... in teoria dovrebbe essere possibile ricavare altezza e larghezza di un'immagine...
ma in che modo??codice:<% Class dimImages Private w, h, strFile 'Inizializza opportunamente la classe Private Sub Class_Initialize() strFile = "" End Sub 'Termina e scarica tutti gli oggetti creati Private Sub Class_Terminate() strFile = "" End Sub 'Setta la larghezza del file Public Property Let Width(num) w = num End Property 'Restituisce la larghezza del file Public Property Get Width() Width = w End Property 'Setta altezza del file Public Property Let Height(num) h = num End Property 'Restituisce altezza del file Public Property Get Height() Height = h End Property 'Setta il file di origine dei dati Public Property Let File(str) strFile = str End Property 'Restituisce il file di origine dei dati Public Property Get File() File = strFile End Property 'Ricava dai file ASCII i bytes da leggere per le dimensioni Private Function readBytes(offset, numBytes) dim objFSO, objFile, objTextStream, buffer set objFSO = Server.CreateObject("Scripting.FileSystemObject") set objFile = objFSO.GetFile(Server.MapPath(Me.File)) fileSize = objFile.Size set objFile = Nothing set objTextStream = objFSO.OpenTextFile(Server.MapPath(Me.File), 1) If offset > 0 Then buffer = objTextStream.Read(offset - 1) End If If numBytes = -1 Then readBytes = objTextStream.Read(fileSize) Else readBytes = objTextStream.Read(numBytes) End If objTextStream.Close set objTextStream = Nothing set objFSO = Nothing End Function 'Converte valori esadecimali in numeri interi decimali Private Function decConvert(str, mode) If mode = 1 Then decConvert = CLng( Asc(Left(str, 1)) + (Asc(Right(str, 1)) * 256)) ElseIf mode = 2 Then decConvert = CLng( Asc(Right(str, 1)) + (Asc(Left(str, 1)) * 256)) End If End Function 'Setta le dimensioni corrette di altezza e larghezza del file grafico Private Function dimsImg() dim extImage extImage = Right(Me.File,3) Select Case extImage Case "gif" Me.Width = decConvert(readBytes(7, 2), 1) Me.Height = decConvert(readBytes(9, 2), 1) Case "bmp" Me.Width = decConvert(readBytes(19, 2), 1) Me.Height = decConvert(readBytes(23, 2), 1) Case "png" Me.Width = decConvert(readBytes(19, 2), 2) Me.Height = decConvert(readBytes(23, 2), 2) Case "jpg" buffer = readBytes(0, -1) fileSize = Len(buffer) target = chr(255) & chr(216) & chr(255) targetFound = InStr(buffer, target) If targetFound > 0 Then pos = targetFound + 2 endLoop = False Do While endLoop = False And pos < fileSize Do While Asc(Mid(buffer, pos, 1)) = 255 And pos < fileSize pos = pos + 1 Loop If Asc(Mid(buffer,pos,1))<192 Or Asc(Mid(buffer,pos,1))>195 Then markerSize = decConvert(Mid(buffer, pos + 1, 2), 2) pos = pos + markerSize + 1 Else endLoop = True End If Loop End If Me.Width = decConvert(Mid(buffer, pos + 6, 2), 2) Me.Height = decConvert(Mid(buffer, pos + 4, 2), 2) Case Else Exit Function End Select End Function 'Verifica se le dimensioni del file grafico rispettano i criteri passati Public Function verDimsImage(maxW, maxH) Call dimsImg() If Me.Width <= maxW And Me.Height <= maxH Then verDimsImage = True Else verDimsImage = False End If End Function End Class %>
qualcuno mi potrebbe postare un esempio?? io sto impazzendo!
ho provato a fare una cosa così:
ma non mi restituisce nullacodice:set DimeImmagine = new dimImages DimeImmagine.File = "immagini/Ricambi_1.jpg" response.Write(DimeImmagine.Height)![]()

Rispondi quotando
