Search code examples
javaimagebufferedimageimage-scalingimagesource

How to print Buffred image as thumbnail in java?


Here i'm scaling image and saving in minImage (Buffred Image format)now how can i print that image as

BufferedImage minImage = ImageSale(buffered, minImageWidth, minImageHeight, TYPE_INT_RGB);

out.println("<img src=\""+minImage+"\">");

How to print image as thumb,please help me to resolve this issue.


Solution

  • You seem to have an issue with understanding the difference between a client and a server and what information they have available to each other, as well as the information that is maintained by HTML.

    HTML is a plain text document, technically, it can't contain binary information (such as image data) and you really don't want to try and do this any way, as the HTML page itself should download relatively quickly.

    The client HTML will need a reference to the image on the file server (or within the web servers context). This is typically done by saving the file to the server in a location which is accessible by the browser.

    If you don't want to save the images to disk, then you will need to create some kind of "memory cache" which contains the key to the image, so that when the browser requests the image from the server you can look it up from the cache and return a stream of the image to the client browser.

    This would require you to seed the URL with some kind of identifier that could be mapped to the cache