The following editor will bring you an article on how to display hexadecimal image data on the img tag of html in PHP (implementation method). The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.
A production database of SQLServer2008 of the client company has reached a huge size of 18G in just over a year. It turns out that the pictures in the system are directly stored in the database in the form of hexadecimal strings. of. It takes me a lot of time to display it on the html page using PHP.
<?php // 从数据库读出来的:图片的十六进制形式字符串 $icon_hex = '89504e470d0a1a0a0000000d494844520000001c00000012010300000072c92ca' .'700000006504c5445000000ffffffa5d99fdd0000003f49444154089963603e6f60c000266cce1' .'b1f8010cc07406220c2febcf10724e2ffe7ff7082f90303e76466062061ccc0603999d90048d81' .'b30d809f3400800c0921ea36f9b656d0000000049454e44ae426082'; $imgdata = base64_encode(pack('H*',$icon_hex)); echo '<img src="data:image/png;base64,'. $imgdata .'" />'; ?>
The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
PHP5 Authoritative Programming Reading Study Notes with e-book download_php basics
Introduction to the organizational structure of nginx php-fpm configuration file_php basics
PHPCorrectly parse UTF -8 String Skills Application_php Basics
PHPBasic Knowledge Review_php Basics
The above is the detailed content of How to display hexadecimal image data on the img tag of html in PHP. For more information, please follow other related articles on the PHP Chinese website!