PHP - Create base64 encoded image from String -


i have array contain strings , want display them in image format (each image contain string). need display image in format: <img src="data:image/png;base64,...<data>..."/>, images in html page. how create base64 encoded image string?

i tried search google, there tutorials "create base64 encoded image image file".

example: if text "600153957", output be:

<img src="data:image/png;base64,ivborw0kggoaaaansuheugaaad4aaaaocaiaaad42ti+aaadv0leqvriidvwt0gqaxq/14zbryamsslehekshyrevawuqktetrlioovetigwluqiwqsfyxzuahmmcjgqfujcypw4cjeieziwfqviigvcmflmog/xdeeaxexxfu9xf6vd7zu/7/yz7xzmbylcnwnz/53av8ex1a8odtrq9fpz838wfmfhoa+vb3z29urqqpvpx8fhxz/x5qb/olkpmayzsrkcbugkekql0m63p1kpf8jzhhd0disizwbtbdarvcqztla2tvb09otxedqaduvrugie5wegeok4ha69xt9snr8lezfhgcnb+fl5kdav1jexlxmgqvareiokokajsdvt8xicoqh4pn6bj0ajabambhgxxq/tnk1sqrworzgcbjabbrc7go0megkaodw8rmszmznjyulezofzahb6evpdiijx19e5xc4wiwga0+n8futqou3tfr+/vywcimhksnk5jihwq9vqtfbm3w63lho4hfyqlbvadb9icxeraarbqes5xl66uoqijuydapb29noiw+gwvpnnlgkfqieakmlkjpojvi+idodjamqk2d6fj2xz3jwisqmbtkajiym7uzvp6o3tjdrmnptfuurelmw3t7clysgu+q2qwgazurtvxtlnmcatszzlu6mu0+l0uvwpdw8achfxytkzianfufv6ndjd+hbqnf0qlqwgw87odga8pj4ajubywarbucguaod1ekul0svly/7+pgdo9frvqolx19dmjmoxwnrqdeeyqlqqmj3k25fhrlhu5uymcfb6vqzdelsb3951rkzvaltbwwcqsqvubm4aqc6xa4bwqyutjyqizwatspxgrf1imjote+lfdxa91wondq0bagmhkioa0n/f32q1impl5axracr2n74darxa7/cdqkfqgb0dvb+/f39/lxqk5xkzdlrcotg7o8vn8wmdax6pz3bw8luqmol0ggdsdnv7/z+pj42nkxtjbpiengaaubm5yreiale3t8viuvj2478jgawcamdxadaymgiaywqsaeibchiebzqau7u73yqakmvlddrd+pj4l9ulmtuydlfyjgvzjumimc1mazowbmfiscjlcrjsevdtdyabzs4tlqea2vrvajwdthpgyrgqfy6ix8fhabcjrkqbooqecrl8fx29y3a/u2+1wj6fj2eyjumqlyp0zpp88pawy7ls8u7nu91usjrclpdwq+v5nvcztizhgj1ofwgego2g5b8ibdy2ntpv6basmm3m8/pzjtr/4b/7+/u3c4fonnbzzriaaaaasuvork5cyii="> 

live example: http://goo.gl/mybui . want protect numbers website. way, spam software scan text find numbers can't read them.

please me! sorry bad english.

this rough example of how want, need generate image php using whatever data want , file contents string

you'll idea if run code is.

<?php      function b64img( $str, $fs=10, $w=250, $h=200, $b=array( 'r'=>255, 'g'=>255, 'b'=>255 ), $t=array('r'=>0, 'g'=>0, 'b'=>0) ){         $tmp=tempnam( sys_get_temp_dir(), 'img' );          $image = imagecreate( $w, $h );         $bck = imagecolorallocate( $image, $b['r'], $b['g'], $b['b'] );         $txt = imagecolorallocate( $image, $t['r'], $t['g'], $t['b'] );          imagestring( $image, $fs, 0, 0, $str, $txt );         imagepng( $image, $tmp );         imagedestroy( $image );          $data=base64_encode( file_get_contents( $tmp ) );         @unlink( $tmp );         return $data;     }       $img=b64img( 'some text make base64 image', 6, 400, 100 );     echo "<img src='data:image/png;base64, {$img}' />";      $img=b64img( 'another image', 10, 200, 200, array('r'=>0, 'g'=>255, 'b'=>0), array('r'=>255, 'g'=>0, 'b'=>0) );     echo "<img src='data:image/png;base64, {$img}' />"; ?> 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -