The example of this article is about how to display the PHP image in base64. Share to everyone for your reference, specific as follows:
Here the implementation of the picture as a string saved to the Web page, so that no longer need to load the function of the picture.
This is the data URI scheme defined in RFC2397, the purpose is to embed some small data directly into the Web page, so that no longer load from the external file, such as the string of characters above, is actually a picture, these characters are copied sticky paste to the Firefox address bar and turn to, you can see.
In the data URI above, data represents the contract name for the acquisition, Image/jpeg is the data type name, base64 is the encoding method of the data, followed by the Image/jpeg file Base64 encoded data.
The types currently supported by Data URI scheme are:
Data:text/plain, Text data
data:text/html,html Code
Data:text/html;base64,base64 coded HTML code
DATA:TEXT/CSS,CSS Code
Data:text/css;base64,base64 coded CSS Code
Data:text/javascript,javascript Code
Data:text/javascript;base64,base64 coded JavaScript code
DATA:IMAGE/GIF;BASE64,BASE64 encoded GIF image data
DATA:IMAGE/PNG;BASE64,BASE64 encoded PNG image data
DATA:IMAGE/JPEG;BASE64,BASE64 encoded JPEG image data
DATA:IMAGE/X-ICON;BASE64,BASE64 encoded icon image data
The PHP code is as follows:
$img _file = ' yun_qi_img/tb1eaielpxxxxcpxpxxsutbfxxx.jpg ';
$img _info = getimagesize ($img _file);
$img _src = "data:{$img _info[' mime ']};base64,". Base64_encode (file_get_contents ($img _file));
Exit ("
PS: Here again for you to recommend several online picture Tools for everyone to use the reference
Picture converted to BASE64 encoded online tool:
Http://tools.jb51.net/transcoding/img2base64
Online Email Email icon Production tool:
Http://tools.jb51.net/email/emaillogo
Online PS image processing tools:
http://tools.jb51.net/aideddesign/webps
Online picture format conversion (jpg/bmp/gif/png) Tool:
Http://tools.jb51.net/aideddesign/picext
ico icon Online generation tool:
Http://tools.jb51.net/aideddesign/ico_img
For more information on PHP related content readers can view the site topics: "PHP graphics and pictures Operating skills summary", "Basic PHP Grammar Introductory Course", "PHP Operations and Operator Usage Summary", "PHP object-oriented Program Design Introductory Course", "PHP Network Programming Skills Summary", "PHP array (Array) Operations tips Encyclopedia, "PHP string (String) Usage Summary", "Php+mysql Database operation Introduction Tutorial" and "PHP Common database Operation tips Summary"
I hope this article will help you with the PHP program design.