php,java,设计,都是相通有趣的哦!
[转贴]本人欣赏这个“钢笔手写体生成”功能
上一篇 /
下一篇 2007-05-05 23:18:38
/ 个人分类:技术
这个网友的功能实现很好玩,虽然这样的钢笔字我不喜欢,但是功能的想法效果还是很值得
学习借鉴的。报着学习的态度转贴别人的blog。张先生更象个全才,很实在的
技术。羡慕中!真是自愧不如啊。。。。。
http://blog.s135.com/read.php/237.htm
用PHP程序+GD库+TTF字体编写的一款Web版《钢笔手写体生成工具 V1.0》。源代码公开。
演示网址(可在该网址在线生成钢笔手写体文章PNG图片): http://www.s135.com/font/ 源代码及字体完整压缩包下载:
http://ishare.iask.sina.com.cn/cgi-bin/fileid.cgi?fileid=1574974 //但是不知道为什么我无法下载,我用的是
linux下的
ubuntu操作系统,firefox来下的。只能下到一半就突然完成可是却失败无法打开了。各位网友有没有谁下得到了,记得加我QQ35830757或者发一份给我,我的邮箱:jinbu2002cn@yahoo.com.cn。心存感激中!!
主体PHP程序源代码(index.php):
- <?php
-
-
-
-
-
-
-
-
-
- $text = $_POST["text"];
- if ($text != "")
- {
- $text = explode("\r\n", $text);
- $text_temp = "";
- $t = 0;
- foreach ($text as $key => $value)
- {
- $text_split = str_split($value, 50);
- foreach ($text_split as $key_split => $value_split)
- {
- $text_temp[$t] = $value_split;
- $t++;
- }
- }
- $text = $text_temp;
-
- $text_count = count($text);
-
- $fontname = "FZJLJT.FON";
- $im = imagecreate(600, $text_count * 29);
- $white = ImageColorAllocate($im, 255, 255, 255);
- $black = ImageColorAllocate($im, 0, 0, 0);
- $red = ImageColorAllocate($im, 255, 0, 0);
-
- for ($n = 0; $n < $text_count; $n++)
- {
- $value = $text[$n];
- $value_length = strlen($value);
- $value_count = 0;
- for ($i = 0; $i < $value_length; $i++)
- {
- if (ord($value{$i}) > 127)
- {
- $value_count++;
- }
- }
- if ($value_count % 2 != 0)
- {
-
-
- $text[$n] = $value . substr($text[$n + 1], 0, 1);
- $text[$n + 1] = substr($text[$n + 1], 1, strlen($text[$n + 1]) - 1);
- }
- }
- $text = implode("\r\n", $text);
- for ($n = 0; $n <= 1; $n++)
- {
- ImageTTFText($im, 18, 0, 2, 30, $black, $fontname, iconv("GBK", "UTF-8", $text));
- }
- $dir = "images/";
- if (is_dir($dir))
- {
- if ($dh = opendir($dir))
- {
- while (($file = readdir($dh)) !== false)
- {
- if (filetype($dir . $file) == "file")
- {
- unlink($dir . $file);
- }
- }
- closedir($dh);
- }
- }
- $file_name = $dir . md5($text) . ".png";
- ImagePng($im, $file_name);
- ImageDestroy($im);
- }
- else
- {
- $file_name = "welcome.png";
- }
- ?>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>钢笔手写体生成工具 V1.0</title>
- </head>
- <body bgcolor="#000000">
- <center>
- <form id="form1" name="form1" method="post" action="">
- <label>
- <font color="#FFFFFF">钢笔手写体生成工具 V1.0 by 回忆未来[张宴]</font><BR />
- </label>
- <label>
- <textarea name="text" cols="82" rows="15" id="text"></textarea>
- <BR />
- </label>
- <label>
- <input name="提交" type="submit" value="生成钢笔手写体" /><BR />
- </label>
- </form>
- <font color="#FFFFFF" size="2">请在下图上点击鼠标右键,选择“图片另存为”将生成的钢笔手写体PNG图片保存到本地。本站不作保存。</font><br>
- <img src="<?= $file_name ?>" border="0">
- </center>
- </body>
- </html>
相关阅读:
- 转帖 dp.SyntaxHighlighter:在网页中加亮显示源代码的工具 (richardlovejob, 2007-4-21)
- 在互联网上非常实用的网址链接 (richardlovejob, 2007-4-21)
- 比kses功能更强的PHP HTML/XHTML处理程序 (冬天来了, 2007-4-23)
- 在ubuntu下制作iso文件的命令 (richardlovejob, 2007-4-28)
- 一些常规ubuntu命令汉化 (richardlovejob, 2007-4-28)
- 在 Ubuntu 中安装 rpm 包 (richardlovejob, 2007-4-28)
- 看看这个是否正常?在ubuntu下的制作iso文件 (richardlovejob, 2007-4-30)
- 简单的EditPlus for JAVA配置 (richardlovejob, 2007-4-30)
- C#实现类似qq的屏幕截图程序 转 (richardlovejob, 2007-5-03)
- [转帖]有关XP与ubuntu双系统及grub引导 (richardlovejob, 2007-5-03)
导入论坛
收藏
分享给好友
管理
举报
TAG:
技术