aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Write image to a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Write image to a file" Watch "Write image to a file" New topic
Author

Write image to a file

prav ford
Greenhorn

Joined: Apr 28, 2004
Posts: 16
Hi,
I have a panel. I select a gif/jpg/* Image file and display the Image on the Panel. Then I have a save button, thru which i have to save the image into a file.

To put it in clear words...I need to read an image from a file and write the image to another file.

Any Ideas.
Thanks,
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
If you are using j2se 1.4+ you can use the ImageIO class to read and write images. It will read .gif, .jpg and .png and write .jpg and .png images. To save an image:

A special download is available from Sun for other image extensions.
Martin Thorpe
Ranch Hand

Joined: May 25, 2004
Posts: 45
yeah that is how it worked for me... sample code below:

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Write image to a file