How can I convert an image like this one into a Base64 string? I upload the image to the server with React, scale it, save it in the database, read it out again and get this format. Now I have to convert this format into a Base64 format.
My Java Code to scale the image:
Part bild = request.getPart("bild");
InputStream in = null;
long fileSize = bild.getSize();
byte[] bytesBild = null;
if (fileSize > 0) {
in = bild.getInputStream();
BufferedImage imBuff = ImageIO.read(bild.getInputStream());
BufferedImage resize = resizeImage(imBuff, 200, 200);
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(resize, "jpeg", os); // Passing: (RenderedImage im, String formatName, OutputStream
// output)
InputStream is = new ByteArrayInputStream(os.toByteArray());
bytesBild = IOUtils.toByteArray(is);
}
This is the result from my Database: