In this set we will learn how to read and write image file in Java.
Classes required to perform the operation:
- To read and write image file we have to import the File class [ import java.io.File; ]. This class represents file and directory path names in general.
- To handle errors we use the IOException class [ import java.io.IOException; ]
- To hold the image we create the BufferedImage object for that we use BufferedImage class [ import java.awt.image.BufferedImage; ]. This object is used to store an image in RAM.
- To perform the image read write operation we will import the ImageIO class [ import javax.imageio.ImageIO;]. This class has static methods to read and write an image.
Note : This code will not run on online IDE as it needs an image on disk.
In the next set we will be learning how to get and set the pixel value of images in JAVA.
This article is contributed by Pratik Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Image Processing in Java | Set 3 (Colored image to greyscale image conversion)
- Image Processing in Java | Set 4 (Colored image to Negative image conversion)
- Image Processing in Java | Set 5 (Colored to Red Green Blue Image Conversion)
- Image Processing in Java | Set 7 (Creating a random pixel image)
- Image Processing in Java | Set 8 (Creating mirror image)
- Image Processing in Java | Set 11 (Changing orientation of image)
- Image Processing in Java | Set 10 ( Watermarking an image )
- Image Processing In Java | Set 2 (Get and set Pixels)
- Image Processing in Java | Set 12 ( Contrast Enhancement )
- Image Processing in Java | Set 9 ( Face Detection )
- Image Processing in Java | Set 14 ( Comparison of two images )
- Image Processing using OpenCV in Java | Set 14 ( Sharpness Enhancement )
- Image Processing using OpenCV in Java | Set 13 (Brightness Enhancement)
- Getting started with Scikit-image: image processing in Python
- Digital Image Processing Basics