java - org.apache.commons.imaging.ImageReadException : Couldn't read magic numbers to guess format

标签 java apache-commons exif

我正在尝试通过 jsp 上传图像,并在后端尝试读取其元数据。但我收到此错误

org.apache.commons.imaging.ImageReadException: Couldn't read magic numbers to guess format.

final ImageMetadata metadata = Imaging.getMetadata(file.getBytes());

问题是目标文件是 MultipartFile,而不是它,它应该是 File 类型。

最佳答案

我使用下面的代码在文件中转换了 Multipartfile 以避免错误。

 File convFile = new File( multipart.getOriginalFilename());
 multipart.transferTo(convFile);
 final ImageMetadata metadata = Imaging.getMetadata(convFile);

关于java - org.apache.commons.imaging.ImageReadException : Couldn't read magic numbers to guess format,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38203400/

相关文章:

node.js - 在使用 node-gm 保存图像的 exif 方向时调整图像大小

exif - 是什么导致某些 EXIF 标签不可写?

java - PasswordVerifier示例将无法编译

java - 如何获取列表包含的元素类?

java - 如何为单个 C 函数生成多个包装器?

java - 尝试将 Java 字符串中的每个单词大写

java - Commons Math : The Apache Commons Mathematics Library 的内存要求

java - log4j 警告问题 - apache commons

java - 如何使用 Azure 在 Java 或 Android 中使用 Microsoft Translator API

image - 读取图像 IPTC 数据