在 C# / VB.NET 中将 EXIF 元数据从 TIF 复制到 JPEG
如果您能阐明这个问题,我将不胜感激。 我有 2 个图像,一个是从带有元数据的 TIF 文件创建的,另一个是内存中图像,将保存为 jpeg。 然后我使用这个例程将 exif 元数据从第一个图像传输到第二个图像(即从 tif 文件创建的图像到内存中图像):
For Each _p In image1.PropertyItems
image2.SetPropertyItem(_p)
Next
这工作得很好。 所有 exif 项目均已成功复制。 我通过在调试模式下使用手表来确认这一点。 当您使用以下方法将 image2 保存为 jpeg 时,问题就出现了:
Dim eps As EncoderParameters = New EncoderParameters(1)
eps.Param(0) = New EncoderParameter(Encoder.Quality, 85)
Dim ici As ImageCodecInfo = GetEncoderInfo("image/jpeg")
image2.Save("C:\1.jpg", ici, eps)
但是,只有很少的 EXIF 属性与 image2 jpeg 文件一起保存,即只有相机型号和相机制造商。 但是,如果我将 image2 保存为 TIF,则原始 tif 中的所有属性都将存在。 谁能解释这是为什么吗?
谢谢。
I would really appreciate if you could shed light on this problem.
I have 2 images, one was created from TIF file with metadata, the other is an in-memory image that will be saved as jpeg.
Then I use this routine to transfer exif metadata from first image to the second one (that is from the one created from tif file to the in-memory image):
For Each _p In image1.PropertyItems
image2.SetPropertyItem(_p)
Next
And this works perfectly fine. All exif items are successfully copied. I confirmed this by using watches in debug mode. The problem comes when you save image2 as jpeg using this:
Dim eps As EncoderParameters = New EncoderParameters(1)
eps.Param(0) = New EncoderParameter(Encoder.Quality, 85)
Dim ici As ImageCodecInfo = GetEncoderInfo("image/jpeg")
image2.Save("C:\1.jpg", ici, eps)
Only very few EXIF properties are saved with image2 jpeg file however, namely only camera model and camera maker. However If I save image2 as TIF, all properties from the original tif will be there. Can anyone explain why is that?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看 Exiv2Sharp - Exiv2 的这个包装器应该提供您正在寻找的内容。
Take a look at Exiv2Sharp - this wrapper around Exiv2 should provide what you're looking for.