* @see Image_Text::set(), Image_Text::construct(), Image_Text::init()
*/
- function Image_Text($text, $options = null)
+ function __construct($text, $options = null)
{
- $this->set('text', $text);
+ $this->set('text', $text);
+
if (!empty($options)) {
- $this->options = array_merge($this->options, $options);
- }
+ $this->options = array_merge($this->options, $options);
+ }
+
}
/**
// todo: with some versions of the GD-library it's also possible to leave font_path empty, add strip ".ttf" from
// the fontname; the fontfile will then be automatically searched for in library-defined directories
// however this does not yet work if at this point we check for the existance of the fontfile
+
$font_file = rtrim($this->options['font_path'], '/\\');
$font_file.= (OS_WINDOWS) ? '\\' : '/';
$font_file.= $this->options['font_file'];
$font_file = realpath($font_file);
if (empty($font_file) || !is_file($font_file) || !is_readable($font_file)) {
- return PEAR::staticRaiseError('Fontfile not found or not readable.');
+ return PEAR::staticRaiseError('Fontfile not found or not readable: ' . $font_file);
} else {
$this->_font = $font_file;
}
*/
function init($options = array())
{
+
if (!is_array($options)) {
// Compatibility mode ... in future versions, these two
// lines of code will be used:
if (isset($options['imageOptions']) && is_array($options['imageOptions']) && count($options['imageOptions']) > 0) {
$this->_imageOptions = array_merge($this->_imageOptions, $options['imageOptions']);
}
+
return true;
}
+
}
/**
$options['background_color'] = $this->_imageOptions['background_color'];
$options['max_lines'] = 1;
$options['mode'] = 'auto';
- do {
+ do {
$this->_imt = new Image_Text(
$this->_phrase,
$options
);
+
+
if (PEAR::isError($e = $this->_imt->init())) {
$this->_error = PEAR::staticRaiseError(
sprintf('Error initializing Image_Text (%s)', $e->getMessage()));
if (PEAR::isError($retval)) {
return PEAR::staticRaiseError($retval->getMessage());
}
-
- if (is_resource($this->_im)) {
+ if (is_object($this->_im)) {
ob_start();
imagepng($this->_im);
$data = ob_get_contents();
ob_end_clean();
return $data;
} else {
- $this->_error = PEAR::raiseError('Error creating CAPTCHA image (font missing?!)');
+ $this->_error = PEAR::staticRaiseError('Error creating CAPTCHA image (font missing?!)');
return $this->_error;
}
}
return PEAR::raiseError($retval->getMessage());
}
- if (is_resource($this->_im)) {
+ if (is_object($this->_im)) {
ob_start();
imagejpeg($this->_im);
$data = ob_get_contents();
return PEAR::raiseError($retval->getMessage());
}
- if (is_resource($this->_im)) {
+ if (is_object($this->_im)) {
ob_start();
imagegif($this->_im);
$data = ob_get_contents();