FAQ
Edit report at https://pear.php.net/bugs/bug.php?id=17623&edit=1

  ID: 17623
  Updated by: michael@bigmichi1.de
  Reported By: hm2k@php.net
  Summary: Notice: Array to string conversion in
                     /usr/share/pear/Image/Text.php...
-Status: Open
+Status: Closed
  Type: Bug
  Package: Image_Text
  Package Version: SVN
  PHP Version: Irrelevant
-Assigned To:
+Assigned To: bigmichi1
  Roadmap Versions:
  New Comment:

-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: bigmichi1
This bug has been fixed in SVN.

If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should
be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.




Previous Comments:
------------------------------------------------------------------------

[2011-12-09 17:25:04] doconnor

I think you are gouing to have a better shot than I am at fixing this!
Fork away,
andI'll make sure the changes needed to fix this get applied

------------------------------------------------------------------------

[2010-07-23 00:26:43] hm2k

Description:
------------
Change
'color' => $colors,
To
'color' => '#000000',

You get the following error:

Notice: Array to string conversion in /usr/share/pear/Image/Text.php on
line 525

Test script:
---------------
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
  * Image_Text example.
  *
  * Example file for the usage of Image_Text.
  *
  * PHP versions 4 and 5
  *
  * LICENSE: This source file is subject to version 3.0 of the PHP
license
  * that is available through the world-wide-web at the following URI:
  * http://www.php.net/license/3_0.txt. If you did not receive a copy
of
  * the PHP License and are unable to obtain it through the web, please
  * send a note to license@php.net so we can mail you a copy
immediately.
  *
  * @category Image
  * @package Text
  * @author Tobias Schlitt <toby@php.net>
  * @copyright 1997-2005 The PHP Group
  * @license http://www.php.net/license/3_0.txt PHP License 3.0
  * @version CVS: $Id: example.php 233863 2007-04-16 09:52:34Z cweiske
$
  * @link http://pear.php.net/package/Net_FTP2
  * @since File available since Release 0.0.1
  */

// ini_set('include_path', '.:/cvs/pear/Image_Text:/usr/share/pear');

require_once 'Image/Text.php';

function getmicrotime()
{
     list($usec,$sec) = explode(' ', microtime());
     return ((float)$usec+(float)$sec);
}


$texts[] = "a passion for php"; // Short Text
$texts[] = "a good computer is like a tipi - no windows, no gates and an
apache inside"; // Normal Text
$texts[] = "What is PEAR?\nThe fleshy pome, or fruit, of a rosaceous
tree (Pyrus communis), cultivated in many varieties in temperate
climates.\nPEAR is a framework and distribution system for reusable PHP
components. PECL, being a subset of PEAR, is the complement for C
extensions for PHP. See the FAQ and manual for more information."; //
Long Text
$texts[] = "EXTERIOR: DAGOBAH -- DAY\nWith Yoda\nstrapped to\n\nhis
back, Luke climbs up one of the many thick vines that grow in the swamp
until he reaches the Dagobah statistics lab. Panting heavily, he
continues his exercises -- grepping, installing new packages, logging in
as root, and writing replacements for two-year-old shell scripts in
PHP.\nYODA: Code! Yes. A programmer's strength flows from code
maintainability. But beware of Perl. Terse syntax... more than one way
to do it... default variables. The dark side of code maintainability are
they. Easily they flow, quick to join you when code you write. If once
you start down the dark path, forever will it dominate your destiny,
consume you it will.\nLUKE: Is Perl better than PHP?\nYODA: No... no...
no. Orderless, dirtier, more seductive.\nLUKE: But how will I know why
PHP is better than Perl?\nYODA: You will know. When your code you try to
read six months from now...";
$texts[] = "1. The idea:\nThe idea is very simple. I wanted to have 2
versions of PHP (4.3.4 and 5.0beta3) running together on 1 maschine,
both as Apache 1.3 modules.\n2. Compiling PHP:\nI had a PHP 4.3.4
running on my devbox and compiled a PHP 5 version in addition. This can
be managed in a bloody simple way. Download a copy of PHP 5, unpack the
archive to any directory. Copy the './configure' statement from your
installed PHP version and exchange/create the prefix option, e.g.
'--prefix=/usr/php5' and change the '--with-config-file-path' to a
different location (e.g. '/etc/php5').\n\nRun the './configure'
statement inside the unpack directory using './configure '. You can get
a complete list opf PHP 5 supported option with './configure
--help'.\n\nPHP 5 make files had been created successfully (most errors
shouls result from version conflicts of libraries and header files, you
can easiely solve this by installing or compiling new versions of the
required packages/development-packages). Now you should run the 'make'
statement and get a coffee, during your first PHP 5 compile... ein Wort
\nmehr";
$texts[] = "1. The idea: \n\n\n\nThe idea is very simple. I wanted to
have 2 versions of PHP (4.3.4 and 5.0beta3) running together on 1
maschine, both as Apache 1.3 modules. \n\n \n\n2. Compiling PHP: \n\n
\n\nI had a PHP 4.3.4 running on my devbox and compiled a PHP 5 version
in addition. This can be managed in a bloody simple way. Download a copy
of PHP 5, unpack the archive to any directory. Copy the './configure'
statement from your installed PHP version and exchange/create the prefix
option, e.g. '--prefix=/usr/php5' and change the
'--with-config-file-path' to a different location (e.g. '/etc/php5').
\n\n \n\nRun the './configure' statement inside the unpack directory
using './configure '. You can get a complete list opf PHP 5 supported
option with './configure --help'. \n\n \n\nPHP 5 make files had been
created successfully (most errors shouls result from version conflicts
of libraries and header files, you can easiely solve this by installing
or compiling new versions of the required
packages/development-packages). Now you should run the 'make' statement
and get a coffee,\nduring your first PHP 5 compile...";
$texts[] = "1. The idea: The idea is very simple. I wanted to have 2
versions of PHP (4.3.4 and 5.0beta3) running together on 1 maschine,
both as Apache 1.3 modules. 2. Compiling PHP: I had a PHP 4.3.4 running
on my devbox and compiled a PHP 5 version in addition. This can be
managed in a bloody simple way. Download a copy of PHP 5, unpack the
archive to any directory. Copy the './configure' statement from your
installed PHP version and exchange/create the prefix option, e.g.
'--prefix=/usr/php5' and change the '--with-config-file-path' to a
different location (e.g. '/etc/php5'). Run the './configure' statement
inside the unpack directory using './configure '. You can get a complete
list opf PHP 5 supported option with './configure --help'. PHP 5 make
files had been created successfully (most errors shouls result from
version conflicts of libraries and header files, you can easiely solve
this by installing or compiling new versions of the required
packages/development-packages). Now you should run the 'make' statement
and get a coffee, during your first PHP 5 compile...";

