【问题标题】:Resize an Image and keeping Metadata/property item调整图像大小并保留元数据/属性项
【发布时间】:2009-06-27 05:42:38
【问题描述】:

.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 库来保留此解决方案。

【问题讨论】:

    标签: .net image metadata


    【解决方案1】:

    遍历 Image.PropertyItems 中的所有 property items 并将它们添加到新图像中。您可以找到如何使用此方法复制元数据的示例here

    【讨论】:

      猜你喜欢
      • 2021-08-26
      • 2011-04-01
      • 2013-08-20
      • 2013-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多