forked from yusufshakeel/Java-Image-Processing-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadWriteImage.java
More file actions
38 lines (34 loc) · 942 Bytes
/
ReadWriteImage.java
File metadata and controls
38 lines (34 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* File: ReadWriteImage.java
*
* Description:
* Read and write image.
* @author Yusuf Shakeel
* Date: 26-01-2014 sun
*
* www.github.com/yusufshakeel/Java-Image-Processing-Project
*/
import java.io.File;
import java.io.IOException;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class MyImage{
public static void main(String args[])throws IOException{
BufferedImage image = null;
File f = null;
//read image file
try{
f = new File("D:\\Image\\Taj.jpg");
image = ImageIO.read(f);
}catch(IOException e){
System.out.println("Error: "+e);
}
//write image
try{
f = new File("D:\\Image\\Output.jpg");
ImageIO.write(image, "jpg", f);
}catch(IOException e){
System.out.println("Error: "+e);
}
}//main() ends here
}//class ends here