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


GD-library header probs





noliver
Hi,

I can verify that the GD_Lib (used for generating images) is installed
( and working ) with
<?PHP print_r(gd_info()); ?>
on this server - so that is not the problem -

The problem comes in when I want to draw an image using the GD-Lib.

(this example works on my linux box at home but refuses to work on this server )

CODE START -----------------------------------------------

<?PHP


error_reporting(E_ALL ^ E_NOTICE);

/*
simplepng.php
Generates a 50 x 50 pixel png of the color passed in parameter 'color'
*/

// convert guaranteed valid hex value to array of integers
$imColor = hex2int(validHexColor($_REQUEST['color']));

// Step 1. Create a new blank image
$im = imageCreate(50,50);

// Step 2. Set background to 'color'
$background = imageColorAllocate($im, $imColor['r'], $imColor['g'], $imColor['b']);

// Step 3. Send the headers (at last possible time)
header('Content-type: image/png');

// Step 4. Output the image as a PNG
imagePNG($im);

// Step 5. Delete the image from memory
imageDestroy($im);

/**
* @param $hex string 6-digit hexadecimal color
* @return array 3 elements 'r', 'g', & 'b' = int color values
* @desc Converts a 6 digit hexadecimal number into an array of
* 3 integer values ('r' => red value, 'g' => green, 'b' => blue)
*/
function hex2int($hex) {
return array( 'r' => hexdec(substr($hex, 0, 2)), // 1st pair of digits
'g' => hexdec(substr($hex, 2, 2)), // 2nd pair
'b' => hexdec(substr($hex, 4, 2)) // 3rd pair
);
}

/**
* @param $input string 6-digit hexadecimal string to be validated
* @param $default string default color to be returned if $input isn't valid
* @return string the validated 6-digit hexadecimal color
* @desc returns $input if it is a valid hexadecimal color,
* otherwise returns $default (which defaults to black)
*/
function validHexColor($input = '000000', $default = '000000') {
// A valid Hexadecimal color is exactly 6 characters long
// and eigher a digit or letter from a to f
return (eregi('^[0-9a-f]{6}$', $input)) ? $input : $default ;
}

?>

CODE END ---------------------------


Any suggestions ?

Cheers,
Nick.
noliver
Nevermind,

Sorted it out - so I guess a moderator can delete this post ?

It was just a "rights" issue. -


Cheers,
Nick.
foggy
Glad you got it sorted out.

-closed-
Related topics
How To : Secure Your PHP Website
Dynamic PHP Images
GD or ImageMagick Support?
web stats in a web banner, how do u make it appear in sig
Does frihost has GD installed?
Does somones use GD library?
GD library?
How to create a php files that contain a image ?
GD Library...
GD and XS Mod
Having a prob with GD library
url access and gd-library?
GD library
Captcha: GD Library
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

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