imagecreatefromjpeg() dynamic page URL


#1

Hello.
I am currently writing a script that will call a dynamic image and write the URL of the page that calls the image ("")

Something like this is what I have so far: http://www.host.com/authimage.php

$url = sprintf("%s%s%s","http://",$_SERVER['HTTP_HOST'],$_SERVER['REQUEST_URI']);

$image = "authbackimg.jpeg"; 
$im = imagecreatefromjpeg($image); 
$tc  = ImageColorAllocate ($im, 0, 0, 0); 

ImageString($im, 3, 148, 2, "text text text", $tc); 
ImageString($im, 2, 148, 15, "more text", $tc); 
ImageString($im, 2, 148, 25, "$url", $tc); 
ImageString($im, 2, 148, 35, "even more text", $tc); 
ImageString($im, 2, 148, 45, "and the last text", $tc); 
header("Content-Type: image/jpeg"); 
Imagepng($im,'',100); 
ImageDestroy ($im); 

and in http://www.mywebsite.com/page.html I have:

<img src="authimage.php" />

So when the http://www.host.com/authimage.php image is called from the http://www.mywebsite.com/page.html page, I want $url to say “http://www.mywebsite.com/page.html” , indicating the page that it is called on.

However, instead of outputting the location of the page that calls the image, it outputs the location of the image itself.

One thing I have tried on http://localhost/ that worked was $_SERVER[‘HTTP_REFERER’]. Because the page that calls the image would be the referer. However, when I upload the page to my online server, HTTP_REFERER has no value. (Could this be because http://localhost/ is Windows server, and online ls Linux? They both run Apache.)

If anyone could help me it would be GREATLY appreciated. Thank you.


#2


#3

If you’re calling the image from http://www.mywebsite.com/page.html, i.e. the address you want texted onto the image, then pass it in a $_GET variable to the image script. That way, the image script will receive the info and you can write it via imagefttext or whatever.