dougou5852 2014-05-28 08:46
浏览 18
已采纳

用PHP在飞行中打印文本

I am trying to combine two pieces of code in one. The first part convert the given .jpg image to .png and put it to IMG folder with the same name just different extension. The second part of the code should print "text" over the picture while taking the picture from the folder IMG (the .png image created by the FIRST PART).

I am doing something wrong obviously as what I get printed in the end is just the source of the picture instead of using the < img src= part in the end.

I have tried to search for some identical issues here, but with no luck.

//FIRST PART
$file = basename($picture, ".jpg");
$file_create = "img/$file.png";
$image = ImageCreateFromJPEG("$picture"); 
ImageJpeg($image, "img/$file.png"); 
ImageDestroy($image); 
//SECOND PART    
    header("Content-type: image/png");
    $imgPath = "$file_create";
    $image = imagecreatefromjpeg($imgPath);
    $color = imagecolorallocate($image, 255, 255, 255);
    $string = "test";
    $fontSize = 3;
    $x = 115;
    $y = 185;
    imagestring($image, $fontSize, $x, $y, $string, $color);
    $final=imagejpeg($image);

print "<img src='img/$final' width=150 height=150 valign=middle title='$item' alt='$item'>";

Any ideas?

  • 写回答

1条回答 默认 最新

  • dongwuli5105 2014-05-28 09:13
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题