$options = array(
             'cx' => 300,
             'cy' => 300,
             'canvas' => array('width'=> 600,'height'=> 600),
             'width' => 300,
             'height' => 300,
             'line_spacing' => 1,
             'angle' => 0,
             'color' => '#000000',
             'background_color' => '#FF0000', //red background
             'max_lines' => 100,
             'min_font_size' => 2,
             'max_font_size' => 50,
             'font_path' => './',
             'antialias' => true,
             'font_file' => 'src/verdana.TTF',
             'halign' => IMAGE_TEXT_ALIGN_LEFT
         );

$text = $texts[array_rand($texts)];

foreach ($_GET as $key => $val) {
     switch ($key) {
         case 'font_size':
             $options['font_size'] = (int)$val;
             break;
         case 'line_spacing':
             $options['line_spacing'] = $val;
             break;
         case 'halign':
             $options['halign'] = $val;
             break;
         case 'valign':
             $options['valign'] = $val;
             break;
         case 'angle':
             $options['angle'] = $val;
             break;
         case 'text':
             $text = $texts[$val];
             break;
     }
}

$start = getmicrotime();

$itext = new Image_Text($text, $options);

$ret = $itext->init();
if (PEAR::isError($ret)) {
     echo $ret->getMessage() . "\n";
     die();
}

if (empty($options['font_size'])) {
     $itext->autoMeasurize();
} else {
     $itext->measurize();
}

$itext->render();

$end = getmicrotime();

$time = $end - $start;

if (isset($_GET['debug'])) {
     echo "<h1>-- DEBUGGING MODE --</h1>";
} else {

     $img =& $itext->getImg();

     $red = imagecolorallocate($img, 255, 0, 0);

     imagefilledellipse($img, 300, 300, 10, 10, $red);

     if (isset($_GET['info'])) {
         imagettftext($img, 10, 0, 10, 550, $red, "./Vera.ttf", "$time
sec.");
     }

     //$itext->display();

}

?>


Expected result:
----------------
A PNG image.

Actual result:
--------------
Notice: Array to string conversion in /usr/share/pear/Image/Text.php on
line 525

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedAug 7, '13 at 11:01a
activeAug 7, '13 at 11:01a
posts1
users1
websitepear.php.net

1 user in discussion

Michael: 1 post

People

Translate

site design / logo © 2022 Grokbase