Home > Back-end >  How to take out a picture back to the browser or interface
How to take out a picture back to the browser or interface

Time:11-29

To realize image watermark function

The original watermark, through the specified address or interface access watermarking


The idea now is to open the https://bbs.xxxx.net/? Img=sadfg. JPG

Then according to the parameters using an, to find the picture of the storage paths,


Add watermark and returned to the customer, after find out or browser,


How to read the picture into a "stream" among this

To add the "flow" watermarking, the watermarking "wheels" I had,

Just don't know how to get the IO "flow"

CodePudding user response:


A search for "the servlet output file stream"


One of the results:
https://www.cnblogs.com/zj0208/p/8945158.html

CodePudding user response:

You need a ByteArrayInputStream/ByteArrayOutputStream, everything in memory operation

CodePudding user response:

Find the picture of the storage paths, this is to get the flow? FileInputStream have not learned? Or do you want to ask is how to response to the front end has a watermark image browser?
On the first floor should be able to solve your problem

CodePudding user response:

BufferedImage image (image will be generated this object);
ServletOutputStream out=response. GetOutputStream ();
ImageIO. Write (image, "JPG", out);
IOUtils. CloseQuietly (out);

CodePudding user response:

Thank you for your bosses, it should be 2 floor laoge said

Is there any other action class, which are frequently used these two classes,

Thanks to the 4th floor laoge code, thank you

CodePudding user response:

This is an example of a landing page to return to the authentication code


@ RequestMapping (" captcha. JPG ")
Public void captcha (HttpServletResponse response) throws IOException {
Response. SetHeader (" cache-control ", "no - store, no - Cache");
The response. SetContentType (" image/jpeg ");

//generated text captchas
String text=producer. CreateText ();
//generated image authentication code
BufferedImage image=producer. CreateImage (text);
//save the shiro sessions
ShiroUtils. SetSessionAttribute (the KAPTCHA_SESSION_KEY, text);

ServletOutputStream out=response. GetOutputStream ();
ImageIO. Write (image, "JPG", out);
}

CodePudding user response:

Current can meet the needs of all transmission ~
  • Related