Jump to content

Recommended Posts

I have a script to import text from a form and insert into a picture.

 

Is it possible to import an image ontop of an image?

 

<?php

header("Content-type: image/png");

$user = $_POST['user'];

$user = $_GET['user'];

$im = imagecreatefrompng("banner.png");

$user_width = imagettfbbox(50, 50, "verdana.ttf", $user);

$x_value = (122 - ($user_width[10] + 122));

$color = imagecolorallocate($im, 255, 255, 255);

imagettftext($im, 20, 0, $x_value, 65, $color, "verdana.ttf", $user);

imagepng($im);

imagedestroy($im);

?>

 

What would I go by?

Link to comment
https://forums.phpfreaks.com/topic/152939-solved-is-it-possible/
Share on other sites

Going by the code he posted it's an image created by GD.

Yes it's possible, but your host needs to have GD support enabled, you could create a phpinfo file and check the output to see if it does.

 

Problem with images is that you don't see much when it errors out, try commenting the "header("Content-type: image/png");"

line. That should make errors show up unless your host has disabled error reporting together.

 

I'm guessing if GD is installed/enabled that your problem lies either with the $user getting called for twice where the $_POST is getting absoleted by the $_GET or due to verdana.ttf not being installed on the server.

You may want the look up $_REQUEST if you want to use $_POST whenever $_GET isn't set.

 

PS: Use code tags instead of blockquote for syntax highlighting.

Even with error codes disabled they can be enabled.

error_reporting(E_ALL ^ E_NOTICE);

That will show all errors but not the notices.

 

In order to display the error messages when playing with GD functions comment out the line(s) sending the image header info (as mentioned above) and access the file using the GD functions directly in the browser as calling it from IMG will still hide the errors.

Ah okay, wasn't clear to me.

 

Yes you can, have a read over at the PHP GD2 documentation .

Most likely you'll want to use imagecopymerge, and don't forget to read the comments there. They often have nice examples of people trying to do the same thing.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.