美文网首页
phpGD库函数之文字水印效果

phpGD库函数之文字水印效果

作者: 咸鱼前端 | 来源:发表于2019-06-20 16:31 被阅读0次
<?php
$filename = 'images/1.jpg';
$fileInfo = getimagesize($filename);
$width = $fileInfo[0];
$height = $fileInfo[1];
$mime = $fileInfo['mime'];
$ext = image_type_to_extension($fileInfo[2]);

$createFun = str_replace('/', 'createfrom', $mime);
$outFun = str_replace('/', '', $mime);
$image = $createFun($filename);
$red = imagecolorallocatealpha($image, 255, 0, 0, 70);
$textHeight = imagefontheight(30);
$fontfile = 'fonts/PingFang.TTF';
imagettftext($image, 30, 0, 0, $height - $textHeight, $red, $fontfile, "我是你爸爸");
header('content-type:' . $mime);
$outFun($image);
imagedestroy($image);

相关文章

网友评论

      本文标题:phpGD库函数之文字水印效果

      本文链接:https://www.haomeiwen.com/subject/ypejqctx.html