views:

211

answers:

1

The .NET libraries do an excellent job at resizing images that look great:

Bitmap newImage = new Bitmap(newWidth, newHeight);
using (Graphics gr = Graphics.FromImage(newImage))
{
    gr.InterpolationMode = InterpolationMode.HighQualityBilinear;
    gr.DrawImage(srcImage, new Rectangle(0, 0, newWidth, newHeight));
}

One problem I'm having with the solutions I see online are that they strip out the metadata that is embedded inside these images. Is there a way to MOVE this data to the new image? Or use the original image and keep this data?

Ideally I'd like to keep this solution using only the built in .NET libraries from Microsoft if possible as well.

+2  A: 

Iterate through all property items in Image.PropertyItems and add them into new image. You can find a sample how to copy metadata using this methodique here.

arbiter