Examples error: imagepsloadfont() undefined

Login or register to post comments
10 replies [Last post]
LaCeja's picture
Offline
Joined: 11/04/2009

I'm getting the following error, when I run the "Dynamically Created Image Labels" tutorial (No. 10, Advanced Controls) of the Examples Site. I imagine I'll get the same error, when I attempt to use this feature in my development.

Fatal error: Call to undefined function imagepsloadfont() in C:\wamp\www\hobbies\includes\qcodo\_core\qform\QImageLabelBase.class.php on line 190

I checked phpinfo to be sure it is enabled:

GD Support => enabled
GD Version => bundled (2.0.34 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.3.9
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 6b
PNG Support => enabled
libPNG Version => 1.2.37
WBMP Support => enabled
XBM Support => enabled

Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 0 => 0

Is there a fix for this? Help!

Thanks.

Offline
Joined: 03/31/2008

http://examples.qcu.be/assets/_core/php/examples/image_label/intro.php works for me..?

As for that error, it sounds like maybe you're running an old version of some file.

alex94040's picture
Offline
Joined: 11/06/2008

This clearly isn't an issue with QCubed - it's a problem with your PHP installation, as imagepsloadfont() is a function defined by a PHP extension. What's your system config (OS, web server, PHP version?)

LaCeja's picture
Offline
Joined: 11/04/2009

I'm running Windows XP, Apache 2.2.11, and PHP 5.3.0.

scottux's picture
Offline
Joined: 11/07/2008

This function is only available if PHP is compiled using --with-t1lib[=DIR].

http://joshcarter.com/software/gd_font_rendering_differences has an example:

Building PHP With T1Lib on Windows

The Win32 binary available from PHP.net does not include T1Lib, and as you can see here, TrueType font rendering on Windows leaves something to be desired. If you want to use the PostScript T1Lib, you'll need to grab source and build your own. I used Cygwin for the build because you can get all the necessary libraries pre-built, thus saving a huge amount of hassle. Here's the PHP configure line I used:

./configure --with-iconv --with-gd --with-t1lib=/cygdrive/c/cygwin/lib
  --with-png-dir=/cygdrive/c/cygwin/lib --with-freetype-dir=/cygdrive/c/cygwin/lib
  --with-libxml-dir=/cygdrive/c/cygwin/lib --with-zlib-dir=/cygdrive/c/cygwin/lib

Note that this does not create a web-safe version of PHP (according to the configure script). For my use generating buttons, I'm doing it locally from the command line so that's okay. Your needs may vary, and you'll probably need more configure options than I used here.

LaCeja's picture
Offline
Joined: 11/04/2009

Thanks scottux!

Do you or anyone know if this feature is needed for captcha?

Thanks again!

scottux's picture
Offline
Joined: 11/07/2008

Only if your captcha system needs postscript font rendering. GD uses the freetype library, which shouldn't rely on that function.

LaCeja's picture
Offline
Joined: 11/04/2009

Thank you very much!

Offline
Joined: 04/04/2008

Hi

I also would like to use this in a captcha system on Qcubed. However I really don't/can't use the postscript fonts. Can QImageLabelBase.class be changed to use GD ttf fonts with imageloadfont? If so... has anyone done it.

Thanks

Dave

alex94040's picture
Offline
Joined: 11/06/2008

I'm sure it's possible - in fact, i think it should be pretty easy to change. Just mod the QImageLabelBase class to allow for both font types.

If you end up doing this, could you share your patch with the rest of the community?

grossini's picture
Offline
Joined: 01/05/2009

I think that the image_label example in windows installation has two problems.

The first problem is also present in online example and arise from ImageLabel not responding to click

The second problem is from php 5.3 compiled without .pfb font support.
to solve this I copied the 2 ttf fonts (before I installed qcaptcha plugin) present in ..qcubed_210\includes\qcubed\plugins\QCaptchaTextBox\fonts to qcubed_210\includes\qcubed\_core\fonts and patched qcubed_210\assets\_core\php\examples\image_label\intro.php line 17

//if ($intPosition = strpos($strFile, '.pfb'))
if ($intPosition = strpos($strFile, '.ttf'))

To be confirmed on first problem I added a button able to react to click
and clicking on button changed the image label as expected.

So I suspect that ImageLabel class is unable to react to click action.

Un caro saluto, Gianni.