如何将 BufferedImage 保存为文件 [英] How to save a BufferedImage as a File
本文介绍了如何将 BufferedImage 保存为文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 imgscalr Java 库来调整大小图片.
I am using the imgscalr Java library to resize an image .
resize() 方法调用的结果是一个 BufferedImage 对象.我现在想将其保存为文件(通常为 .jpg).
The result of a resize() method call is a BufferedImage object. I now want to save this as a file (usually .jpg).
我该怎么做?我想从 BufferedImage
-> File
开始,但也许这不是正确的方法?
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屋!
查看全文