Reputation: 11
I want to use the Facebook users Profile Picture in my Application.
I think I should use the following function, but I'm not sure if that's correct:
public function getImg() {
$img = file_get_contents('https://graph.facebook.com/'.getUser().'/picture?type=normal');
return $this->img;
}
My goal is to place the profile picture on top of another image.
I think I have to use something like this:
ImageCopy ( $picture , $source, 445, 160 , 0 , 0 , $width , $height );
To conclude... I want to use the profile picture of a user an add it on another picture, how can I do this ?
Upvotes: 1
Views: 930
Reputation: 3099
grab user profile pic using following code:
$userpic = imagecreatefromjpeg("http://graph.facebook.com/".$user_id."/picture?type=normal");
Now place in in your main photo:
$mainphoto = imagecreatefromjpeg("path/to/main/photo.jpg");
imagecopymerge($mainpic, $userpic, $x, $y, -2, -2, 55, 55, 100);
Now $mainphoto
will contain the main photo and userpic on it.
you have to follow the same for all userpics you want to put on the mainphoto.
finally download the photo in server and free the memory:
imagejpeg($mainphoto, "save_as_this_name.jpg", 100);
imagedestroy($mainphoto);
Upvotes: 1
Reputation: 10556
I do not know php but i think this example from here may help you:
<?php
// Create image instances
$src = imagecreatefromgif('php.gif');
$dest = imagecreatetruecolor(80, 40);
// Copy
imagecopy($dest, $src, 0, 0, 20, 13, 80, 40);
// Output and free from memory
header('Content-Type: image/gif');
imagegif($dest);
imagedestroy($dest);
imagedestroy($src);
?>
Upvotes: 0