Jump to content

GD imagePng()


opencombatclan

Recommended Posts

Hi there.

I wrote a php script last night.

It creates board pictures for the members of my clan.

Here is the url: http://opencombatclan.gethost.nl/bestanden/occscript.php

Its fully functional and you can choose fonts, pixels, colors and add multiple rows.

But... When i create my image and save it to my desktop (right-click, save as)

and i save it, and then i open the png to see what it looks like, its EMPTY...

and when i open the PNG with notepad, i see my html code there!!!

 

how is this possible???

Can you help me?

I use the following code

<?php
if (IsSet($_POST['submit']))
{
Header ("Content-type: image/png");
$img_handle = imageCreateFromPNG("opencombatclanuserpic.png");
$color = ImageColorAllocate ($img_handle, 100, 100, 100);
//My other variables here (Colors,letters,fonts)
$text1 = $_POST['image_inhoud'];
$text2 = $_POST['image_inhoud2'];
$text3 = $_POST['image_inhoud3'];
$text4 = $_POST['image_inhoud4'];
$text5 = $_POST['image_inhoud5'];
imagettftext($img_handle, "$font1", 0, 180, 20, $color1, $letter1, $text1);
imagettftext($img_handle, "$font2", 0, 180, 45, $color2, $letter2, $text2);
imagettftext($img_handle, "$font3", 0, 180, 70, $color3, $letter3, $text3);
imagettftext($img_handle, "$font4", 0, 180, 95, $color4, $letter4, $text4);
imagettftext($img_handle, "$font4", 0, 180, 120, $color4, $letter5, "$text5");
imagePng ($img_handle);
imagedestroy($img_handle);
}
?>

Can u tell me what i am doing wrong?

I just want to save the picture by right clicking it...

And somepeople have those images by adding:

SCRIPT.php?txt=Hello%20stranger

How can i add my texts, and fonts and variables to my url, so people can link to it from our forum...

 

So basicly i need to accomplish the following:

1.) allow user to right-click the image and save it

2.) Making a Direct Link Url to the user specified image

 

I really hope you can help me out.

 

Yours faithfully,

Steven

 

Link to comment
https://forums.phpfreaks.com/topic/115566-gd-imagepng/
Share on other sites

To start with, your form does not have any closing </form> tag.

 

However, the problem with the image is your php code is unconditionally outputting the form on that page, so there is HTML on the end of the image data.

 

 

How to fix it?

I am a bit new with php...

can u help me out?

Link to comment
https://forums.phpfreaks.com/topic/115566-gd-imagepng/#findComment-594244
Share on other sites

To prevent your form from being output with the image data, you would need to place the form code inside of a conditional statement that is only true when you want the form to be output and false when you are outputting the image.

Yes thank you VERY much!

You are my hero!

But...

I have now idea how to do:

you would need to place the form code inside of a conditional statement that is only true when you want the form to be output and false when you are outputting the image

Sorry for being annoying..

I really want to have this working.

And i want to understand php more...

Can you Please give me a exmple that i can use?

 

I really hope so

 

Link to comment
https://forums.phpfreaks.com/topic/115566-gd-imagepng/#findComment-594276
Share on other sites

So, have you read through a basic php book or some basic php tutorials to get up to speed with the fundamentals of the programming language you are using? If not, it is going to be a very frustrating experience for you (and anyone who tries to help you) to create code that accomplishes anything.

 

Ref: http://www.php.net/manual/en/language.control-structures.php

Link to comment
https://forums.phpfreaks.com/topic/115566-gd-imagepng/#findComment-594289
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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