// User = facebook id
// img = รูปที่ต้องการเปรียบเทียบ
// gname = ชื่อเกมส์
function getMergimg($user,$img,$gname){
$imgd = file_get_contents ( 'https://graph.facebook.com/' . $user . '/picture?type=large' );
$file = 'resource/images/profileimg/' . $user . '.jpg';
file_put_contents ( $file, $imgd );
$src = array (
"resource/images/profileimg/".$user.".jpg",
"resource/images/right-arrow.gif",//รูปลูกศร
"images/upload/{$img}");
$imgBuf = array ();
foreach ($src as $link)
{
switch(substr ($link,strrpos ($link,".")+1))
{
case 'png':
$iTmp = imagecreatefrompng($link);
break;
case 'gif':
$iTmp = imagecreatefromgif($link);
break;
case 'jpeg':
case 'jpg':
$iTmp = imagecreatefromjpeg($link);
break;
}
array_push ($imgBuf,$iTmp);
}
$iOut = imagecreatetruecolor ("380","240") ;
$text_colour = imagecolorallocate( $iOut, 234, 244, 254 );
$font_file = 'resource/images/supermarket.ttf';//กำหนดฟอนต์
imagecopy ($iOut,$imgBuf[0],0,30,10,0,imagesx($imgBuf[0]),imagesy($imgBuf[0]));
imagedestroy ($imgBuf[0]);
imagecopy ($iOut,$imgBuf[1],182,80,0,0,imagesx($imgBuf[1]),imagesy($imgBuf[1]));
imagedestroy ($imgBuf[1]);
imagecopy ($iOut,$imgBuf[2],198,20,5,10,imagesx($imgBuf[2]),imagesy($imgBuf[2]));
imagedestroy ($imgBuf[2]);
imagefttext($iOut, 18, 0, 20, 30, $text_colour, $font_file, $gname);
//imagecolordeallocate( $text_color );
$line_colour = imagecolorallocate( $iOut, 128, 255, 0 );
imagesetthickness ( $iOut, 5 );
imageline( $iOut, 0, 190, 380, 190, $line_colour );
imagecolordeallocate( $line_color );
imagefttext($iOut, 12, 0, 20, 220, $text_colour, $font_file, 'ข้อความที่ต้องการด้านล่าง');
imagecolordeallocate( $text_color );
//[ชื่อโดเมนของเรา] เปลี่ยนด้วย
//[folder ที่เอาไว้เก็บภาพ] เปลี่ยนด้วย
imagepng($iOut, '/home/admin/domains/[ชื่อโดเมนของเรา]/public_html/[folder ที่เอาไว้เก็บภาพ]/'.$user.'_merg.png');
//imagepng($iOut);
return $user.'_merg.png';
}