In my web app, I have a screen where the users can upload their documents. I should allow the file formats of .pdf,jpg,png etc. I want the documents to be resized before they go in to the database. Having said that, I don't want to loose the quality of the file being resized.
Could you let me know the best way to do this?
Right now I am using this. It is resizing, but I am loosing the quality.
public byte resizeDocument(System.Drawing.Image image_file)
int image_height = image_file.Height;
int image_width = image_file.Width;
int max_height = 120;
int max_width = 160;
image_height = (image_height * max_width) / image_width;
image_width = max_width;
if (image_height > max_height)
image_width = (image_width * max_height) / image_height;
image_height = max_height;
Bitmap bitmap_file = new Bitmap(image_file, image_width, image_height);
System.IO.MemoryStream stream = new System.IO.MemoryStream();
stream.Position = 0;
byte data = new byte[stream.Length + 1];
stream.Read(data, 0, data.Length);