List of utility methods to do BufferedImage to Base64 String
String | imageToBase64(BufferedImage image) image To Base ByteArrayOutputStream out = new ByteArrayOutputStream(BUFFER_SIZE); ImageIO.write(image, "png", out); return Base64.getEncoder().encodeToString(out.toByteArray()); |
String | imageToBase64String(BufferedImage image, String type) image To Base String String imageString = null; ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { ImageIO.write(image, type, bos); byte[] imageBytes = bos.toByteArray(); imageString = Base64.getEncoder().encodeToString(imageBytes); bos.close(); } catch (IOException e) { ... |
String | imageToBase64String(RenderedImage image, String type) Encode image to string String ret = null; ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { ImageIO.write(image, type, bos); byte[] bytes = bos.toByteArray(); BASE64Encoder encoder = new BASE64Encoder(); ret = encoder.encode(bytes); ret = ret.replace(System.lineSeparator(), ""); ... |