I have to re size an existing image and with proper width and height.
for now this is the code I have the code like this
Image resized = ResizeImageForFull(original, new Size(768, 1024));
//save the image to memory stream
MemoryStream memStream = new MemoryStream();
resized.Save(memStream, System.Drawing.Imaging.ImageFormat.Jpeg)
after getting the modified image it is saved to the memory stream. can any one help me to put that into a target folder to save it as a jpeg image.
public static Image ResizeImageForFull(Image image, Size size, bool preserveAspectRatio = true)
{
int newWidth=0;
int newHeight=0;
if (preserveAspectRatio)
{
newWidth = size.Width;
newHeight = size.Height;
}
Image newImage = new Bitmap(newWidth, newHeight);
using (Graphics graphicsHandle = Graphics.FromImage(newImage))
{
graphicsHandle.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphicsHandle.DrawImage(image, 0, 0, newWidth, newHeight);
}
return newImage;
}