我正在尝试通过 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/