sky-tiankong

InputStream inputStream = null;

inputStream = frontFile.getInputStream();
BufferedImage bufImg = Thumbnails.of(inputStream).scale(0.2f).asBufferedImage();
ByteArrayOutputStream os = new ByteArrayOutputStream();
String frontFileName = frontFile.getOriginalFilename().substring(frontFile.getOriginalFilename().lastIndexOf(".")+1);
ImageIO.write(bufImg, frontFileName, os); //图片写入到 ImageOutputStream
inputStream = new ByteArrayInputStream(os.toByteArray());
String frontSavePath = **************************************** "."+frontFileName;

文件流上传至阿里云,阿里云应该是通过传递过来的文件格式名解析文件流的, jpg格式的图片转换成了png,图片总是显示不正常。最后查看图片发现上传后的文件格式,和我设置的不一致,才发现的。

分类:

技术点:

相关文章:

  • 2021-11-19
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2021-12-05
  • 2021-10-12
  • 2021-08-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-07
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
相关资源
相似解决方案