java with pictures size of the problem

In memory of the requirements of Party today proposed requiring back-end control of the length and width of the front end upload pictures, if over 1024, requires scaling images. Then compress the picture quality.

 

This operation is usually done at the front end, but today the need to do the back-end. And there is no way to only do ah

 

The first is the receiver front-end picture, usually MultipartFile reception, this time you need to turn into MultipartFile Image. We need to first turn to Image MultipartFile

Turn into File.

FileInputStream in = (FileInputStream) file.getInputStream();

BufferedImage  image = javax.imageio.ImageIO.read(in);      //转成BufferedImage  

Then flow through io, save it to a folder.

 And then casually talk about compressing images. Compression quality pictures. Too many pictures, compress quality.

thumbnailator use

Need to guide package

Method for compressing images: Compression picture quality of 80%

 

 

 

 

Published 20 original articles · won praise 7 · views 10000 +

Guess you like

Origin blog.csdn.net/qrnhhhh/article/details/89488075