有沒有人在Java中加載JPEG文件時遇到過問題?我們的客戶之一是發送無法解析的文件,但這些相同的文件可以在Windows中打開。 (我們收到的JPEG文件,其他99%,沒有任何問題的過程)未能從字節中讀取JPEG文件[]
我已經嘗試了幾個圖書館閱讀這些:
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[]
的錯誤在這裏建議對我來說,JPEG文件被破壞,然而,這並不能解釋爲什麼他們仍然可以看到。
如果任何人有任何建議,我將不勝感激
感謝
你是否嘗試用油漆減少圖片尺寸? – VirtualTroll 2012-08-09 14:40:36
檢查編碼問題。可能在兩端。您或您的客戶可能會使用某些可根據語言環境/編碼轉換字節的類(可能爲Reader),並會中斷數據。 – npe 2012-08-09 14:40:46
也許圖像使用CMYK模型。 http://stackoverflow.com/questions/2408613/problem-reading-jpeg-image-using-imageio-readfile-file – 2012-08-09 14:48:33