FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Select a url for an image in image functions





The-Master
OK. I want to use the = $_GET function to get the location of an image but cannot seem to get it to work. I have tried this but get an error. Is there a better way to do this?:

Code:
<?php
error_reporting(E_ALL);
#header("Content-type: image/png");
header("Content-type: text/plain");
$image = @$_GET_['text'];
$img_bg_loc = 'http://www.dougie.frih.net/images/hpmembersig.PNG';
if(@$_GET['image']) {
   $image = $_GET['image'];
list($x, $y, $maxwidth) = array(0, 0, 0);
$fontsize = 18;
if(@$_GET['fontsize']) {
   $fontsize = $_GET['fontsize'];
}
$font = 'Halo.ttf';
$text = @$_GET['text'];
$image = @$_GET_['image'];
$im = imagecreatefrompng($image);
$yellow = imagecolorallocate($im, 0, 0, 0);
$image = @$_GET_['image'];
$img_w = imagesx($im);
$px = ($img_w - 7.5 * strlen($text)) / 2;
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefttext($img_bg_loc, $fontsize, 0, $x, $y,, $yellow, $font, $text);
imagepng($im);
imagedestroy($im);
?>
hexkid
The-Master wrote:
OK. I want to use the = $_GET function to get the location of an image but cannot seem to get it to work. I have tried this but get an error. Is there a better way to do this?:

Code:
<?php
/*01*/ error_reporting(E_ALL);
/*02*/ #header("Content-type: image/png");
/*03*/ header("Content-type: text/plain");
/*04*/ $image = @$_GET_['text'];
/*05*/ $img_bg_loc = 'http://www.dougie.frih.net/images/hpmembersig.PNG';
/*06*/ if(@$_GET['image']) {
/*07*/    $image = $_GET['image'];
/*08*/ list($x, $y, $maxwidth) = array(0, 0, 0);
/*09*/ $fontsize = 18;
/*10*/ if(@$_GET['fontsize']) {
/*11*/    $fontsize = $_GET['fontsize'];
/*12*/ }
/*13*/ $font = 'Halo.ttf';
/*14*/ $text = @$_GET['text'];
/*15*/ $image = @$_GET_['image'];
/*16*/ $im = imagecreatefrompng($image);
/*17*/ $yellow = imagecolorallocate($im, 0, 0, 0);
/*18*/ $image = @$_GET_['image'];
/*19*/ $img_w = imagesx($im);
/*20*/ $px = ($img_w - 7.5 * strlen($text)) / 2;
/*21*/ $white = imagecolorallocate($im, 255, 255, 255);
/*22*/ $black = imagecolorallocate($im, 0, 0, 0);
/*23*/ imagefttext($img_bg_loc, $fontsize, 0, $x, $y,, $yellow, $font, $text);
/*24*/ imagepng($im);
/*25*/ imagedestroy($im);
?>


line 04: $_GET_['text'] should not have the last underscore
line 06: where is the matching closing brace? ??????
line 07: make up your mind; image is $_GET['text'] or $_GET['image']?
line 08: Ok, but I prefer $x = $y = $maxwidth = 0;
line 15: Ah! you really mean $_GET_['image'] Smile
line 16: No error checking! Check the first example for imagecreatefrompng() in the PHP manual.
line 17: Why $yellow? 0, 0, 0 will create black.
line 18: Yes, yes, yes, I know. You don't need to repeat it every other line (but remove the extra _)
line 23: $img_bg_loc is a string. imagefttext() expects a resource created with an imagecreate* function.

Try to make your script work with constants instead of using $_GET variables. When that is working replace your constants.

Code:
# $image = $_GET['image'];
$image = 'The-Master';
The-Master
Thanks for the help hexkid. I will try and sort it. I am getting better at php slowly but surely. As you can see I am not too great yet Very Happy
Related topics
Tutorials
How to burn CLONEs
Url image
Slapping a WaterMark Automatically.
PHP Image functions
GD Library...
Pls help, onmouseover popup image frm database
ImageMagick - How to add text?
Image not showing
"drawing" with JavaScript
Twitter Clients
PHP MySQL Image loading
PHP Image crop
Review Me!
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.