我想将php字符串转换为图像。 我用这个代码
header("Content-type: image/png");
$string = '.the_title().';
$font = 5;
$width = imagefontwidth($font) * strlen($string);
$height = imagefontheight($font);
$image = imagecreatetruecolor ($width,$height);
$white = imagecolorallocate ($image,255,255,255);
$black = imagecolorallocate ($image,0,0,0);
imagefill($image,0,0,$white);
imagestring ($image,$font,0,0,$string,$black);
imagepng ($image);
imagedestroy($image)
但它将the_title显示为文本而不是执行字符串
答案 0 :(得分:2)
使用imagecreatefromstring
$string = '.the_title().';
$data = base64_decode($string);
$im = imagecreatefromstring($data);
if ($im !== false) {
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
}
答案 1 :(得分:1)
使用imagestring
之类的:
library(stringr)
do.call(rbind, lapply(str_extract_all(df$col, '\\d+'),
function(x) head(as.numeric(x),2)))