使用 javax.imageio 读取 jpeg 或 gif 元数据 [英] Reading jpeg or gif metadata with javax.imageio

查看:248
本文介绍了使用 javax.imageio 读取 jpeg 或 gif 元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想修改某些类型的图像(png、jpeg 或 gif)的元数据,并且我在这个 主题,由 haraldK 提供.但是,当我尝试在 jpg 图像上运行它时,它会引发此错误:javax.imageio.IIOException:JFIF APP0 必须是 SOI 之后的第一个标记.到达IIOImage image = reader.readAll(0, null);

I want to modify the metadata of some types of images (png, jpeg or gif) and I found a a code that works very well for PNG images on this topic, provided by haraldK. When I try to run it on a jpg image though, it throws this error : javax.imageio.IIOException: JFIF APP0 must be first marker after SOI. The error is thrown when arriving on the line IIOImage image = reader.readAll(0, null);

我该怎么做才能让它发挥作用?

What can I do to get this working ?

预先感谢您的回答.

推荐答案

您面临的问题是 JPEG 标准没有定义文件格式.出现了几种文件格式.例如.国际金融论坛.EXIF.斯皮夫.这些格式以不同的方式表示元数据.显然,您尝试使用的库仅支持 JFIF 文件格式.显然,您的库仅支持 JFIF 格式,而您拥有不同格式(可能是 EXIF)的文件.

The problem you face is the JPEG standard did not define a file format. Several file formats appeared. E.g. JFIF. EXIF. SPIFF. These formats represent metadata in different ways. Apparently the library you are trying to use only supports the JFIF file format. Apparently your library only supports the JFIF format while you have a file in a different format (likely EXIF).

因此,您需要一个支持您的文件格式的库,或者您需要修改您必须使用的任何文件格式的库.这可能是一个相当大的变化.

So you need a library that supports your file format or you need to modify the library you have to work with whatever file format you have. That could be a fairly substantial change.

这篇关于使用 javax.imageio 读取 jpeg 或 gif 元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