首页 > 编程知识 正文

php文字生成图片,css添加图片代码

时间:2023-05-04 18:23:36 阅读:169518 作者:1345

摘要: image copy merge (资源dst_im,资源$ src _ im,int $dst_x,int $dst_y,int $src_x,int $src_x 两图像基于pct决定合并程度,其取值范围从0到100。 pct=0时,实际上什么也没做。

imagecopymerge(resource$dst_im,resource$src_im,int$dst_x,int$dst_y,int$src_x,int $ src _ im

src_im将图像中的坐标从src_x、src_y开始、宽度为src_w、高度为src_h的一部分复制到dst_im图像中的坐标为dst_x和dst_y的位置。 两图像基于pct决定合并程度,其取值范围从0到100。 pct=0时,实际上什么都没做。 如果为100,则调色板图像的本函数与imagecopy ) )完全相同,为真彩色图像提供alpha透明度,实际上是控制水印图像的透明度。

具体的实现代码? php

//要添加水印的图像的路径

$ src _ path=' images/20181127112131649.png ';

//水印图像路径

$金菇_path='金菇s/it金菇. png ';

//创建图像的实例

$ src=imagecreatefromstring (file _ get _ contents ) $src_path );

$金菇=imagecreatefromstring (file _ get _ contents ) $金菇_path;

//获取水印图像的宽度、高度

list($金菇_w,$金菇_h )=getimagesize($ ) $金菇_path );

//获取图像的宽度、高度

list($src_w,$src_h )=getimagesize ) $src_path );

$src_name=basename($src_path );

//将水印图像复制到目标图像,最后的参数50通过设定透明度,在这里实现半透明效果

imagecopymerge($src,$心动香菇,($src_w-$心动香菇_w-5 ),) $src_h-$心动香菇_h-5 ),0,0,0

//水印图像本身带有透明色时,使用imagecopy方法

//imagecopy($src,$金菇,10,10,0,0,$金菇_w,$金菇_h );

//输出图像

list($src_w,$src_h,$src_type )=getimagesize ) $src_path );

sitch($src_type ) {

case1://GIF

头(content-type : image/gif );

imagegif($src,' nimages/'.$src_name );

黑;

case2://JPG

头(content-type : image/JPEG );

imageJPEG($src,' nimages/'.$src_name );

黑;

case3://PNG

头(content-type : image/png );

imagepng($src,' nimages/'.$src_name );

黑;

默认:

黑;

}

imagedestroy($src;

imagedestroy($心跳的香菇);

水印效果:

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。