1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Facebook Profile image merge with existing image

Discussion in 'Facebook API' started by arctushar, Nov 27, 2012.

  1. #1
    facebook image merge

    Hi I want to develop a facebook apps. Where it will take quiz, then merge profile picture in a certificate image. with result.
    SEMrush
    the index.php file is as below

    <?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";
    ?>

    and the home.php is as below

    <?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" />';
    ?>

    and the image.php file is as below

    <?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);
    ?>

    This is working fine. But I want that at image.php user profile picture will be used instead of '7e142c8d.jpg'
    what is the solution ? plz help
     
    arctushar, Nov 27, 2012 IP
    SEMrush