一张图片加些文字后生成新的图片 imagepng输出展示的时候不正确?

// 基本参数
$font = './Upload/fonts/hanyishengongtijian.ttf';//字体
$img = imagecreatefromstring(file_get_contents($img_path));
$black = imagecolorallocate($img, 224, 193, 68);//字体颜色 RGB
$fontSize = 20;   //字体大小
$left = 140;      //左边距
$top = 177;       //顶边距

$string = '不成功 很难过 求帮助';
imagefttext ($img, $fontSize, 0, $left, $top, $black, $font, $string);

$string = 'NO:88888';
imagefttext ($img, $fontSize, 0, $num_left, $num_top, $black, $font, $string);

$create_img_path = './Upload/cart/user_cart'.222.'.png';

Header("Content-type: image/png");
imagepng($img,$create_img_path);
imagedestroy($img);

https://img1.mukewang.com/5c8f681c0001d68602600160.jpg
最后的结果是这样的 但是我保存到本地的图片是正常的 我拿本地的图片上传到第三方 打开也是不行的 是不是字体的原因啊?有木有知道的大神求教

jeck猫
浏览 403回答 1
1回答

幕布斯7119047

把Header("Content-type: image/png");这行注释掉看看,看看有咩有报错
打开App,查看更多内容
随时随地看视频慕课网APP