课程/PHP/后端开发
GD库实现图片水印与缩略图
-
-
小尾巴都糊了
2017-11-29
- <?php
/*打开图片*/
//1.配置图片路径
$src_url = "image/GD_test.png";
//2.获取图片信息
$info = getimagesize($src_url);
// echo "<pre>";
//print_r($info);
//3.通过图片编号来确认图片类型,取消false参数获取值为 .png ;
$type = image_type_to_extension($info[2],false);
// print_r($type);
//4.在内存中创建一个和打开图片类型一样的图像
$fun = "imagecreatefrom{$type}"; //相当于 $fun = imagecreatefrompng();
//5.把图片复制到内存中
$image = $fun($src_url); //相当于 imagecreatefrompng($src)
/*操作图片*/
//1.设置字体路径
$font = "image/msyhl.ttc";
//2.填写水印内容
$content = "xiaoweiba.ml";
//3.设置字体颜色RGB值和透明度,
//参数1:内存中的图片; 参数2:颜色; 参数3:透明度
//注意!!! png图片无法正常渲染字体颜色!!!!
$col = imagecolorallocatealpha($image,0,0,0,15);
-
0赞 · 0采集
-
-
小尾巴都糊了
2017-11-29
-
imagettftext($image,20,0,20,30,$col,$font,$content);
/*输出图片*/
//1.浏览器输出
header("Content-type:".$info['mime']);
$func = "image{$type}"; //如果是jpeg就调用 imagejpeg()方法,如果是peg就会调用imagepng()方法
$func($image);
//2.保存图片
$func($image,'image/newimage.'.$type); //imagepng($image,'image/newimage.png');
//显示图片
//输出生成的图片,配置文件路径
$src_new = "image/newimage.png";
//无法直接输出图片,必须将图片复制到内存中。
$fun_new = imagecreatefrompng($src_new);
//输出图片
imagepng($fun_new); // imagepng(imagecreatefrompng("image/newimage.png"));
/*销毁图片*/
imagedestroy($image);
imagedestroy($fun_new);
?>
-
0赞 · 0采集
-
-
Gigure
2017-09-27
- B.操作图片
(1)设置字体的路径 $font = '..ttf';
(2)设置文字水印内容 $content = '你好,php';
(3)设置 源图片所在画布 将使用的颜色(相当于为画布分配画笔颜色),
$col= imagecolorallocatealpha($image,255,255,255,50) //$image为源图片 三个255表示颜色(RGB类型) 50表示透明度
(4)写入水印文字 imagetfftext($image,'字体大小','旋转角','x轴偏移量','y轴偏移量',$col,$font,$content,)
-
0赞 · 0采集
-
-
黄枪枪
2017-03-18
- B.操作图片
(1)设置字体的路径 $font = '..ttf';
(2)设置文字水印内容 $content = '你好,php';
(3)设置 源图片所在画布 将使用的颜色(相当于为画布分配画笔颜色),
$col= imagecolorallocatealpha($image,255,255,255,50) //$image为源图片 三个255表示颜色(RGB类型) 50表示透明度
(4)写入水印文字 imagetfftext($image,'字体大小','旋转角','x轴偏移量','y轴偏移量',$col,$font,$content,)
-
0赞 · 0采集
-
-
日月晓风
2017-02-07
- php 图片输入文字
-
截图
0赞 · 0采集
-
-
采风Mooc
2017-01-20
- 2 操作图片--
-
截图
0赞 · 0采集
-
-
侠客岛的含笑
2016-11-26
- 没啥好记的,截图上都有
-
截图
0赞 · 1采集
-
-
im
2016-11-21
- 操作图片
-
截图
0赞 · 1采集
-
-
bo giǎng
2016-11-03
- 2.操作图片<br><br>
(1)设置字体的路径 $font = '..ttf';<br><br>
(2)设置水印内容 $content = '你好,php';<br><br>
(3)设置字体的颜色,透明度$col= imagecolorallocatealpha($image,255,255,255,50)//$image是内存中的图片切记<br>
(4)写入水印文字 imagetfftext($image,'字体大小','旋转角','x轴偏移量','y轴偏移量',$col,$font,$content,)
-
0赞 · 0采集
-
-
流浪佳人纳入怀
2016-10-29
- 文字水印--2操作图片2.1设置字体路径2.2填写水印内容2.3设置字体颜色RGB和透明度:参数1内存中的图片2.3.4.RGB颜色三个值5.透明度4写入文字
-
截图
0赞 · 0采集
-
-
小安Andrew
2016-10-14
- imagetext需要写入的参数
-
截图
0赞 · 0采集
-
-
RenneXV
2016-03-15
- imagetftext()添加文字.
-
截图
0赞 · 0采集
-
-
RenneXV
2016-03-15
- 打开图片,
-
截图
0赞 · 0采集
-
-
phpcreate
2016-03-08
- 2.操作图片<br><br>
(1)设置字体的路径 $font = '..ttf';<br><br>
(2)设置水印内容 $content = '你好,php';<br><br>
(3)设置字体的颜色,透明度$col= imagecolorallocatealpha($image,255,255,255,50)//$image是内存中的图片切记<br>
(4)写入水印文字 imagetfftext($image,'字体大小','旋转角','x轴偏移量','y轴偏移量',$col,$font,$content,)
-
2赞 · 3采集
-
-
林静听蝉
2015-10-11
- //2.操作图片
//2.1设置字体的路径
$font = "msyh.ttf";
//2.2填写我们的水印内容
$content = "萌物语moe__1010";
//2.3设置字体的颜色RGB和透明度:参数1(内存中的图片),参数2(颜色)
$col = imagecolorallocatealpha($image, 255, 255, 255, 50);
//2.4写入文字
imagettftext($image, 20, 0, 20, 30, $col, $font, $content);
-
截图
0赞 · 0采集
-
-
vonmarshall
2015-10-08
- 文字水印 操作图片
-
截图
0赞 · 1采集
-
-
Virture
2015-09-22
- 代码段
-
截图
0赞 · 0采集
-
-
dbstream
2015-08-13
- 把图像写入内存
-
0赞 · 0采集
-
-
Crimson
2015-05-10
- 向图片写入内容
-
截图
0赞 · 1采集
-
-
墨西哥鸡味卷
2015-03-02
- 操作完成
-
截图
0赞 · 0采集
-
-
墨西哥鸡味卷
2015-03-02
- rray imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )用 TrueType 字体将 指定的 text 写入图像。
-
0赞 · 0采集
-
-
墨西哥鸡味卷
2015-03-02
- int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha )为一幅图像分配颜色
-
0赞 · 0采集
-
-
墨西哥鸡味卷
2015-03-02
- int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha )为一幅图像分配颜色
-
0赞 · 0采集
-
-
王凯1994
2015-02-26
- 操作图片
-
截图
0赞 · 0采集
-
-
TraJoe_Wu
2015-02-25
- int imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha )为一幅图像分配颜色
array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )用 TrueType 字体将 指定的 text 写入图像。
-
0赞 · 0采集