Mahngiel Posted June 22, 2011 Share Posted June 22, 2011 Greetings, been a while since I've been here. I'm having a helluva problem using this imagecreate, as I am not able to output an actual image file. The output is here: www.mahngiel.com/kat/img2.php and my coding is below. (don't worry, nobody can see your IP except yourself, and it is not logged) Cheers! <?php //Validate IP if (!empty($_SERVER['HTTP_CLIENT_IP'])){ $ip=$_SERVER['HTTP_CLIENT_IP']; //Is it a proxy address }elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){ $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; }else{ $ip=$_SERVER['REMOTE_ADDR']; } //Original Image for background $img = imagecreatefrompng('ipfun.png'); imagealphablending($img, true); //Colors $black = imagecolorallocate($img, 0, 0, 0); $gold = imagecolorallocate($img, 255, 215, 0); $red = imagecolorallocate($img, 178, 34, 34); //Border imagesetthickness($img, 2); imagerectangle($img, 0, 2, 98, 98, $black); //Shapes imageline($img, 15,31, 80,31, $gold); imagerectangle($img, 4,80, 97,70, $red); //Strings $font_file = '../poll/mahngiel.ttf'; imagefttext($img, 13, 0, 15, 28, $black, $font_file, 'Your IP:'); imagefttext($img, 32, 350, 42, 63, $red, $font_file, '!'); imagefttext($img, 11, 0, 4, 80, $gold, $font_file, $ip); //Output header("Content-Type: image/png"); imagepng($img); imagedestroy($img); ?> Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/ Share on other sites More sharing options...
Pikachu2000 Posted June 22, 2011 Share Posted June 22, 2011 The attached is what I get. Is that different from what you're expecting? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233156 Share on other sites More sharing options...
Mahngiel Posted June 22, 2011 Author Share Posted June 22, 2011 I guess I was hoping for more of an image extension in the output. Notice my page output still ends in PHP, whereas my muse ends in a .jpg and is easily referred to external calls. http://www.danasoft.com/vipersig.jpg I've tried imagepng($img, $dest), which does output to disk, but it will no longer process the script. Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233358 Share on other sites More sharing options...
Pikachu2000 Posted June 22, 2011 Share Posted June 22, 2011 The image does have a .png extension. Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233389 Share on other sites More sharing options...
Mahngiel Posted June 22, 2011 Author Share Posted June 22, 2011 Copying the image location yields: http://www.mahngiel.com/kat/img2.php That does not allow me to hotlink it. What have I done wrong that I cannot the function to push it to a standalone .png like the example above? Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233395 Share on other sites More sharing options...
Pikachu2000 Posted June 22, 2011 Share Posted June 22, 2011 This works fine for me, is that what you're trying to do with it? <img src="http://www.mahngiel.com/kat/img2.php"> Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233403 Share on other sites More sharing options...
Mahngiel Posted June 22, 2011 Author Share Posted June 22, 2011 Hmm. Yes, i've noticed i could wrap it in an image tag with the .php extention - but I'm still missing a piece of the puzzle. I'm trying to use this as an avatar, which requires the link to have the extention png/jpg/etc etc. I can use the php-image i posted above, and it performs as it should; but I've yet to figure how I can duplicate that myself. Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233409 Share on other sites More sharing options...
Pikachu2000 Posted June 22, 2011 Share Posted June 22, 2011 I've not worked with the imagecreate functions enough to be able to offer much more than I already have. Surely someone else has done this though; I see others here with dynamic avatars/signature images, etc. Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233414 Share on other sites More sharing options...
Mahngiel Posted June 22, 2011 Author Share Posted June 22, 2011 Thanks for trying and your input, Pika. Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233417 Share on other sites More sharing options...
Mahngiel Posted June 22, 2011 Author Share Posted June 22, 2011 bump Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233491 Share on other sites More sharing options...
Mahngiel Posted June 23, 2011 Author Share Posted June 23, 2011 Still trying to figure out how to push that .php image into a .png/gif/jpg/wbmp Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233862 Share on other sites More sharing options...
Andy-H Posted June 23, 2011 Share Posted June 23, 2011 mod_rewrite? Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233865 Share on other sites More sharing options...
Mahngiel Posted June 23, 2011 Author Share Posted June 23, 2011 mod_rewrite? Alright, I think we're onto the right track. I've spent the last hour reading into mod_rewrite and think I have a decent grasp. Not getting it done however. With the img2.php script sitting in that /kat folder, my .htaccess in the root folder looks like this: RewriteEngine on RewriteRule ^/kat/img\.png$ /kat/img2.php I got some 404s, so I also tried this: RewriteEngine on RewriteRule ^/kat/img2\.php$ /kat/img2.png [PT] Still nothing. Anybody got a clue? Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233906 Share on other sites More sharing options...
Mahngiel Posted June 23, 2011 Author Share Posted June 23, 2011 Cannot edit my post, but I got it figured out. here's the .htaccess file in my /kat dir: Options +FollowSymLinks RewriteEngine On RewriteBase /kat/ RewriteRule img2.gif img2.php Quote Link to comment https://forums.phpfreaks.com/topic/240065-imagecreate-failing/#findComment-1233911 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.