如何结合imagettftext显示blob图像

时间:2016-12-15 06:07:19

标签: php blob imagettftext

仍然在imagettftext主题上,现在我有问题如何在从imagecreatefrompng创建的页面上显示blob图像。 I want to do this

<?php
include('../db.php');

$id = $_GET['id'];

$sql = "SELECT * FROM data WHERE id=$id";
$result = $conn->query($sql);
$row = $result->fetch_array();

$id = $row['id']; //varchar
$name = $row['name']; //varchar
$address = $row['address']; //varchar
$photo = base64_encode($row['photo']); //blob image

$im = imagecreatefrompng('../img/idcard.png');
$black = imagecolorallocate($im, 0, 0, 0);
$font = "../fonts/Ubuntu-R.ttf";

imagettftext($im, 15, 0, 200, 175, $black, $font, $id);
imagettftext($im, 15, 0, 240, 200, $black, $font, $name);
imagettftext($im, 15, 0, 280, 275, $black, $font, $address);

imagettftext($im, 15, 0, 350, 315, $black, $font, $photo);

header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>

我的代码显示身份证,文字,但图片/照片只显示为文字字符

1 个答案:

答案 0 :(得分:0)

$im2 = imagecreatefromstring($photo);
imagecopyresized ($im,$im2,2,2,0,0,46,46,183,173);//see parameters at: http://php.net/manual/en/function.imagecopyresized.php

(如果你不需要调整大小你也可以使用imagecopy)