从 .NET 中的 JPEG 读取 IPTC 字段时出错

发布于 2024-07-21 00:44:39 字数 742 浏览 12 评论 0原文

在我尝试过的大约 1% 的 JPEG 上调用 BitmapMetadata.GetQuery("/app13/irb/8bimiptc/iptc") 时,出现以下异常。 可能是什么原因造成的?我可以采取什么措施来解决这个问题? (我尝试过谷歌搜索,但只能找到一个相关结果,提出了相同的问题,但没有答案。)

System.OverflowException:
The image data generated an overflow during processing. ---> 
System.Runtime.InteropServices.COMException (0x88982F05): 
Exception from HRESULT: 0x88982F05
--- End of inner exception stack trace ---
at System.Windows.Media.Imaging.BitmapMetadata.GetQuery(String query)
at MyProject.ImageRecord..ctor(String file)
in C:\MyProject\ImageRecord.cs:line 93
The image data generated an overflow during processing.

编辑:

exiv2 工具报告:

Error: Invalid Photoshop IRB data size 6372

I get the following exception when calling BitmapMetadata.GetQuery("/app13/irb/8bimiptc/iptc") on about 1% of JPEGs I have tried this on. What could be causing this and what can I do to fix it? (I have tried Googling but I can only find one relevant result asking the same question but with no answer.)

System.OverflowException:
The image data generated an overflow during processing. ---> 
System.Runtime.InteropServices.COMException (0x88982F05): 
Exception from HRESULT: 0x88982F05
--- End of inner exception stack trace ---
at System.Windows.Media.Imaging.BitmapMetadata.GetQuery(String query)
at MyProject.ImageRecord..ctor(String file)
in C:\MyProject\ImageRecord.cs:line 93
The image data generated an overflow during processing.

Edit:

The exiv2 tool reports:

Error: Invalid Photoshop IRB data size 6372

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

静水深流 2024-07-28 00:44:39

我的猜测是 Photoshop IRB 数据比标头指定的长度长。

至少这是我可以通过浏览 Exiv2 的源代码(第 107 行)来推断的:

http://dev.exiv2.org/repositories/entry/exiv2/trunk/src/jpgimage.cpp?rev=1146

但是我对c的理解不太好! :)

My guess is that the Photoshop IRB data is longer than the header specifies.

At least this is what I can deduct by skimming over the source of Exiv2 (line 107):

http://dev.exiv2.org/repositories/entry/exiv2/trunk/src/jpgimage.cpp?rev=1146

But my understanding of c is not that good! :)

迷你仙 2024-07-28 00:44:39

错误 0x88982F05 只是 WIC 的常规值超出范围错误
因此您可以轻松处理。 此外,这可能不是 IPTC 查询字符串的唯一问题。 只需尝试像这样 {} catch {} 此部分即可实现优雅的失败转移

if (bitmapMetadata.GetQuery(MY_QUERY) != null &&) {
try { 
... }
catch {}

Error 0x88982F05 is only regular value-out-of-range error by WIC
Thus it can be easely handled by you. Also this might not be your only problem with IPTC query strings. Just try {} catch {} this section like this to graceful fallover

if (bitmapMetadata.GetQuery(MY_QUERY) != null &&) {
try { 
... }
catch {}
请你别敷衍 2024-07-28 00:44:39

根据exiv2报告的信息,Photoshop IRB信息的大小与元数据的整体大小不一致。

如果您希望忽略这些消息,我会更具体地说明您捕获的异常类型——仅忽略或报告特定的 COM 异常。

那里有一些工具/资源:

Based on the information reported by exiv2, the size of the Photoshop IRB information is inconsistent with the overall size of the metadata.

If you wish to ignore the messages I would be more specific in the the type of exception you catch -- only ignore or report that particular COM Exception.

A couple of tools/resources out there:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文