Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image facebook图像与其他图像合并_Image_Facebook Graph Api_Merge - Fatal编程技术网

Image facebook图像与其他图像合并

Image facebook图像与其他图像合并,image,facebook-graph-api,merge,Image,Facebook Graph Api,Merge,facebook图像合并 嗨,我想开发一个facebook应用程序。它将在其中进行测验,然后将配置文件图片合并到证书图像中。结果呢 index.php文件如下所示 <?php include_once "fbmain.php"; //if user is logged in and session is valid. if ($user){ //fql query example using legacy method call and passing parameter try{ $fq

facebook图像合并

嗨,我想开发一个facebook应用程序。它将在其中进行测验,然后将配置文件图片合并到证书图像中。结果呢

index.php文件如下所示

<?php
include_once "fbmain.php";
//if user is logged in and session is valid.
if ($user){
//fql query example using legacy method call and passing parameter
try{
$fql = "select name, hometown_location, sex, pic_square from user where uid=" . $user;
//http://developers.facebook.com/docs/reference/fql/
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);
}
catch(Exception $o){
d($o);
}
}
//set page to include default is home.php
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : "home.php";
include_once "template.php";
?>
<?php
echo '<div id="namaz_content">';
echo '</div>';
echo $userInfo['picture'];
//Get the current users id
$uid = $facebook->getUser();
//create the url
$profile_pic = "http://graph.facebook.com/".$uid."/picture?width=80&height=80";
//echo the image out
echo "<img src=\"" . $profile_pic . "\" />";
echo '<img src="image.php?name=My name is Tushar&result=A%2D&taka=1000&subject=math" />';
?>
<?php
$text=$_GET['name'];
$result=$_GET['result'];
$subject=$_GET['subject'];
$taka='Tk. '.$_GET['taka'].'/-';
$dest = imagecreatefromjpeg('certificate.jpg');
$src = imagecreatefromjpeg('7e142c8d.jpg');
// Allocate A Color For The Text
$red = imagecolorallocate($dest,255,0,0);
$blue= imagecolorallocate($dest,0,0,255);
// Set Path to Font File
$font_path = 'bdquiz.ttf';
// Set Text to Be Printed On Image
// Print Text On Image
imagettftext($dest, 20, 0, 192, 240, $red, $font_path, $text);
imagettftext($dest,35, 0, 72, 380, $red, 'arial.ttf', $result);
imagettftext($dest,15, 0, 318, 420, $red, 'arial.ttf', $taka);
imagettftext($dest,15, 0, 270, 348, $blue, 'arial.ttf', $subject);
imagecopymerge($dest, $src, 468, 186, 0, 0, 80, 80, 100); //have to play with these numbers for it to work for you, etc.
//header('Content-Type: image/png');
imagejpeg($dest);
imagedestroy($dest);
imagedestroy($src);
?>

home.php如下所示

<?php
include_once "fbmain.php";
//if user is logged in and session is valid.
if ($user){
//fql query example using legacy method call and passing parameter
try{
$fql = "select name, hometown_location, sex, pic_square from user where uid=" . $user;
//http://developers.facebook.com/docs/reference/fql/
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);
}
catch(Exception $o){
d($o);
}
}
//set page to include default is home.php
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : "home.php";
include_once "template.php";
?>
<?php
echo '<div id="namaz_content">';
echo '</div>';
echo $userInfo['picture'];
//Get the current users id
$uid = $facebook->getUser();
//create the url
$profile_pic = "http://graph.facebook.com/".$uid."/picture?width=80&height=80";
//echo the image out
echo "<img src=\"" . $profile_pic . "\" />";
echo '<img src="image.php?name=My name is Tushar&result=A%2D&taka=1000&subject=math" />';
?>
<?php
$text=$_GET['name'];
$result=$_GET['result'];
$subject=$_GET['subject'];
$taka='Tk. '.$_GET['taka'].'/-';
$dest = imagecreatefromjpeg('certificate.jpg');
$src = imagecreatefromjpeg('7e142c8d.jpg');
// Allocate A Color For The Text
$red = imagecolorallocate($dest,255,0,0);
$blue= imagecolorallocate($dest,0,0,255);
// Set Path to Font File
$font_path = 'bdquiz.ttf';
// Set Text to Be Printed On Image
// Print Text On Image
imagettftext($dest, 20, 0, 192, 240, $red, $font_path, $text);
imagettftext($dest,35, 0, 72, 380, $red, 'arial.ttf', $result);
imagettftext($dest,15, 0, 318, 420, $red, 'arial.ttf', $taka);
imagettftext($dest,15, 0, 270, 348, $blue, 'arial.ttf', $subject);
imagecopymerge($dest, $src, 468, 186, 0, 0, 80, 80, 100); //have to play with these numbers for it to work for you, etc.
//header('Content-Type: image/png');
imagejpeg($dest);
imagedestroy($dest);
imagedestroy($src);
?>

php文件如下所示

