0

Hi Everyone, I am trying to write text to a image and I would like to save that image as a new file with the text in place.

I have been doing some google'ing and testing but im getting confused a wee bit.

The two scripts I have found both pretty much do the same thing as they write text to any pre-determined image.
But what they dont give you is how to create a new image and then save it for later useage.

The two script I am working with are as follows.

Script one

    header("Content-type: image/jpeg");
    $imgPath = 'image.jpg';
    $image = imagecreatefromjpeg($imgPath);
    $color = imagecolorallocate($image, 255, 255, 255);
    $string = "http://test.net";
    $fontSize = 3;
    $x = 115;
    $y = 185;
    imagestring($image, $fontSize, $x, $y, $string, $color);
    imagejpeg($image);

Now, When ever I put this code on my website inside the <head>
The page doesnt load fully, Im thinking it must have something to do with the header ("content-type")

Any help would be much appreciated

2
Contributors
1
Reply
11
Views
3 Years
Discussion Span
Last Post by Taywin
0

Are you talking about create an image and save it to file??? You may be looking for file_put_contents() to save the image to file.

Also, are you sure that the path of the image file is correct? You seem to think about 'relative path' but I am not sure that your script is looking at the same path you want it to do...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.