根据标题关键字生成图片实现优质图片PHP代码
2022/4/13 14:12:58
本文主要是介绍根据标题关键字生成图片实现优质图片PHP代码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
$bgimg = "./image/" . $numrand . ".jpg"; $bg_info = getimagesize($bgimg); $bg_type = image_type_to_extension($bg_info[2], false); $func = "imagecreatefrom" . $bg_type; $bg_image = $func($bgimg); $numrand2 = rand(1, 6); $tu1 = "./image/" . $numrand2 . ".png"; $tu1_info = getimagesize($tu1); $tu1_type = image_type_to_extension($tu1_info[2], false); $tu1_func = "imagecreatefrom" . $tu1_type; $tu1_image = $tu1_func($tu1); imagecopy($bg_image, $tu1_image, 100, 50, 0, 0, 600, 400); $tu2 = "./image/" . $numrand2 . ".png"; $tu2_mark = getimagesize($tu2); $tu2_type = image_type_to_extension($tu2_mark[2], false); $tu2_func = "imagecreatefrom" . $tu2_type; $tu2_image = $tu2_func($tu2); imagecopy($bg_image, $tu2_image, 583, 1193, 0, 0, 258, 261); $gettxtone = mb_substr($get, 0, 12, "utf-8"); $gettxttwo = mb_substr($get, 12, 13, "utf-8"); $gettxtthree = mb_substr($get, 25, 13, "utf-8"); $text1 = preg_split("/(?<!^)(?!$)/u", $gettxtone); $text2 = preg_split("/(?<!^)(?!$)/u", $gettxttwo); $text3 = preg_split("/(?<!^)(?!$)/u", $gettxtthree); if (($waterturn == 1)) { $waterfont = $watertitle; $waterfont = preg_split("/(?<!^)(?!$)/u", $waterfont); } $color = imagecolorallocate($bg_image, 255, 255, 255); $font = "./font/" . $fontrand . ".ttf"; $font_lposition = [110, 60]; $font_tposition = [220, 120]; $height = $height + $h * $size; $titlelenth = strlen($title); if ($titlelenth > 20) { $x = 130; $y = 220; } else { $x = 200; $y = ($height - imagefontheight($size)) / 2; } $size = 40; $y2 = $y + 60; $x2 = 110; $y3 = $y2 + 60; $x3 = $x2; foreach ($text1 as $k => $v) { imagettftext($bg_image, $size, 0, $x, $y, $color, $font, $v); $x = $x + 45; } foreach ($text2 as $k => $v) { imagettftext($bg_image, $size, 0, $x2, $y2, $color, $font, $v); $x2 = $x2 + 45; } foreach ($text3 as $k => $v) { imagettftext($bg_image, $size, 0, $x3, $y3, $color, $font, $v); $x3 = $x3 + 45; } if ($waterfont) { foreach ($waterfont as $k => $v) { imagettftext($bg_image, $size, 0, $waterx, $watery, $color, $font, $v); $waterx = $waterx + 45; } } header("Content-type:image/png"); imagepng($bg_image); imagedestroy($bg_image); imagedestroy($bg_image); imagedestroy($tu1_image); imagedestroy($tu2_image); session_start(); header("Cache-Control: private, max-age=10800, pre-check=10800"); header("Pragma: private"); header("Expires: " . date(DATE_RFC822, strtotime(" 2 day")));
根据标题关键字生成图片实现优质图片PHP代码,随笔记录。
本文转自万象文库www.2wx.com。
这篇关于根据标题关键字生成图片实现优质图片PHP代码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-11开源 PHP 商城项目 CRMEB 二次开发和部署教程
- 2024-11-09怎么使用php在kaufland平台刊登商品?-icode9专业技术文章分享
- 2024-11-05PHP的抽象类和接口是什么,有什么区别-icode9专业技术文章分享
- 2024-11-01开源 PHP 商城项目 CRMEB 安装和使用教程
- 2024-11-01用php和mysql写无限分类,有哪几种方法-icode9专业技术文章分享
- 2024-10-31php数据分表导出时部分数据无法导出什么原因-icode9专业技术文章分享
- 2024-10-30有经验的 PHP 开发者学习一门新的编程语言,有哪些推荐的有前景的语言-icode9专业技术文章分享
- 2024-10-21php 检测图片是否篡改过-icode9专业技术文章分享
- 2024-10-20fruitcake/php-cors 该怎么使用-icode9专业技术文章分享
- 2024-10-18PHP7.1可以使用哪个版本的swoole-icode9专业技术文章分享