Home > Backend Development > PHP Tutorial > PHP certificate image generation php output image php generate image php image combination

PHP certificate image generation php output image php generate image php image combination

WBOY
Release: 2016-07-29 08:48:54
Original
2249 people have browsed it

<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>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the PHP certificate image generation, including PHP and book image content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template