首頁 >後端開發 >php教程 >PHP憑證圖片產生 php 輸出圖片 php 產生圖片 php 圖片合

PHP憑證圖片產生 php 輸出圖片 php 產生圖片 php 圖片合

WBOY
WBOY原創
2016-07-29 08:48:542232瀏覽

<code><span>$realname</span><span>=</span><span>"姓名"</span>;
<span>$schoolname</span><span>=</span><span>"学校"</span>;  
<span>$idcard</span><span>=</span><span>"身份证号"</span>; 

<span>$image</span><span>=</span> imagecreatefrompng(<span>'certification.png'</span>);           <span>// 证书模版图片文件的路径 </span><span>$red</span><span>=</span> imagecolorallocate(<span>$image</span>,<span>00</span>,<span>00</span>,<span>00</span>);                 <span>// 字体颜色</span><span>// imageTTFText("Image", "Font Size", "Rotate Text", "Left Position","Top Position", "Font Color", "Font Name", "Text To Print");</span>
imageTTFText(<span>$image</span>, <span>50</span>, <span>0</span>, <span>1110</span>, <span>1025</span>, <span>$red</span>, <span>'字体路径'</span>,<span>$realname</span>);
imageTTFText(<span>$image</span>, <span>50</span>, <span>0</span>, <span>1000</span>, <span>1023</span>, <span>$red</span>, <span>'字体路径'</span>, <span>$schoolname</span>);
imageTTFText(<span>$image</span>, <span>55</span>, <span>0</span>, <span>900</span>, <span>810</span>, <span>$red</span>, <span>'字体路径(/usr/share/fonts/truetype/ttf-dejavu/simhei.ttf)'</span>, <span>$idcard</span>);

 <span>/* 直接显示在浏览器 */</span><span>header</span>(<span>'Content-type: image/png;'</span>);
ImagePng(<span>$image</span>);
imagedestroy(<span>$image</span>);


<span>/* 如果需要保存 */</span><span>$filename</span><span>=</span><span>'certificate_aadarsh.png'</span>;
ImagePng(<span>$image</span>, <span>$filename</span>);
imagedestroy(<span>$image</span>);


<span>/* 如果需要下载 */</span><span>$filename</span><span>=</span><span>'certificate_aadarsh.png'</span>;
ImagePng(<span>$image</span>,<span>$filename</span>);
<span>header</span>(<span>'Pragma: public'</span>);
<span>header</span>(<span>'Cache-Control: public, no-cache'</span>);
<span>header</span>(<span>'Content-Type: application/octet-stream'</span>);
<span>header</span>(<span>'Content-Length: '</span><span>.</span> filesize(<span>$filename</span>));
<span>header</span>(<span>'Content-Disposition: attachment; filename="'</span><span>.</span>
 basename(<span>$filename</span>) <span>.</span><span>'"'</span>);
<span>header</span>(<span>'Content-Transfer-Encoding: binary'</span>);
readfile(<span>$filename</span>);
imagedestroy(<span>$image</span>);</code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介紹了PHP憑證圖片生成,包含了php,書圖片方面的內容,希望對PHP教學有興趣的朋友有幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn