我正在尝试将两段代码合二为一。第一部分将给定的.jpg图像转换为.png并将其放到IMG文件夹中,其名称只是不同的扩展名。 代码的第二部分应该打印" text"从文件夹IMG(FIRST PART创建的.png图像)拍摄照片时,在照片上方。
我显然做错了,因为我最后打印的只是图片的来源,而不是使用< img src =最后的部分。
我试图在这里搜索一些相同的问题,但没有运气。
//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'>";
有什么想法吗?
答案 0 :(得分:1)