Page 1 of 1

How to check if GD2 extension is loaded?

Posted: Tue Nov 30, 2004 9:20 am
by WaldoMonster
For the GD extension this code works:

Code: Select all

<?php
if (!extension_loaded('gd')) echo('GD extension not loaded');
?>
But how can I check if GD2 (on windows) is loaded?

Another question.
What was the first release above PHP 4.1.0 that came with the GD2 extension (windows compile)?

Thanks for the help.

Posted: Tue Nov 30, 2004 9:36 am
by number8
You can see the names of various extensions by using phpinfo() or if you're using the CGI or CLI version of PHP you can use the -m switch to list all available extensions

-Or-

Use print_r(get_loaded_extensions()); to get all loaded extensions.

I hope this will show you the right way 8)

Posted: Tue Nov 30, 2004 9:38 am
by kettle_drum
Or:

Code: Select all

print_r(gd_info());

Posted: Tue Nov 30, 2004 11:56 am
by WaldoMonster
Thanks kettle_drum,

Code: Select all

<?php
$gd_info = gd_info();
echo $gd_info['GD Version'];
?>
returns something like:

Code: Select all

bundled (2.0.28 compatible)
I'm not so good with preg_match, how can I check if it is version 2 or newer?
Checking if 'imagecreatetruecolor' function exit, is this a good alternative?

Posted: Tue Nov 30, 2004 12:09 pm
by redmonkey
The gd_info() function is only available in PHP v4.3 and above, PHP v4.3 only has the imagecreatetruecolour function available if G.D 2 is loaded so you can use a standard function_exists() to determine if GD2 is loaded.

Re: How to check if GD2 extension is loaded?

Posted: Tue Nov 30, 2004 2:43 pm
by pickle
Couldn't you just go:

Code: Select all

<?php
if (!extension_loaded('gd2')) echo('GD extension not loaded');
?>
??

Re: How to check if GD2 extension is loaded?

Posted: Tue Nov 30, 2004 5:47 pm
by WaldoMonster
pickle wrote:Couldn't you just go:

Code: Select all

<?php
if (!extension_loaded('gd2')) echo('GD extension not loaded');
?>
??
That doesn't work.
Otherwise I would use that :wink:

Posted: Tue Nov 30, 2004 5:50 pm
by WaldoMonster
redmonkey wrote:The gd_info() function is only available in PHP v4.3 and above, PHP v4.3 only has the imagecreatetruecolour function available if G.D 2 is loaded so you can use a standard function_exists() to determine if GD2 is loaded.
I will go for:

Code: Select all

<?php
if (!function_exists('imagecreatetruecolor')) echo('GD2 extension not loaded');
?>
Thanks