jQuery in Action, 3rd edition
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Write image to a file" Watch "Write image to a file" New topic

Write image to a file

prav ford

Joined: Apr 28, 2004
Posts: 16
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.
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:

I agree. Here's the link: http://aspose.com/file-tools
subject: Write image to a file
jQuery in Action, 3rd edition