Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.1k views
in Technique[技术] by (71.8m points)

java - How to save a BufferedImage as a File

I am using the imgscalr Java library to resize an image .

The result of a resize() method call is a BufferedImage object. I now want to save this as a file (usually .jpg).

How can I do that? I want to go from BufferedImage -> File but perhaps this is not the correct approach?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
File outputfile = new File("image.jpg");
ImageIO.write(bufferedImage, "jpg", outputfile);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...