如何将一个BufferedImage保存为一个文件 [英] How to save a BufferedImage as a File
本文介绍了如何将一个BufferedImage保存为一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 imgscalr Java库调整图像。
resize()方法调用的结果是一个BufferedImage对象。我现在想把它保存为一个文件(通常是.jpg)。
我该怎么做?我想从> BufferedImage
- > File
但是这可能不是正确的方法吗?
解决方案
File outputfile = new File(image.jpg);
ImageIO.write(bufferedImage,jpg,outputfile);
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?
解决方案
File outputfile = new File("image.jpg");
ImageIO.write(bufferedImage, "jpg", outputfile);
这篇关于如何将一个BufferedImage保存为一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文