Java Utililty Methods BufferedImage from String

List of utility methods to do BufferedImage from String

Description

The list of methods to do BufferedImage from String are organized into topic(s).

Method

BufferedImagebase64StringToImage(String imageString)
Decode string to image
BufferedImage ret = null;
byte[] imageByte;
try {
    BASE64Decoder decoder = new BASE64Decoder();
    imageByte = decoder.decodeBuffer(imageString);
    ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
    ret = ImageIO.read(bis);
    bis.close();
...
BufferedImagebase64StringToImage(String imageString)
base String To Image
BufferedImage image = null;
byte[] imageByte;
try {
    imageByte = Base64.getDecoder().decode(imageString);
    ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
    image = ImageIO.read(bis);
    bis.close();
} catch (Exception e) {
...
BufferedImagebase64StringToImg(final String base64String)
base String To Img
try {
    return ImageIO.read(new ByteArrayInputStream(Base64.getDecoder().decode(base64String)));
} catch (final IOException ioe) {
    throw new UncheckedIOException(ioe);
BufferedImagebase64ToImage(final String data, final int width, final int height)
Builds an image from the given base64 encoded text.
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
final byte[] decodedData = DatatypeConverter.parseBase64Binary(data);
try (ByteArrayInputStream bis = new ByteArrayInputStream(decodedData)) {
    image = ImageIO.read(bis);
return image;
BufferedImagebase64ToImage(String base64)
base To Image
byte[] bytes = Base64.getDecoder().decode(base64);
return ImageIO.read(new ByteArrayInputStream(bytes));
BufferedImagebase64ToImg(String base64Strings)
base To Img
BufferedImage bi = null;
ByteArrayInputStream bais = null;
BASE64Decoder decoder = new sun.misc.BASE64Decoder();
byte[] bytes1;
try {
    bytes1 = decoder.decodeBuffer(base64Strings);
    bais = new ByteArrayInputStream(bytes1);
    bi = ImageIO.read(bais);
...
BufferedImagedecodeImage(String encoded)
create an image from the given ascii-encoded representation
BASE64Decoder decoder = new BASE64Decoder();
byte[] bytes = decoder.decodeBuffer(encoded);
ByteArrayInputStream input = new ByteArrayInputStream(bytes);
return ImageIO.read(input);
BufferedImagedecodeImage(String imageString)
decode Image
BufferedImage image = null;
byte[] imageBytes;
imageBytes = DatatypeConverter.parseBase64Binary(imageString);
ByteArrayInputStream bis = new ByteArrayInputStream(imageBytes);
try {
    image = ImageIO.read(bis);
    bis.close();
} catch (IOException e) {
...
BufferedImagedecodeToImage(String imageString)
Decode string to image
BufferedImage image = null;
byte[] imageByte;
try {
    BASE64Decoder decoder = new BASE64Decoder();
    imageByte = decoder.decodeBuffer(imageString);
    ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
    image = ImageIO.read(bis);
    bis.close();
...
java.awt.image.BufferedImagedecodeToImage(String imageString)
decode To Image
java.awt.image.BufferedImage image = null;
try {
    String imgString = imageString.startsWith("data:image/")
            ? imageString.substring(imageString.indexOf(',') + 1)
            : imageString;
    java.io.InputStream stream = new java.io.ByteArrayInputStream(
            java.util.Base64.getDecoder().decode(imgString));
    image = javax.imageio.ImageIO.read(stream);
...