Jump to content

Recommended Posts

Hi there.

I'm new here and I have a problem I can't solve on my own so I was hoping to get some help here.

I tried to google my problem but I couldn't find anything.

 

Here's my problem:

I'm writing an event-site for my company. The admin is able to add new events to the site and can choose if he wants to upload a specific picture for this event or not. If the admin doesn't want to upload a picture I want to create an automatic picture in which the event-name is in with the GD-Libraries. I managed to create a new .php file that contains to script for the picture via php. Everything works except that there is no text on the picture and I can't figure out why.

 

Here's the script that writes the GD-Libraries script in the new .php file. I hope you can help me.

 

 

$neuesbild = "eventbilder/".$name.".php";
$open = fopen($neuesbild, 'w') or DIE("Kann Datei nicht öffnen<meta http-equiv=refresh content='2; URL=neuer_event.php?pid=09'>");
$var1 = "\$bild";
$var2 = "\$bg";
$var3 = "\$black";
$var4 = "\$text";
$var5 = "\$font";
$string = "<?php\n
header('content-type: image/png');\n

$var1 = imagecreate(320,150);\n
$var2 = imagecolorallocate(\$bild, 255, 255, 255);\n
$var3 = imagecolorallocate(\$bild, 0, 0, 0);\n
$var4 = \"$name\";\n
$var5 = \"times.ttf\";\n

imagettftext(\$bild, 20, 0, 135, 80, \$black, \$font, \$text);\n

imagepng(\$bild);\n
?>";
fwrite($open, $string);
fclose($open);
$bild = $name.".php";

 

Thank you very much

Link to comment
https://forums.phpfreaks.com/topic/176656-gd-libraries-imagettftext/
Share on other sites

Hi

 

I agree with the above.

 

However looking at your code I suspect one issue is the line:-

 

imagettftext(\$bild, 20, 0, 135, 80, \$black, \$font, \$text);\n

 

which is missing a few quotes:-

 

imagettftext(\$bild, 20, 0, 135, 80, \$black, '\$font', '\$text');\n

 

Not sure what can do with $bild and $black, as they should be references (to an image and to a colour for that image respectively) and I would expect the variables are referring to things in the main script which will no longer exist (and even if they did exist they couldn't be accessed by the generated script) when the generated script is run.

 

All the best

 

Keith

 

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.