1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
public function render_img_result(){
$listuser = json_decode( urldecode($this->uri->segment(3)) );
$app_id = $this->uri->segment(4);
$slogans= $this->App_content->get_all_question($app_id);
$bg = $this->App->get_app($app_id)[0]['img'];
$dst_im = imagecreatefromjpeg($bg);
// Couleurs
$black = imagecolorallocate($dst_im, 0, 0, 0);
$white = imagecolorallocate($dst_im, 255, 255, 255);
// Police texte
$font_path = 'assets/fonts/RobotoSlab-Regular.ttf';
// Texte footer
imagettftext($dst_im, 40, 0, 40, 585, $black, $font_path, $slogans[1]['content']);
//Noms utilisateurs ( Ce que je veux centrer dans un rectangle )
$padding = 50 + (213 - strlen( $listuser[0]->name ) * 8 ) / 2;
imagettftext($dst_im, 40, 0, $padding, 460, $black, $font_path, $listuser[0]->name);
$padding = 630 + (213 - strlen( $listuser[1]->name ) * 8 ) / 2;
imagettftext($dst_im, 40, 0, $padding, 460, $black, $font_path,$listuser[1]->name);
// Avatar utilisateur
$src_im = imagecreatefromjpeg("http://graph.facebook.com/".$listuser[0]->id."/picture?type=normal&width=350&height=350");
imagecopy ( $dst_im , $src_im , 110 , 35 , 0 , 0 , $this->img_size , $this->img_size);
imagedestroy($src_im);
$src_im = imagecreatefromjpeg("http://graph.facebook.com/".$listuser[1]->id."/picture?type=normal&width=350&height=350");
imagecopy ( $dst_im , $src_im , 740 , 35 , 0 , 0 , $this->img_size , $this->img_size);
imagedestroy($src_im);
header("Content-type: image/jpeg");
imagejpeg($dst_im);
imagedestroy($dst_im);
} |
Partager