Search code examples
phpimagejpeg

imagejpeg do not show an a image


I'm trying generate a certificate to print, but the only thing that happens is show a empty square in screen:

enter image description here

I'm trying show the image on the screen before i try to write on it.

header("Content-type: image/jpeg");
$imagem = imagecreatefromjpeg("assets/img/certificado.jpg");
imagejpeg($imagem);

I already check the gd2 extension and it's enable: enter image description here

And I check the php error log and the page who run this code dont return any error.

When I remove the header("Content-type:image/jpeg"); and put a var_dump($i) it shows me this: resource(12,gd)

Sorry for my english and thanks!


Solution

  • $our_image = imagecreatefromjpeg('upload/promo/flyer_hindi.jpg');
    $white_color = imagecolorallocate($our_image, 0, 0, 0);
    $font_path = 'upload/promo/CALIBRIB.TTF';
    $text = 'some text';
    $size = 70;
    $angle = 0;
    $left = 420;
    enter code here
    imagettftext($our_image, $size, $angle, $left, $top, $white_color, $font_path, $text);
    imagejpeg($our_image, 'upload/promo/' . $id . '.jpg', 80);
    

    i tried this code a last year, i upload a flyer and add some text on fix location and save. i think you need the same.