构建PHP脚本以创建新图像

构建PHP脚本以创建新图像,php,html,image,Php,Html,Image,我正在为我的个人网站创建一个新脚本的路上。我想要一种功能,访问者可以在输入字段中写入内容,然后按生成图像 然后脚本应拍摄背景图像,并在顶部插入访问者文本 我的问题是:实际生成图像文件的php代码是什么?如何将输入数据连接到图像 如果您没有时间,我不需要完整的代码示例,我只需要如何设置这样一个系统的基本实践 请尝试以下代码: $filename = "layout.jpg"; $im = @imagecreatefromjpeg($filename); $font = "tahoma.ttf";

我正在为我的个人网站创建一个新脚本的路上。我想要一种功能,访问者可以在输入字段中写入内容,然后按生成图像

然后脚本应拍摄背景图像,并在顶部插入访问者文本

我的问题是:实际生成图像文件的php代码是什么?如何将输入数据连接到图像

如果您没有时间,我不需要完整的代码示例,我只需要如何设置这样一个系统的基本实践

请尝试以下代码:

$filename = "layout.jpg";

$im = @imagecreatefromjpeg($filename);
$font = "tahoma.ttf";

$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);

imagettftext($im, 15, 0, 50, 50, $black, $font, $_POST['message_from_user']);

header('Content-Type: image/jpeg');

imagejpeg($im, null, 100);
imagedestroy($im);
layout.jpg是背景图像,tahoma.ttf是字体文件

两个文件应放在同一文件夹中

此代码将生成带有用户字符串的jpg图像

通过搜索“php中的gd”可以获得更多详细信息。

请尝试以下代码:

$filename = "layout.jpg";

$im = @imagecreatefromjpeg($filename);
$font = "tahoma.ttf";

$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);

imagettftext($im, 15, 0, 50, 50, $black, $font, $_POST['message_from_user']);

header('Content-Type: image/jpeg');

imagejpeg($im, null, 100);
imagedestroy($im);
layout.jpg是背景图像,tahoma.ttf是字体文件

两个文件应放在同一文件夹中

此代码将生成带有用户字符串的jpg图像

通过搜索“php中的gd”可以获得更多详细信息。

请尝试以下代码:

$filename = "layout.jpg";

$im = @imagecreatefromjpeg($filename);
$font = "tahoma.ttf";

$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);

imagettftext($im, 15, 0, 50, 50, $black, $font, $_POST['message_from_user']);

header('Content-Type: image/jpeg');

imagejpeg($im, null, 100);
imagedestroy($im);
layout.jpg是背景图像,tahoma.ttf是字体文件

两个文件应放在同一文件夹中

此代码将生成带有用户字符串的jpg图像

通过搜索“php中的gd”可以获得更多详细信息。

请尝试以下代码:

$filename = "layout.jpg";

$im = @imagecreatefromjpeg($filename);
$font = "tahoma.ttf";

$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);

imagettftext($im, 15, 0, 50, 50, $black, $font, $_POST['message_from_user']);

header('Content-Type: image/jpeg');

imagejpeg($im, null, 100);
imagedestroy($im);
layout.jpg是背景图像,tahoma.ttf是字体文件

两个文件应放在同一文件夹中

此代码将生成带有用户字符串的jpg图像


通过搜索“php中的gd”可以获得更多详细信息。

执行以下操作:

$text = 'put ur txt here'; 

$height = 25; 

$width = 65; 

$image_p = imagecreate($width, $height); 

$black = imagecolorallocate($image_p, 0, 0, 0); 

$white = imagecolorallocate($image_p, 255, 255, 255); 

$font_size = 14; 



imagestring($image_p, $font_size, 5, 5, $text, $white); 

imagejpeg($image_p, 'file name here', 80); 

这样做:

$text = 'put ur txt here'; 

$height = 25; 

$width = 65; 

$image_p = imagecreate($width, $height); 

$black = imagecolorallocate($image_p, 0, 0, 0); 

$white = imagecolorallocate($image_p, 255, 255, 255); 

$font_size = 14; 



imagestring($image_p, $font_size, 5, 5, $text, $white); 

imagejpeg($image_p, 'file name here', 80); 

这样做:

$text = 'put ur txt here'; 

$height = 25; 

$width = 65; 

$image_p = imagecreate($width, $height); 

$black = imagecolorallocate($image_p, 0, 0, 0); 

$white = imagecolorallocate($image_p, 255, 255, 255); 

$font_size = 14; 



imagestring($image_p, $font_size, 5, 5, $text, $white); 

imagejpeg($image_p, 'file name here', 80); 

这样做:

$text = 'put ur txt here'; 

$height = 25; 

$width = 65; 

$image_p = imagecreate($width, $height); 

$black = imagecolorallocate($image_p, 0, 0, 0); 

$white = imagecolorallocate($image_p, 255, 255, 255); 

$font_size = 14; 



imagestring($image_p, $font_size, 5, 5, $text, $white); 

imagejpeg($image_p, 'file name here', 80); 

检查你的phpinfo()也许你已经安装好了。Rest是自我解释StackOverflow不做你的工作。在试图解决你的问题时,你至少应该表现出最小的自我努力。我觉得我的问题在这些范围之内。我只要求提供这种系统的基本设置。先生们只是提供了一些代码。检查你的phpinfo()也许你已经安装好了。Rest是自我解释StackOverflow不做你的工作。在试图解决你的问题时,你至少应该表现出最小的自我努力。我觉得我的问题在这些范围之内。我只要求提供这种系统的基本设置。先生们只是提供了一些代码。检查你的phpinfo()也许你已经安装好了。Rest是自我解释StackOverflow不做你的工作。在试图解决你的问题时,你至少应该表现出最小的自我努力。我觉得我的问题在这些范围之内。我只要求提供这种系统的基本设置。先生们只是提供了一些代码。检查你的phpinfo()也许你已经安装好了。Rest是自我解释StackOverflow不做你的工作。在试图解决你的问题时,你至少应该表现出最小的自我努力。我觉得我的问题在这些范围之内。我只要求提供这种系统的基本设置。先生们只是提供了一些代码。谢谢您的时间和解释。我试试这个。谢谢你的时间和解释。我试试这个。谢谢你的时间和解释。我试试这个。谢谢你的时间和解释。我试试这个。谢谢你的时间和解释。我试试这个。谢谢你的时间和解释。我试试这个。谢谢你的时间和解释。我试试这个。谢谢你的时间和解释。我试试这个。