【问题标题】:VB.Net - Removing image.PropertyItems dataVB.Net - 删除 image.PropertyItems 数据
【发布时间】:2012-08-24 21:39:18
【问题描述】:

如何成功删除图像属性项?我尝试加载图像,然后使用 image.ProperyIdList 循环,然后调用 .RemovePropertyItem 然后将图像保存到新文件,但新文件仍然包含所有元数据。我还尝试将每个 propertyItem.value 的所有字节归零,但这会在我保存时导致通用 gdi+ 错误。我还尝试将图像推入内存流并返回,认为它会清除元数据。有什么想法吗?

【问题讨论】:

    标签: vb.net image metadata


    【解决方案1】:

    我能够通过使用下面的代码完成以下操作。它不是最快的,但它确实有效。我基本上剥离了我想要的元数据,然后为网络创建一个没有属性的新图像,从而确保个人数据不在照片中。

    Using img As Image = Image.FromFile(fileName)
                Using newImage As New Bitmap(img.Width, img.Height)
    
                    Using gr As Graphics = Graphics.FromImage(newImage)
                        gr.InterpolationMode = Drawing2D.InterpolationMode.Bilinear
                        gr.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height))
                    End Using
                    newImage.Save(newFileName)
                End Using
            End Using
    

    【讨论】:

    • 嗯,刚刚做了,但是注意到文件大小增加了大约 14k,只是为了那些后来的人......(保存后从 30.694 字节到 45,191 字节)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多