[英]Unable to save BufferedImage from applet using ImageIO.write
[英]Unable to write tif file from controller using ImageIO
我有jai-imageio jar并将它添加到我的类路径中。 我只是不知道将.tif图像写入响应的输出流。 有人能帮我吗?
这是我的代码:
RenderedOp image = JAI.create("fileload", filepath);
ImageIO.write(image.getAsBufferdImage(), "tif", response.getOutputStream());
我知道javax.imageio.ImageIO不支持tif图像,那么我怎么处理jai-imageio才能让它成为烦恼? 我迷路了。
注意:上面的代码适用于其他图像类型,如jpeg和png。
看起来你正朝着存储和提供上传图像的错误方向前进。 您根本不需要整个Java 2D API。
当您检索上传的图像时,就这样做
InputStream input = uploadedFile.getInputStream();
OutputStream output = new FileOutputStream(uniqueImagePath);
// Now write input to output in a loop the usual way.
当您提供上传的图片时,就这样做
InputStream input = new FileInputStream(uniqueImagePath);
OutputStream output = response.getOutputStream();
// Now write input to output in a loop the usual way.
您根本不需要按摩/操纵字节。 只是简单地流动它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.