Reading JPEG in Java

I am trying to get a JPEG in a BufferedImage to display on a JPanel . However, javax.imageio.ImageIO.read() seems very fussy about the JPEG processes it processes, often throwing an IIOException . The same JPEG files are perfectly visible in any image reading application that you would like to name.

I looked at Apache Sanselan and JAI . But Sanselan cannot handle JPEG, and JAI is not available for 64-bit Windows platforms and seems not to be supported (the last update was in 2006). The previous https://stackoverflow.com/a/166268/combination/questions/245552/ ... suggested com.sun.image.codec.jpeg.JPEGCodec , but this was deprecated in Java 5 and disappeared in 7.

Are these my only options? Are there really no Java libraries capable of efficiently reading JPEG files in BufferedImage ?

+4
source share
1 answer

Legacy Toolkit methods such as createImage and getImage are softer than ImageIO .

Werner Randelshofer also wrote CMYK Image Reading Service Provider with ImageIO .

By combining both approaches (try all possible ImageReader and then cancel Toolkit ), you can process a reasonable amount of JPEG images.

Reading a JPEG with a CMYK profile can be interesting.

+1
source

All Articles