0

I want to create certificates for users on my website but following code isn't working and only showing grey square when loaded on localhost...

<?php
header('content-type:image/jpeg');
$font="BRUSHSCI.TTF";
$image=imagecreatefromjpeg("certificate.jpg");
$color=imagecolorallocate($image,19,21,22);
$name="Name";
imagettftext($image,50,0,365,420,$color,$font,$name);
$date="12th may 2021";
imagettftext($image,20,0,450,595,$color,"AGENCYR.TTF",$date);
imagejpeg($image);
imagedestroy($image);
?>

This output I got when I run above code:
This output I got when I run above code

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • You should look in the webserver error log for php errors, or use `error_reporting(E_ALL)` upfront to show potential errors. – Jos May 13 '21 at 14:05
  • no no error, it only shows above output no error log.... – Mayur Jadhav May 13 '21 at 14:08
  • It shows no errors in your browser, but have you checked the error log? Or have you used the `error_reporting(E_ALL)` and then refreshed? – Jos May 13 '21 at 14:10
  • yeah Mr. I did But same output.... Let me know, whether imagecreatefromjpeg work on php 7 or not? – Mayur Jadhav May 13 '21 at 14:12
  • Your code looks fine...The problem is probably because you have something before the PHP...1.you need to remove everything before the – Kevin Gales May 13 '21 at 14:47
  • imagecreatefromjpeg will work in any version of php, as long as GD is installed. See https://www.php.net/manual/en/image.installation.php – Jos May 14 '21 at 06:03

0 Answers0