$im = imagecreatetruecolor(400, 100);
/*$white = imagecolorallocate($im, 255, 255, 255);
//imagefilledrectangle($im, 0, 0, 399, 99, $white);
$black = imagecolorallocate($im, 0, 0, 0);*/
imagesavealpha($im, true);
imagealphablending($im, false);
$white = imagecolorallocatealpha($im, 255, 255, 255, 127);
imagefill($im, 0, 0, $white);
$black = imagecolorallocate($im, 0, 0, 0);
imagettftext($im, 30, 0, 0, 60,
$black,
base_path('public/fonts/Dancing-Script.ttf'), 'Satish Sharma');
// Output to browser
header('Content-Type: image/png');
$file='zip-unzip/'.rand(10000, 9999999)."-signature.png";
imagepng($im, $file);
imagedestroy($im);
$base64 = 'data:image/png;base64,' . base64_encode(file_get_contents(base_path('public/'.$file)));
unlink(base_path('public/'.$file));