使用 JPEG 文件读取和修改"User Comment" vb.net



我有特定类型的JPEG文件,其中包含"User Comment"属性中的信息。

User Comment属性的ID为37510。

我要做的就是:

a)获取属性为text b)修改属性 c)设置修改后的属性

读取我想要的属性。

'Load the Imgae from the file system.
Dim image As Image = System.Drawing.Image.FromFile("Real_VRX_Image.jpg")
'The specific propertie item.
Dim propItem As PropertyItem = image.GetPropertyItem(37510)

这不起作用,因为"User Comment"似乎是一个字节数组。

'Display the Text of the "User Comment" (does not work...)
MessageBox.Show(propItem.Value.ToString)

我已经尝试使用这个函数,将字节数组转换为一个字符串,我可以编辑-但它只是创建垃圾。

Public Function ByteArrayToString(ByRef Barr() As Byte) As String
Return Convert.ToBase64String(Barr)
End Function

Thx

MsgBox(System.Text.Encoding.Unicode.GetString(propItem.Value))

最新更新