Has anyone ever had an issue with Loading JPEG files in java? One of our clients is sending files that cannot be resolved, but these same files can be opened in windows. (the other 99% of jpeg files we recieve, process without any problems)
有没有人在java中加载JPEG文件有问题?我们的一个客户端正在发送无法解析的文件,但这些文件可以在Windows中打开。 (我们收到的其他99%的jpeg文件,处理没有任何问题)
I have tried a couple of libraries to read these:
我尝试了几个库来阅读这些:
itextpdf : com.itextpdf.text.Jpeg (getInstance(imageData) - gives "java.io.IOException: Premature EOF while reading JPG."
sanselan : org.apache.sanselan.ImageInfo ( Sanselan.getImageInfo(imageData) gives "java.io.IOException: Invalid Segment: insufficient data")
where imageData is a byte[]
The errors here suggest to me that the jpegs are broken, however, this does not explain why they are still viewable.
这里的错误告诉我,jpegs坏了,但是,这并不能解释为什么它们仍然可见。
If anyone has any suggestions, I would be most grateful
如果有人有任何建议,我将非常感激
Thanks
1 个解决方案
#1
0
The "solution" I have gone for is to run the byte array we recieve through our current process which identifies type. If this can't identify the type, then I take the byte array and forcably save it to a JPEG. This can then be re read and pushed back through the current process.
我已经解决的“解决方案”是运行我们通过当前进程识别类型的字节数组。如果这不能识别类型,那么我采用字节数组并强制将其保存为JPEG。然后可以通过当前进程重新读取并推回。
Bit hacky, but its just a work around for a couple of months.
有点hacky,但它只是一个工作了几个月。
Thanks for everyone's help here!
感谢大家的帮助!
#1
0
The "solution" I have gone for is to run the byte array we recieve through our current process which identifies type. If this can't identify the type, then I take the byte array and forcably save it to a JPEG. This can then be re read and pushed back through the current process.
我已经解决的“解决方案”是运行我们通过当前进程识别类型的字节数组。如果这不能识别类型,那么我采用字节数组并强制将其保存为JPEG。然后可以通过当前进程重新读取并推回。
Bit hacky, but its just a work around for a couple of months.
有点hacky,但它只是一个工作了几个月。
Thanks for everyone's help here!
感谢大家的帮助!