为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

PHP
jeck猫 2019-03-12 11:35:25
// 基本参数 $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); 最后的结果是这样的 但是我保存到本地的图片是正常的 我拿本地的图片上传到第三方 打开也是不行的 是不是字体的原因啊?有木有知道的大神求教
查看完整描述

1 回答

?
幕布斯7119047

TA贡献1794条经验 获得超8个赞

把Header("Content-type: image/png");这行注释掉看看,看看有咩有报错

查看完整回答
反对 回复 2019-03-18
  • 1 回答
  • 0 关注
  • 402 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信