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?