imagejpeg不显示图像

时间:2019-01-22 18:05:15

标签: php imagejpeg

我正在尝试生成要打印的证书,但是唯一发生的是在屏幕上显示一个空的正方形:

enter image description here

我想先在屏幕上显示图像,然后再在其上书写。

header("Content-type: image/jpeg");
$imagem = imagecreatefromjpeg("assets/img/certificado.jpg");
imagejpeg($imagem);

我已经检查了gd2扩展名并启用了它: enter image description here

然后我检查php错误日志,运行此代码的页面没有返回任何错误。

当我移除header("Content-type:image/jpeg");并放上var_dump($i)时,它向我显示:resource(12,gd)

对不起,我的英语,谢谢!

1 个答案:

答案 0 :(得分:1)

$our_image = imagecreatefromjpeg('upload/promo/flyer_hindi.jpg');
$white_color = imagecolorallocate($our_image, 0, 0, 0);
$font_path = 'upload/promo/CALIBRIB.TTF';
$text = 'some text';
$size = 70;
$angle = 0;
$left = 420;
enter code here
imagettftext($our_image, $size, $angle, $left, $top, $white_color, $font_path, $text);
imagejpeg($our_image, 'upload/promo/' . $id . '.jpg', 80);

我去年尝试过此代码,我上传了传单,并在修复位置添加了一些文本并保存。我想你也一样。