Some Poster55 Posted December 23, 2008 Share Posted December 23, 2008 Hi, I'll try to explain this as best I can, but basically I need to create a GD image based off of a variable entered in the page's URL. I've seen a number of sites do this in the past, so I know it's possible. So for example, if I were to visit http://website.com/HelloWorld/image.png - it would show an image containing the text "HelloWorld". Whatever that directory name would be changed to in the URL would then be displayed on the picture. So if I changed the URL to http://website.com/ByeWorld/image.png - it would show an image containing the text "ByeWorld". If I changed the URL to http://website.com/HeyWorld/image.png - it would show an image containing the text "HeyWorld" - And so on... I understand how to do this using a regular php file as so: <?php header("Content-type: image/png"); $im = imagecreate(510, 20); $bg = imagecolorallocate($im, 0, 0, 0); //Get the current directory of the page $url = $_SERVER["REQUEST_URI"]; $text = explode("/",$url); //Write the page's current directory on the image $textcolor = imagecolorallocate($im, 0, 0, 255); imagestring($im, 5, 0, 0, $text[1], $textcolor); imagepng($im); imagedestroy($im); ?> However, I'm baffled as to how this works by just using a file with a .png extension. Following in the above example, my code will work as desired from http://website.com/HelloWorld/image.php and correctly write an image with the text "HelloWorld", but what I need is for it to be at http://website.com/HelloWorld/image.png . The code above is exactly what I need, it's just I need the page to have a .png extension instead of a .php extension. Any ideas? Thanks much in advance! Link to comment https://forums.phpfreaks.com/topic/138134-solved-help-with-php-gd-creating-a-gd-image-from-a-page-with-an-image-extension/ Share on other sites More sharing options...
ratcateme Posted December 23, 2008 Share Posted December 23, 2008 i have never used it but my understanding is that you do it with mod_rewrite. i have never used it before but i am sure that is what you need to do this Scott. Link to comment https://forums.phpfreaks.com/topic/138134-solved-help-with-php-gd-creating-a-gd-image-from-a-page-with-an-image-extension/#findComment-722076 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.