Page 1 of 2

Quick question about displaying...

Posted: Sat Nov 26, 2005 11:24 am
by unsuaulvb
i need some php help i need to display an iframe ontop of a image

using

Code: Select all

ImageString($im, 0, 0, 0, "", $black);
Here is my code

Code: Select all

<?php
$im = imagecreate(204, 104);
$white = imagecolorallocate($im, 255, 255, 255);
$name =UnusualVB
ImageString($im, 0, 0, 0, "", $white);
////////////////////////////////////
Header('Content-type: image/png');
imagepng($im);
ImageDestroy ($im);
?>
Here is my Iframe
http://mysite.com/$name.card

Posted: Sat Nov 26, 2005 11:45 am
by foobar
Iframes have nothing to do with PHP. What is it you want to do?

If you want your iframe to have a certain background, just create an appropriate stylesheet in the file it displays.

Posted: Sat Nov 26, 2005 11:50 am
by unsuaulvb
i wana display a website as a image

Posted: Sat Nov 26, 2005 11:57 am
by ody
unsuaulvb wrote:i wana display a website as a image
yeah and I want the internet in paperback but sometimes we just dont get what we want.

Posted: Sat Nov 26, 2005 12:01 pm
by foobar
unsuaulvb wrote:i wana display a website as a image
And I want to download the internet.

Posted: Sat Nov 26, 2005 12:02 pm
by unsuaulvb
Its asimple question and if you have to be rude and be sarcastic then i could easily report you to the admin, I have not broken any rules, this forum is for asking questions about php and getting answers. Now if you do not know the answer then do not post.

Posted: Sat Nov 26, 2005 12:13 pm
by ody
No no you are right, I am sorry, it was just a bit of humour.

Posted: Sat Nov 26, 2005 12:18 pm
by foobar
unsuaulvb wrote:Its asimple question and if you have to be rude and be sarcastic then i could easily report you to the admin, I have not broken any rules, this forum is for asking questions about php and getting answers. Now if you do not know the answer then do not post.
If you would have said anything useful beyond, and I quote, "i wana display a website as a image", then maybe we'd be able to help. In that sentence, and your previous posts, you gave no indication of what exactly you want to do.

Cheers,

Tom

Posted: Sat Nov 26, 2005 12:27 pm
by unsuaulvb
i need some php help i need to display an iframe ontop of a image using GD
Also i would like to know how to define a variable like this $username using

Code: Select all

http://mysite.com/index.php?username=unusualvb
Here is my code

Code: Select all

<?php
$im = imagecreate(204, 104);
$white = imagecolorallocate($im, 255, 255, 255);
$username =UnusualVB
ImageString($im, 0, 0, 0, "", $white);
////////////////////////////////////
Header('Content-type: image/png');
imagepng($im);
ImageDestroy ($im);
?>
Here is my Iframe
http://mysite.com/$name.card

Posted: Sat Nov 26, 2005 12:47 pm
by Chris Corbyn
Is there any reason you can't just set the background of the iframe content as the image?

Posted: Sat Nov 26, 2005 12:47 pm
by ody
you need to set the background image of the html page in the iframe to point to your php script that outputs the image.

when you pass a variable in the url it is known as a GET var, you would access it using $_GET['username']

Posted: Sat Nov 26, 2005 1:07 pm
by foobar
unsuaulvb wrote:i need some php help i need to display an iframe ontop of a image using GD
Also i would like to know how to define a variable like this $username [etc. see first post
I was asking you to explain, not restate. We can all go back to the first post, that's not the problem. You need to provide more information. Do yourself a favor and make it easier to help you. It's in your own interest.
ody wrote:you need to set the background image of the html page in the iframe to point to your php script that outputs the image.
I already told him that, but that doesn't seem to be the problem. I am really at a loss here. No clue what unsualvb wants. :?

Posted: Sat Nov 26, 2005 1:09 pm
by ody
foobar wrote:
unsuaulvb wrote:i need some php help i need to display an iframe ontop of a image using GD
Also i would like to know how to define a variable like this $username [etc. see first post
I was asking you to explain, not restate. We can all go back to the first post, that's not the problem. You need to provide more information. Do yourself a favor and make it easier to help you. It's in your own interest.
ody wrote:you need to set the background image of the html page in the iframe to point to your php script that outputs the image.
I already told him that, but that doesn't seem to be the problem. I am really at a loss here. No clue what unsualvb wants. :?
Either way dewd, getting the internet into paper back, how can we do that with PHP? :wink:

Posted: Sat Nov 26, 2005 1:15 pm
by unsuaulvb
ok what im making is for xbox live

Code: Select all

<?php
$im = ImageCreate(204, 104);
$bg = imagecolorallocate($im, 0, 0, 0);
$fontcolor = imagecolorallocate($im, 255, 255, 522);
if ( $_GET['username'] == "" ) {
    $gamertag = "No Gamertag";
} else {
   $gamertag = $_GET['username'];
}
////////////////////////////////////
$str = "$gamertag";
$name = str_replace(" ", "%20", $str);
$name = str_replace(".png", "", $name);
$name = str_replace(".jpg", "", $name);
$name = str_replace(".gif", "", $name);
////////////////////////////////////
ImageString  ($im, 0, 0, 0, "<iframe src= http://gamercard.xbox.com/$name.card scrolling=no frameBorder=0 height=140</iframe>", $fontcolor);
////////////////////////////////////
Header('Content-type: image/png');
imagepng($im);
ImageDestroy ($im);

It does not work but this does

Code: Select all

<?php
$im = ImageCreate(204, 104);
$bg = imagecolorallocate($im, 0, 0, 0);
$fontcolor = imagecolorallocate($im, 255, 255, 522);
if ( $_GET['username'] == "" ) {
    $gamertag = "No Gamertag";
} else {
   $gamertag = $_GET['username'];
}
////////////////////////////////////
$str = "$gamertag";
$name = str_replace(" ", "%20", $str);
$name = str_replace(".png", "", $name);
$name = str_replace(".jpg", "", $name);
$name = str_replace(".gif", "", $name);
////////////////////////////////////
echo "<iframe src= http://gamercard.xbox.com/$name.card scrolling=no frameBorder=0 height=140</iframe>"
////////////////////////////////////
?>
But i need the top scipt because it uses GD to make it a image

Posted: Sat Nov 26, 2005 1:36 pm
by foobar
unsuaulvb wrote:

Code: Select all

ImageString  ($im, 0, 0, 0, "<iframe src= http://gamercard.xbox.com/$name.card scrolling=no frameBorder=0 height=140</iframe>", $fontcolor);
^That's where you've got an error.

Your usage of imagestring() is incorrect. What your code will do is print the text "<iframe ... ></iframe>" on your image. I'm not sure what you're trying to achieve. If you want to get the xbox-live image, you could do the following:

Assuming it's a PNG image

Code: Select all

header('Content-Type: image/png');

//Get $name...
//$name = ... ;

$path = "http://gamercard.xbox.com/$name.card";

/* Create a GD image from a PNG file */
$image = @imagecreatefrompng($path);

/* Get image size */
list($width, $height) = getimagesize($path);

//Do whatever you want to with the image...

return $image;
As a side note, your iframe code is wrong, you forgot the > on your opening tag.