PHP/GD库Imagettftext将图像保存在服务器上并发送到浏览器



我使用GD在图像(已经在我的服务器上)上覆盖一些文本。我正在尝试在服务器上保存新图像。

下面是我的代码,但它所做的只是向浏览器显示新图像,而不是将其保存到服务器。

        <?
//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);

        ?>

谢谢@Ignacio

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

找到于http://php.net/manual/en/function.imagejpeg.php

最新更新