As part of our series of Handling common image file formats in Java I will be writing about how we can read JPeg images in Java where I mention the different libraries that enable us to read JPeg images.
What is JPeg?
It is commonly used for digital images as it gives you high quality images. One main feature of JPeg is that it enables you to choose between quality and file size; you can sacrifice quality for a smaller file or vice versa.
There are many libraries out there that can read JPeg images. These include ImageIO, JAI and JDeli.
How to read JPeg images in Java?
Here are some code examples using Image IO, JAI and JDeli to read JPEG.
File jpegFile = new File("jpegImage.jpg"); BufferedImage image = ImageIO.read(jpegFile);
RenderedImage image = JAI.create("fileload", "test1.jpeg");
JpegDecoder decoder = new JpegDecoder(); BufferedImage image = decoder.read(rawImageBytes);
We have also created a useful how to series on how to read and write various Image formats. You can find moire about this on our Index.
Latest posts by Zain (see all)
- Using Zendesk or Jira Service Desk to provide customer support - July 20, 2017
- Java 9 JShell explained in 5 minutes - May 11, 2017
- Java 9 Modularity explained in 5 minutes - May 4, 2017
- Key takeaways from NetBeans Day UK 2017 - April 26, 2017
- Why IDRsolutions uses the NetBeans IDE for Java Development - April 18, 2017