esiste una funzione che mi permetta di ottenere le dimensioni width e height di un immagine??
esiste una funzione che mi permetta di ottenere le dimensioni width e height di un immagine??
sì, e si chiamano proprio width e heghtOriginariamente inviato da maurizio127
esiste una funzione che mi permetta di ottenere le dimensioni width e height di un immagine??![]()
Pietro
ok... ma come si applica??
io ho una serie di immagini. devo controllare le due dimensioni.
in più devo capire se il file esiste oppure no.
ho provato così:
path = "http://nomesito.it/immagine.jpg"
Dim fs
fs = Server.CreateObject("Scripting.FileSystemObject")
If fs.FileExists(path) Then
Response.Write("il file esiste")
Else
Response.Write("Il file non esiste")
End If
fs = Nothing
ma l'istruzione if da sempre falso anche se il file esiste... sbaglio qualcosa??
codice:Dim f As String = "C:\dati\Prove Nicon\DSCN0014.JPG" If File.Exists(f) Then Dim bmp As New Bitmap(f) Response.Write(String.Format("Width = {0}, Height = {1}", bmp.Width, bmp.Height)) bmp.Dispose() End If
Pietro
ho copiato il codice che hai scritto sulla mia pagina e gli errori che mi da sono:
1) nome File non dichiarato
2) tipo Bitmap non definito
Dim f As String = "C:\dati\Prove Nicon\DSCN0014.JPG"
If File .Exists(f) Then
Dim bmp As New Bitmap (f)
Response.Write(String.Format("Width = {0}, Height = {1}", bmp.Width, bmp.Height))
bmp.Dispose()
End If
codice:Option Strict On Imports System.IO Imports System.Drawing Partial Class prove_a Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim f As String = "C:\dati\Prove Nicon\DSCN0014.JPG" If File.Exists(f) Then Dim bmp As New Bitmap(f) Response.Write(String.Format("Width = {0}, Height = {1}", bmp.Width, bmp.Height)) bmp.Dispose() End If End Sub End Class
Pietro
all'interno di visual web developer ho provato a copiare quello che mi scritto, ma è tutto un errore!! Option Strict On, Imports, Partial, Protected Sub, Inherits e anche Bitmap e File!!!
non so come fare!
questo è fatto col notepad, se non va, ci sono altri problemicodice:<html> <body> <% Dim f As String = "C:\dati\Prove Nicon\DSCN0014.JPG" If System.IO.File.Exists(f) Then Dim bmp As New System.Drawing.Bitmap(f) Response.Write(String.Format("Width = {0}, Height = {1}", bmp.Width, bmp.Height)) bmp.Dispose() End If %> </body> </html>![]()
Pietro
così non mi da nessun errore, però c'è un però:
io ho cambiato il percorso della foto con una cosa tipo "http://www.miosito.it/immagine.jpg"
e pur esistendo il file non esegue l'if.... per caso ci voglio permessi sulla cartella per scrittura?