.NET 库在调整图像大小方面做得非常出色,看起来很棒:
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));
}
我在网上看到的解决方案遇到的一个问题是,它们删除了嵌入这些图像中的元数据。有没有办法将此数据移动到新图像?或者使用原始图像并保留这些数据?
理想情况下,如果可能的话,我希望仅使用 Microsoft 的内置 .NET 库来保留此解决方案。
最佳答案
迭代所有 property items在 Image.PropertyItems 中并将它们添加到新图像中。您可以找到如何使用此方法复制元数据的示例 here .
关于.net - 调整图像大小并保留元数据/属性项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1050936/