Ho questo script:
Se carico una img minore di 450px di larghezza è tutto ok, se invece ne carico una più grande finisce correttamente nell'if il problema che quando va a fare il ResizeAndSave finale (ultima riga) ottengo l'errore Parameter is not valid sulla prima riga della funzione ResizeAndSave che sarebbe: System.Drawing.Image bmpStream2 = System.Drawing.Image.FromStream(imgStr);codice:file1.PostedFile.SaveAs("c:/inetpub/wwwroot/miac/fotoup/1_" + nomefile); System.IO.FileStream file = new System.IO.FileStream("fotoup/1_" + nomefile, System.IO.FileMode.Open); System.Drawing.Image bmpStream = System.Drawing.Image.FromStream(file); object altezza = bmpStream.Height; object larghezza = bmpStream.Width; int w; int h; if (Convert.ToInt32(larghezza) > 450) { w = 450; h = ((450 * Convert.ToInt32(altezza)) / Convert.ToInt32(larghezza)); file.Close(); ResizeAndSave(file1.PostedFile.InputStream, w, h, "c:/inetpub/wwwroot/miac/fotoup/2_" + nomefile3); } w = 90; h = 90; ResizeAndSave(file1.PostedFile.InputStream, w, h, "c:/inetpub/wwwroot/miac/fotoup/3_" + nomefile2);

Rispondi quotando