
php--如何使用用户输入的信息生成图像有文字水印
发布日期:2021-05-06 21:18:42
浏览次数:20
分类:原创文章
本文共 2820 字,大约阅读时间需要 9 分钟。
<?php/** * Created by PhpStorm. */if(!$_POST){?><html><head> <title>Image Creation From</title> <style type="text/css"> fieldset { border: 0; padding: 0 0 18px 0; } fieldset label { margin-left: 24px; } legend, label { font-weight: bold } </style></head><body><h1>Create an Image</h1><form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>Image Size</legend> <label for="w">W:</label> <input type="text" id="w" name="w" size="5" maxlength="5"> <label for="h">H:</label> <input type="text" id="h" name="h" size="5" maxlength="5"> </fieldset> <fieldset> <legend>Background Color:</legend> <label for="b_r">R:</label> <input type="text" id="b_r" name="b_r" size="3" maxlength="3"> <label for="b_g">G:</label> <input type="text" id="b_g" name="b_g" size="3" maxlength="3"> <label for="b_b">B:</label> <input type="text" id="b_b" name="b_b" size="3" maxlength="3"> </fieldset> <fieldset> <legend>Text Color:</legend> <label for="t_r">R:</label> <input type="text" id="t_r" name="t_r" size="3" maxlength="3"> <label for="t_g">G:</label> <input type="text" id="t_g" name="t_g" size="3" maxlength="3"> <label for="t_b">B:</label> <input type="text" id="t_b" name="t_b" size="3" maxlength="3"> </fieldset> <p><label for="string">Text String:</label> <input type="text" id="string" name="string" size="35"> </p> <p><label for="font_size">Font Size:</label> <select id="font_size" name="font_size"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </p> <fieldset> <legend>Text Starting Position:</legend> <label for="x">X:</label> <input type="text" id="x" name="x" size="3" maxlength="3"> <label for="y">Y:</label> <input type="text" id="y" name="y" size="3" maxlength="3"> </fieldset> <button type="submit" name="submit" value="create">Create Image</button></form></body></html><?php } else { $my_image = imagecreate($_POST['w'],$_POST['h']); $background = imagecolorallocate($my_image,$_POST['b_r'], $_POST['b_g'],$_POST['b_b']); $text_color = imagecolorallocate($my_image,$_POST['t_r'] ,$_POST['t_g'],$_POST['t_b']); imagestring($my_image,$_POST['font_size'], $_POST['x'],$_POST['y'],$_POST['string'],$text_color); header('Content-type:image/png'); imagepng($my_image); imagedestroy($my_image); }?>
发表评论
最新留言
做的很好,不错不错
[***.243.131.199]2025年04月12日 13时50分23秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
【MySQL】(九)触发器
2019-03-05
Oracle 11G环境配置
2019-03-05
【Python】(十二)IO 文件处理
2019-03-05
【Oozie】(三)Oozie 使用实战教学,带你快速上手!
2019-03-05
师兄面试遇到这条 SQL 数据分析题,差点含泪而归!
2019-03-05
C语言的数值溢出问题(上)
2019-03-05
BottomNavigationView控件item多于3个时文字不显示
2019-03-05
函数指针的典型应用-计算函数的定积分(矩形法思想)
2019-03-05
8051单片机(STC89C52)以定时器中断模式实现两倒计时器异步计时
2019-03-05
用 wxPython 打印你的 App
2019-03-05
vue项目通过vue.config.js配置文件进行proxy反向代理跨域
2019-03-05
Linux下安装MySql过程
2019-03-05
android:使用audiotrack 类播放wav文件
2019-03-05
vue通过better-scroll 封装自定义的下拉刷新组件
2019-03-05
android解决:使用多线程和Handler同步更新UI
2019-03-05
Element UI 中动态路由的分析及实现
2019-03-05
使用springMVC配置视图管理器后找不到指定的页面
2019-03-05
杭电 2007 平方和与立方和(输入数据的大小顺序并不能默认)
2019-03-05
十大排序算法之三:插入排序(Python)
2019-03-05
利用Python实现循环队列
2019-03-05