Код:
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors' , 1);
require('vendor/autoload.php');
use GDText\Box;
use GDText\Color;
$text = $_GET["text"];
$text = explode("@", $text);
$text = implode("\n", $text);
$uid = $_GET["id"];
$id_get = json_decode(file_get_contents("https://api.vk.com/method/users.get?v=5.67&user_ids=".$uid."&fields=photo_200"),true);
//print_r($id_get);
//$dest = imagecreatefromjpeg('cit.jpg');
$dest = imagecreate(800, 200);
$main = imagecolorallocate($dest, 236,242,244);
if($id_get['response'][0]['photo_200']=="https://vk.com/images/camera_200.png"){
$src = imagecreatefrompng($id_get['response'][0]['photo_200']);
}else{
$src = imagecreatefromjpeg($id_get['response'][0]['photo_200']);
}
$blek = imagecolorallocate($dest, 117,119,117);
//$font_path = "./font/font.ttf";
$font_path = "./3966.ttf";
// Copy and merge
imagecopymerge($dest, $src, 0, 0, 0, 0, 200, 220, 100);
function mb_str_split($str, $split_length) {
$chars = array();
$len = mb_strlen($str, 'UTF-8');
for ($i = 0; $i < $len; $i+=$split_length ) {
$chars[] = mb_substr($str, $i, $split_length, 'UTF-8');
}
return $chars;
}
$arr = mb_str_split( $text, 33);
$name = "©".$id_get['response'][0]['first_name']." ".$id_get['response'][0]['last_name'];
$w_predmet=strlen($name) * 17 + 40; // максимальное длина предмета умножаем на 1,5 + 20 слева отступ + 20 справа отступ
imagettftext($dest, 20, 0, 210, 65, $blek, $font_path, "«".implode( "\n", $arr)."»");
$box = new Box($dest);
$box->setFontFace($font_path); // http://www.dafont.com/pacifico.font
$box->setFontSize(17);
$box->setFontColor(new Color(117,119,117));
$box->setBox(
50, // distance from left edge
50, // distance from top edge
745, // textbox width
150 // textbox height
);
$box->setTextAlign('right', 'bottom');
$box->draw($name);
//imagettftext($dest, 17, 0, 560, 195, $blek, $font_path, $name);
// Output and free from memory
header('Content-type: image/jpeg');
imagegif($dest);
imagedestroy($dest);
imagedestroy($src);
?>
Почему то на выходе, фотка из вк становится черно белой!