Hi,
I have an issue about EditableImage. I'm trying to resize images but i get some exceptions like "Image stream seems to be causing issues" or "The source of the image seems to be invalid".
It doesn't throw exceptions always. Only some images couse the error. For example I attached two image. Org is the original image. And the other is edited image.
Org gives error. When i edit in photoshop and resize width to 750px it works.
My code is here :
Thanks for your help.
I have an issue about EditableImage. I'm trying to resize images but i get some exceptions like "Image stream seems to be causing issues" or "The source of the image seems to be invalid".
It doesn't throw exceptions always. Only some images couse the error. For example I attached two image. Org is the original image. And the other is edited image.
Org gives error. When i edit in photoshop and resize width to 750px it works.
My code is here :
protected void btnAddImage_Click(object sender, System.EventArgs e) {
Stream StreamImage = flImage.PostedFile.InputStream; MemoryStream ms = new MemoryStream(); byte[] imgData = new byte[StreamImage.Length]; StreamImage.Read(imgData, 0, imgData.Length); ms.Write(imgData, 0, imgData.Length); SaveImage(ms, "g_" + PhotoID.ToString(), 610, 610); } void SaveImage(MemoryStream ms, string FileName, int Width, int Height) { try { EditableImage image = new EditableImage(ms); decimal oran = 0; Size s; if (!(Width > image.Width && Height > image.Height)) { if ((Width / Convert.ToDecimal(image.Width)) > (Height / Convert.ToDecimal(image.Height))) { //Height oran = Height / Convert.ToDecimal(image.Height); s = new Size(Convert.ToInt32(oran * image.Width), Convert.ToInt32(oran * image.Height)); } else { //Width oran = Width / Convert.ToDecimal(image.Width); s = new Size(Convert.ToInt32(oran * image.Width), Convert.ToInt32(oran * image.Height)); } image.Resize(s); } image.Image.Save(Server.MapPath(Settings["FolderPath"].ToString() + FileName + ".jpg"), System.Drawing.Imaging.ImageFormat.Jpeg); } catch (Exception ex) { throw ex; } }Thanks for your help.