<?php
include_once "fbmain.php";
//if user is logged in and session is valid.
if ($user){
//fql query example using legacy method call and passing parameter
try{
$fql = "select name, hometown_location, sex, pic_square from user where uid=" . $user;
//http://developers.facebook.com/docs/reference/fql/
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);
}
catch(Exception $o){
d($o);
}
}
//set page to include default is home.php
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : "home.php";
include_once "template.php";
?>
<?php
echo '<div id="namaz_content">';
echo '</div>';
echo $userInfo['picture'];
//Get the current users id
$uid = $facebook->getUser();
//create the url
$profile_pic = "http://graph.facebook.com/".$uid."/picture?width=80&height=80";
//echo the image out
echo "<img src=\"" . $profile_pic . "\" />";
echo '<img src="image.php?name=My name is Tushar&result=A%2D&taka=1000&subject=math" />';
?>
<?php
$text=$_GET['name'];
$result=$_GET['result'];
$subject=$_GET['subject'];
$taka='Tk. '.$_GET['taka'].'/-';
$dest = imagecreatefromjpeg('certificate.jpg');
$src = imagecreatefromjpeg('7e142c8d.jpg');
// Allocate A Color For The Text
$red = imagecolorallocate($dest,255,0,0);
$blue= imagecolorallocate($dest,0,0,255);
// Set Path to Font File
$font_path = 'bdquiz.ttf';
// Set Text to Be Printed On Image
// Print Text On Image
imagettftext($dest, 20, 0, 192, 240, $red, $font_path, $text);
imagettftext($dest,35, 0, 72, 380, $red, 'arial.ttf', $result);
imagettftext($dest,15, 0, 318, 420, $red, 'arial.ttf', $taka);
imagettftext($dest,15, 0, 270, 348, $blue, 'arial.ttf', $subject);
imagecopymerge($dest, $src, 468, 186, 0, 0, 80, 80, 100); //have to play with these numbers for it to work for you, etc.
//header('Content-Type: image/png');
imagejpeg($dest);
imagedestroy($dest);
imagedestroy($src);
?>

这很好用。但我希望在image.php中使用用户配置文件图片,而不是“7e142c8d.jpg”
解决办法是什么?plz帮助

我不确定您在编码方面有多好,所以我将分步骤进行解释

在home.php中

在顶部添加以下内容:

session_start()

并将其添加到profile_pic后面的下一行中

$\u会话['profilepic']=$profile\u pic

现在在image.php中,将其添加到顶部

session_start()

改变这个

$src=imagecreatefromjpeg('7e142c8d.jpg')

$src=imagecreatefromjpeg(“$”会话['profilepic'])

或者,如果你不想知道怎么做,只是想让它工作,复制粘贴这个。(我希望你想学习而不是复制粘贴。)

home.php

<?php
session_start();
echo '<div id="namaz_content">';
echo '</div>';
echo $userInfo['picture'];
//Get the current users id
$uid = $facebook->getUser();
//create the url
$profile_pic = "http://graph.facebook.com/".$uid."/picture?width=80&height=80";
$_SESSION['profilepic'] = $profile_pic;
//echo the image out
echo "<img src=\"" . $profile_pic . "\" />";
echo '<img src="image.php?name=My name is Tushar&result=A%2D&taka=1000&subject=math" />';
?>
<?php
session_start();
$text=$_GET['name'];
$result=$_GET['result'];
$subject=$_GET['subject'];
$taka='Tk. '.$_GET['taka'].'/-';
$dest = imagecreatefromjpeg('certificate.jpg');
$src = imagecreatefromjpeg('$_SESSION['profilepic']');
// Allocate A Color For The Text
$red = imagecolorallocate($dest,255,0,0);
$blue= imagecolorallocate($dest,0,0,255);
// Set Path to Font File
$font_path = 'bdquiz.ttf';
// Set Text to Be Printed On Image
// Print Text On Image
imagettftext($dest, 20, 0, 192, 240, $red, $font_path, $text);
imagettftext($dest,35, 0, 72, 380, $red, 'arial.ttf', $result);
imagettftext($dest,15, 0, 318, 420, $red, 'arial.ttf', $taka);
imagettftext($dest,15, 0, 270, 348, $blue, 'arial.ttf', $subject);
imagecopymerge($dest, $src, 468, 186, 0, 0, 80, 80, 100); //have to play with these numbers for it to work for you, etc.
//header('Content-Type: image/png');
imagejpeg($dest);
imagedestroy($dest);
imagedestroy($src);
?>

Image.php

<?php
session_start();
echo '<div id="namaz_content">';
echo '</div>';
echo $userInfo['picture'];
//Get the current users id
$uid = $facebook->getUser();
//create the url
$profile_pic = "http://graph.facebook.com/".$uid."/picture?width=80&height=80";
$_SESSION['profilepic'] = $profile_pic;
//echo the image out
echo "<img src=\"" . $profile_pic . "\" />";
echo '<img src="image.php?name=My name is Tushar&result=A%2D&taka=1000&subject=math" />';
?>
<?php
session_start();
$text=$_GET['name'];
$result=$_GET['result'];
$subject=$_GET['subject'];
$taka='Tk. '.$_GET['taka'].'/-';
$dest = imagecreatefromjpeg('certificate.jpg');
$src = imagecreatefromjpeg('$_SESSION['profilepic']');
// Allocate A Color For The Text
$red = imagecolorallocate($dest,255,0,0);
$blue= imagecolorallocate($dest,0,0,255);
// Set Path to Font File
$font_path = 'bdquiz.ttf';
// Set Text to Be Printed On Image
// Print Text On Image
imagettftext($dest, 20, 0, 192, 240, $red, $font_path, $text);
imagettftext($dest,35, 0, 72, 380, $red, 'arial.ttf', $result);
imagettftext($dest,15, 0, 318, 420, $red, 'arial.ttf', $taka);
imagettftext($dest,15, 0, 270, 348, $blue, 'arial.ttf', $subject);
imagecopymerge($dest, $src, 468, 186, 0, 0, 80, 80, 100); //have to play with these numbers for it to work for you, etc.
//header('Content-Type: image/png');
imagejpeg($dest);
imagedestroy($dest);
imagedestroy($src);
?>

谢谢,但它不起作用。问题在$profile_pic=“”行中;当这条线在标签下时,工作正常。但对于抢夺形象来说,这并不好。原因此链接不是真正的图像url。如果在地址栏中使用此lin,链接将重定向到