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

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

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.