Heim >Backend-Entwicklung >PHP-Tutorial >PHP证书图片生成 php 输出图片 php 生成图片 php 图片合

PHP证书图片生成 php 输出图片 php 生成图片 php 图片合

WBOY
WBOYOriginal
2016-07-29 08:48:542231Durchsuche

<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教程有兴趣的朋友有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn