This article introduces the generation of watermark images and thumbnails (PHP). Now I share it with everyone. Friends in need can take a look.
<?php /** * 生成水印图片 */ //1.获取图片资源 $big = imagecreatefromjpeg('./kaola.jpg'); //大图 $small = imagecreatefrompng('./t1.png'); //水印图 //2.获取图像大小 list($bw , $bh) = getimagesize('./kaola.jpg'); list($w , $h) = getimagesize('./t1.png'); //imagecopymerge(dst_im, src_im, dst_x, dst_y, src_x, src_y, src_w, src_h, pct) //imagecopymerge("目标图","水印图","目标图的x坐标","y坐标","水印图的x","y","宽","高","透明度"); imagecopymerge($big, $small, $bw-$w, $bh-$h, 0, 0, $w, $h, 40); imagepng($big , 't4.png'); imagedestroy($big); imagedestroy($small); ################################################################################## /** * 生成缩略图 */ $big = imagecreatefromjpeg('./kaola.jpg'); list($w , $h) = getimagesize('./kaola.jpg'); //创建小画布 $small = imagecreatetruecolor($w/2, $h/2); //拷贝图像并修改大小 //imagecopyresampled(dst_image, src_image, dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h) imagecopyresampled($small, $big, 0, 0, 0, 0, $w/2, $h/2, $w, $h); imagepng($small , './t6.png'); imagedestroy($big); imagedestroy($small); ?>
Function encapsulation
https://blog.csdn.net/liguanjie8/article/details/79835373
Related recommendations:
008-php generates a random verification code
The above is the detailed content of 009-Generate watermark image + generate thumbnail (PHP). For more information, please follow other related articles on the PHP Chinese website!