public static String imageToBytes(Image image) throws IOException {
    //noinspection UndesirableClassUsage
    BufferedImage bi = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = bi.createGraphics();
    g.drawImage(image, 0, 0, null);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(bi, "png", baos);
    g.dispose();
    return new String(baos.toByteArray(), StandardCharsets.ISO_8859_1);
  }
public static String imageToBytes(Image image)