img base64

 

<img src="data:image;base64, base64 encoding of the image">

Such as


 

Open the html file with a browser



 

 

 

 

An example of base64 encoding an image in Java

/**
	 * Convert image to base64 encoded string
	 */
	public static String getImageStr(String imgFile) {
	    InputStream inputStream = null;
	    byte[] data = null;
	    try {
	        inputStream = new FileInputStream(imgFile);
	        data = new byte[inputStream.available()];
	        inputStream.read(data);
	        inputStream.close();
	    } catch (IOException e) {
	        e.printStackTrace ();
	    }
	    // base64 encoding
	    BASE64Encoder encoder = new BASE64Encoder();
	    return encoder.encode(data);
	}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326825784&siteId=291194637