Ciao,
ho fatto una ricerca e se n'è gia parlato......ma almeno per quello che ho visto se eseguo un resize o si impostano le dimensioni o la qualità...e tutte e due contemporaneamente?
io, con l'aiuto del forum, ho fatto:
Sub Page_Load()
Dim width as Integer = 308
Dim height as Integer = 0
' ridimensiona l'immagine se specificato
Dim immagine as String = Server.mappath("images/"&request.QueryString("img"))
call ImgRedim(immagine, width, height)
End Sub
' Funzione di redim
Public Sub ImgRedim(immagine as String, width as Integer, height as Integer)
Dim bmp as System.Drawing.Bitmap = CType(System.Drawing.Image.FromFile(immagine), System.Drawing.Bitmap)
if height = 0 Then
height = Convert.ToInt32(width / bmp.Width * bmp.Height)
End if
' c'è da ridimensionare?
Dim miniaturabmp as New System.Drawing.Bitmap(bmp, width, height)
' salvo l'immagine con un nome temporaneo
if immagine.EndsWith(".jpg") Then
miniaturabmp.Save(Server.mappath("images/"&"tmp"&request.QueryString("img")), System.Drawing.Imaging.ImageFormat.Jpeg)
else
miniaturabmp.Save(Server.mappath("images/"&"tmp"&request.QueryString("img")), System.Drawing.Imaging.ImageFormat.Gif)
end if
' pulizia
bmp.Dispose()
miniaturabmp.Dispose()
'cancello il file originale
System.IO.File.delete(Server.mappath("images/"&request.QueryString("img")))
'"rinomino" il nuovo file usando il move
System.IO.File.move(Server.mappath("images/tmp"&request.QueryString("img")),Server.mappath("i mages/"&request.QueryString("img")))
End Sub
che funziona benissimo ma la qualità non è molto buona......
ecco come posso integrare questo script con il settaggio della qualità???
grazie in anticipo!!!!![]()