开发者

PHP/GD Library Imagettftext save image on server and send to browser

开发者 https://www.devze.com 2023-04-08 17:16 出处:网络
I am overlay some text on an image (that is already on my server) using GD. I am trying to save the new image on the server.

I am overlay some text on an image (that is already on my server) using GD. I am trying to save the new image on the server.

Below is my code but all it does is show the new image to the browser it doesnt save it to the server.

        <?
//PHP's GD class functions can create a variety of output image
    //types, this example creates a jpeg
    header("Content-Type: image/jpeg");

    $im = imagecreatefromjpeg($image_full); 

    $black = ImageColorAllocate($im, 255, 255, 255);


    $copy_1_x = 10;
    $copy_1_y = 20;

    $copy_2_x = 10;
    $copy_2_y = 20;

    $copy_3_x = 10;
    $copy_3_y = 20;

    //writes text to image
    Imagettftext($im, 12, 0, $copy_1_x, $copy_1_y, $black, 'verdana.ttf', $main_number);
    Imagettftext($im, 12, 0, $copy_2_x, $copy_2_y, $black, 'verdana.ttf', $prime_number);
    Imagettftext($im, 12, 0, $copy_3_x, $copy_3_y, $black, 'verdana.ttf', $legal);

    //Creates the jpeg image and sends it to the browser
    //100 is开发者_如何学编程 the jpeg quality percentage
    Imagejpeg($im, '', 100);


    ImageDestroy($im);



        ?>


Thanks @Ignacio

Imagejpeg($im, '/path_to_folder/imagename.jpg', 100);

Found at http://php.net/manual/en/function.imagejpeg.php

0

精彩评论

暂无评论...
验证码 换一张
取 消