public static ImageResource loadImageResourceFromUri(final String uri) {
if (ImageUtil.isEmbeddedBase64Image(uri)) {
return loadEmbeddedBase64ImageResource(uri);
} else {
StreamResource sr = new StreamResource(uri);
InputStream is;
ImageResource ir = null;
try {
sr.connect();
is = sr.bufferedStream();
try {
BufferedImage img = ImageIO.read(is);
if (img == null) {
throw new IOException("ImageIO.read() returned null");
}
ir = createImageResource(uri, img);
} catch (FileNotFoundException e) {
XRLog.exception("Can't read image file; image at URI '" + uri + "' not found");
} catch (IOException e) {
XRLog.exception("Can't read image file; unexpected problem for URI '" + uri + "'", e);
} finally {
sr.close();
}
} catch (IOException e) {
// couldnt open stream at URI...
XRLog.exception("Can't open stream for URI '" + uri + "': " + e.getMessage());
}