Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading a image file in Jva

Tags:

java

io

image

How to read a image in Java and convert it to buffered image?

like image 331
akshay Avatar asked Feb 15 '10 15:02

akshay


People also ask

Which is used to read an image file in Java?

In Java, we can use the javax. imageio. ImageIO class to read and write an image.

Can Java read JPEG?

Java 2D supports loading these external image formats into its BufferedImage format using its Image I/O API which is in the javax. imageio package. Image I/O has built-in support for GIF, PNG, JPEG, BMP, and WBMP.

Can we read text from image in Java?

The Optical Character Recognition (OCR) technology has made it possible to recognize and read the text within the scanned documents and images. OCR lets you convert the read-only text into an editable form.


2 Answers

You need the Java 2D API for this. Here's a Sun tutorial about the subject. In the "Working with Images" chapter you can learn how to read/load an image. Here's an extract of the tutorial:

BufferedImage img = null;
try {
    img = ImageIO.read(new File("strawberry.jpg"));
} catch (IOException e) {

}
like image 144
BalusC Avatar answered Oct 12 '22 23:10

BalusC


See ImageIO.read().

like image 33
extraneon Avatar answered Oct 13 '22 01:10

extraneon