How to get base64 encoded contents for an ImageReader?
- by htf
Hi. How do I read an image into a base64 encoded string by its ImageReader?
Here's example source code using HtmlUnit. I want to get the base64 String of img:
WebClient wc = new WebClient();
wc.setThrowExceptionOnFailingStatusCode(false);
wc.setThrowExceptionOnScriptError(false);
HtmlPage p = wc.getPage("http://flickr.com");
HtmlImage img = (HtmlImage) p.getByXPath("//img").get(3);
System.out.println(img.getImageReader().getFormatName());