我必须创建一种PHP,以恢复一个透明狗的形象流(PNG或GIF)。
你们能否给我一个容易使用的解决办法?
我必须创建一种PHP,以恢复一个透明狗的形象流(PNG或GIF)。
你们能否给我一个容易使用的解决办法?
翻译:1x1 PNG:
header( Content-Type: image/png );
echo base64_decode( iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII= );
翻译:1x1 GIF:
header( Content-Type: image/gif );
echo base64_decode( R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw== );
在PHP 5.4和更高一级,可以使用hex2bin,这比基64_decode(在下文中用空白GIF文档测试)。 产出图像编码是:
翻译:1x1 PNG:
header( Content-Type: image/png );
die(hex2bin( 89504e470d0a1a0a0000000d494844520000000100000001010300000025db56ca00000003504c5445000000a77a3dda0000000174524e530040e6d8660000000a4944415408d76360000000020001e221bc330000000049454e44ae426082 ));
翻译:1x1 GIF:
header( Content-Type: image/gif );
die(hex2bin( 47494638396101000100900000ff000000000021f90405100000002c00000000010001000002020401003b ));
您可以很容易地将第64类编码数据转换成六dec:
echo bin2hex(base64_decode($data));
或档案:
echo bin2hex(base64_decode(file_get_contents($filename)));
然而,根据我的基准,使用“Lukas Liesis”建议的本土PHP越轨方法是最快的,比第64-decode条快12.5倍。 它将几乎与任何版本的购买力平价合作。 这里是《法典》的版本:
翻译:1x1 PNG:
header( Content-Type: image/png );
die("x89x50x4ex47x0dx0ax1ax0ax00x00x00x0dx49x48x44x52x00x00x00x01x00x00x00x01x01x03x00x00x00x25xdbx56xcax00x00x00x03x50x4cx54x45x00x00x00xa7x7ax3dxdax00x00x00x01x74x52x4ex53x00x40xe6xd8x66x00x00x00x0ax49x44x41x54x08xd7x63x60x00x00x00x02x00x01xe2x21xbcx33x00x00x00x00x49x45x4ex44xaex42x60x82");
翻译:1x1 GIF:
header( Content-Type: image/gif );
die("x47x49x46x38x39x61x01x00x01x00x90x00x00xffx00x00x00x00x00x21xf9x04x05x10x00x00x00x2cx00x00x00x00x01x00x01x00x00x02x02x04x01x00x3b");
定期表述(如一劳永逸地工作)很容易形成这样的鸿沟:
echo preg_replace( /../ , \x ,bin2hex($data));
或从档案中提取:
echo preg_replace( /../ , \x ,bin2hex(file_get_contents($filename)));
回答一些人的问题:
你必须反映形象的内容。 标题只是表明,你正在把图像退回浏览器,而不是正常文本。 因此,如果你只回头,那就只是头脑——没有数据。 然而,印刷图像数据并做成,你只是寄出一个形象:
阅读档案并不好,但会更好回馈Sjoerd主要答复中显示的原始数据。 这样,你就可以节省不必处理阅读操作的时间和服务器负荷。 阅读磁盘是一项缓慢的任务。 随着时间的推移,从磁盘上读书的速度加快,但从I/O到磁盘的读数仍然更好。
我甚至没有第64条码,但这一形象有白色的颜色:
header( Content-Type: image/gif );
// 1x1px white gif
die("x47x49x46x38x37x61x1x0x1x0x80x0x0xfcx6ax6cx0x0x0x2ax0x0x0x0x1x0x1x0x0x2x2x44x1x0x3b");
难道有人会知道如何将任何档案转换成这种数据?
header( Content-Type: image/gif );
printf( %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c% , 71, 73, 70, 56, 57, 97, 1, 0, 1, 0, 128, 255, 0, 192, 192, 192, 0, 0, 0, 33, 249, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 68, 1, 0, 59);
在短链氯化石蜡中,你可以通过在黄色打字来转换:
hexdump -v -e "\x" 1/1 "%X" image.gif; echo
I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
I found this script online that creates a thumbnail out of a image but the thumbnail image is created with poor quality how can I improve the quality of the image. And is there a better way to create ...
如何确认来自正确来源的数字。
Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...
I wonder there is a way to post a message to a facebook business page with cURL? thanks
I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...
How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...