ImageUtil { public static BufferedImage loadEmbeddedBase64Image(String imageDataUri) { try { byte[] buffer = getEmbeddedBase64Image(imageDataUri); if (buffer != null) { return ImageIO.read(new ByteArrayInputStream(buffer)); } } catch (IOException ex) { XRLog.log(Level.WARNING, LogMessageId.LogMessageId0Param.EXCEPTION_CANT_READ_XHTML_EMBEDDED_IMAGE, ex); } return null; }  static BufferedImage makeCompatible(BufferedImage bimg); static BufferedImage createCompatibleBufferedImage(int width, int height, int biType); static BufferedImage createCompatibleBufferedImage(int width, int height); static BufferedImage getScaledInstance(ScalingOptions opt, BufferedImage orgImage); static BufferedImage getScaledInstance(BufferedImage orgImage, int targetWidth, int targetHeight); static BufferedImage convertToBufferedImage(Image awtImg, int type); static BufferedImage createTransparentImage(int width, int height); static boolean isEmbeddedBase64Image(String uri); static boolean isDataUri(String uri); static byte[] getEmbeddedBase64Image(String imageDataUri); static byte[] getEmbeddedDataUri(String dataUri); static BufferedImage loadEmbeddedBase64Image(String imageDataUri);  }
@Test public void testLoadEmbeddedBase64Image() { String onePixel = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAC4jAAAuIwF4pT92AAAADElEQVQI12P4 BufferedImage result = ImageUtil.loadEmbeddedBase64Image(onePixel); Assert.assertThat(result.getHeight(), is(1)); Assert.assertThat(result.getWidth(), is(1)); }