1821981 Members
3235 Online
109638 Solutions
New Discussion юеВ

Apache, PHP and Images

 
SOLVED
Go to solution
MR VILLOT   MR MONTAGNE
Frequent Advisor

Apache, PHP and Images

Hello,

I have HP-UX Apache-based Web Server and MySQL Database on HP-UX Server.

Now I would like to generate graphics with php using tools like jpgraph.

I did a simple test to generate graphics with php but I do not get anything :




images


Images



png bleu
jpeg rouge






$image=imagecreate(100,100);
$rouge=imagecolorallocate($image,255,0,0);
imagefill($image,0,0,$rouge);
header('Content-type: image/jpeg');
imagejpeg($image);
?>

$image=imagecreate(100,100);
$bleu=imagecolorallocate($image,0,0,255);
imagefill($image,0,0,$bleu);
header('Content-type: image/png');
imagepng($image);
?>

I did also tests with jpgraph without success (blank page).I must not have good libs with PHP. I need also to configure gd librairies for jpgraph.

How can i do with this distributed version of PHP ?

Thanks

Laurent
27 REPLIES 27
Ermin Borovac
Honored Contributor

Re: Apache, PHP and Images

Full intructions on how to enable GD with HP's Apache are in the following knowledge base article.

Date: 10/19/04
Document description: Configuring and Testing PHP image libraries w HP Apache 2.0
Document id: MJFKBRC00015829
Alex Lavrov.
Honored Contributor

Re: Apache, PHP and Images

To enable GD you should go to your php.ini file. In some versions it's located in /etc/php.ini and in some in /opt/hpws/apache/php/php.ini.

There you locate the list of extensions that you can enable and you uncomment the GD extension.

Now, when you restart apache, it will nt work, because GD requires libraries that are not installed by default on the system. A very simple way to see what are these libraries is to go to errors_log of apache (located in /opt/hpws/apache/logs) and see what library is missing. Then, you go here:
http://hpux.cs.utah.edu/
and in the search box, enter the name of the lib and install that depot (with this lib) and all it's dependencies. After a few installations it will work, I've done it several times.

It can take time, because there are many depots to install, but all of them are small, so I believe in 20-30 minutes your GD extension will work.

Regards,
Alex
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Alex Lavrov.
Honored Contributor

Re: Apache, PHP and Images

P.S. Ermin, can you please post a link to the article please? I'll be interested to read it.

thanx.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Ermin Borovac
Honored Contributor

Re: Apache, PHP and Images

Alex,

You can access article as follows

http://www.itrc.hp.com -> technical knowledge base -> select 'search by doc ID' -> enter MJFKBRC00015829
Alex Lavrov.
Honored Contributor

Re: Apache, PHP and Images

Oh, I believe I need a conract ID for the knowledge base ...
I don't give a damn for a man that can only spell a word one way. (M. Twain)
MR VILLOT   MR MONTAGNE
Frequent Advisor

Re: Apache, PHP and Images

Hi,

Thanks for your help. It works fine with the first scripts. Now, I would like to use jpgraph with this small test :

include ("/opt/hpws/apache/htdocs/info/jpgraph-1.17/src/jpgraph.php");
include ("/opt/hpws/apache/htdocs/info/jpgraph-1.17/src/jpgraph_line.php");

$ydata = array(8,3,16,2,7,25,16);

// Creation du graphique
$graph = new Graph(300,200);
$graph->SetScale("textlin");

// CrM-iation du systM-hme de points
$lineplot=new LinePlot($ydata);

// On rajoute les points au graphique
$graph->Add($lineplot);

// Affichage
$graph->Stroke();
?>

When I browse my url I get the following message :
JpGraph Error: Can't create truecolor image. Check that you really have GD2 library installed.

My version is :
gd 2.0.33 gd

I think it could be a setting in a configuration file in jpgraph.

Laurent


MR VILLOT   MR MONTAGNE
Frequent Advisor

Re: Apache, PHP and Images

Hi,

I did tests to check my GD libraries :
for GD library :
$im = @ImageCreate (150, 100)
or die ("Cannot create a new GD image.");
$background_color = ImageColorAllocate ($im, 255, 255, 255);
$text_color = ImageColorAllocate ($im, 233, 14, 91);
ImageString ($im, 1, 5, 5, "A Simple Text String", $text_color);
header ("Content-type: image/png");
ImagePng ($im);
?>
--> OK

for GD2 library :
$im = imagecreatetruecolor (300, 200);
$black = imagecolorallocate ($im, 0, 0, 0);
$white = imagecolorallocate ($im, 255, 255, 255);

imagefilledrectangle($im,0,0,399,99,$white);
imagerectangle($im,20,20,250,190,$black);

header ("Content-type: image/png");
imagepng ($im);

--> I get :
Warning: imagecreatetruecolor(): requires GD 2.0 or later in /opt/hpws/apache/htdocs/info/testgd2.php on line 2

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /opt/hpws/apache/htdocs/info/testgd2.php on line 3

I get gd library on :
http://hpux.asknet.de/hppd/hpux/Development/Libraries/gd-2.0.33/

If I change DEFINE('USE_TRUECOLOR',true); to false it does not work !!

With phpinfo.php :

GD Support enabled
GD Version 1.6.2 or higher
FreeType Support enabled
FreeType Linkage with freetype
T1Lib Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled

I am disappointed !!
My GD library seems to be GD2 library but I do not why it is not possible to generate graphics ?
If anybody knows how to configure jpgraph whith HP-UX Apache, I will be very interested in.

Laurent
Alex Lavrov.
Honored Contributor

Re: Apache, PHP and Images

What exactly did you install?

I used all the depots that can be found in that porting archive and I'm using jpgraph on many hpux boxes.

Can yo post here the packages you installed and how you installed tham?
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Ermin Borovac
Honored Contributor

Re: Apache, PHP and Images

>>> With phpinfo.php :

>>> GD Support enabled
>>> GD Version 1.6.2 or higher

This tells me that PHP is picking up older version of GD from somewhere. It should say version 2.0 or higher.

What does the following command return?

# ldd -v /opt/hpws/apache/php/lib/php/extensions/gd.sl
Alex Lavrov.
Honored Contributor

Re: Apache, PHP and Images

I think you have somewhere old gd.sl and it takes it.

echo $SHLIB_PATH
I don't give a damn for a man that can only spell a word one way. (M. Twain)
MR VILLOT   MR MONTAGNE
Frequent Advisor

Re: Apache, PHP and Images

Hi,

I joined file with results of ldd.
the share library gd.sl in /opt/hpws/apache/php/lib/php/extensions must be an old library (hpuxwsApache A.1.0.06.02 HP-UX Apache-based Web Server)

I installed new library gd 2.0.33 (libgd.sl in /usr/local/lib)

My apache configuration files :
php.ini :

extension_dir = /opt/hpws/apache/php/lib/php/extensions

extension=gd.sl

apachectl :

export SHLIB_PATH=$APACHE_PREFIX/php/lib/php/extensions:/usr/local/lib:$SHLIB_PATH

How can I set the new version of gd library in Apache ? I tried with symbolic link but it does not work.
I can upgrade my version of Apache server (I must check if gd2 library is available)


Alex Lavrov.
Honored Contributor

Re: Apache, PHP and Images

I don't think you need to upgrade. You apache is not that old and it has nothing to do with the apache version anyway.

Are you sure that libgd.sl in /usr/local/lob is the new one?

do:
what /usr/local/lib/libgd.sl
file /usr/local/lib/libgd.sl
I don't give a damn for a man that can only spell a word one way. (M. Twain)
MR VILLOT   MR MONTAGNE
Frequent Advisor

Re: Apache, PHP and Images


Yes,Alex

I checked with Software Installed (SAM) for product gd 2.0.33.

I get 3 libraries in /usr/local/lib :
libgd.a
libgd.la
libgd.sl

#file /usr/local/lib/libgd.sl
/usr/local/lib/libgd.sl: PA-RISC2.0 shared library

Now, I would like that apache and php use this library and not gd.sl which is set by HP-UX Apache.
Alex Lavrov.
Honored Contributor

Re: Apache, PHP and Images

What about:
what /usr/local/lib/libgd.sl


gd.sl that is located under your apache is not the same thing as lidgd.sl.

gd.sl is a shared library of php, so php will be able to use GD installed on your system and libgd.sl is the GD itself, so you can't replase one with another, because they are different things.

If you run find for libgd.sl, do you get only "/ust/local/lib/libgd.sl" ?
I don't give a damn for a man that can only spell a word one way. (M. Twain)
MR VILLOT   MR MONTAGNE
Frequent Advisor

Re: Apache, PHP and Images


for what :
#what /usr/local/lib/libgd.sl
/usr/local/lib/libgd.sl:

for find :
#find / -name "libgd.sl"
/usr/local/lib/libgd.sl

If I want to put good version of gd.sl library in php directory, How can I do ?

I download libraries from HP-UX Porting and Archive Centre of HP-UX
Alex Lavrov.
Honored Contributor

Re: Apache, PHP and Images

According to this it should work.
When you rename libgd.sl to something else, do you have errors in error_log of apache?

This how we can be sure that it uses libgd.sl.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Ermin Borovac
Honored Contributor

Re: Apache, PHP and Images

I suggest that you update to current version of HP's apache web server. It includes GD library version 2 in the extensions directory.

http://www.hp.com/go/webserver
MR VILLOT   MR MONTAGNE
Frequent Advisor

Re: Apache, PHP and Images

Alex,

I did the test :
mv libgd.sl to libgd.sl.1

restart apache server
error_log :
[Thu May 12 14:10:51 2005] [notice] LDAP: Built with OpenLDAP LDAP SDK
[Thu May 12 14:10:51 2005] [notice] LDAP: SSL support unavailable
[Thu May 12 14:10:52 2005] [notice] Digest: generating secret for digest authentication ...
[Thu May 12 14:10:52 2005] [notice] Digest: done
[Thu May 12 14:10:52 2005] [notice] LDAP: Built with OpenLDAP LDAP SDK
[Thu May 12 14:10:52 2005] [notice] LDAP: SSL support unavailable
PHP Warning: Unable to load dynamic library '/opt/hpws/apache/php/lib/php/extensions/gd.sl' - Can't find path for shared library: lib
gd.sl in Unknown on line 0
[Thu May 12 14:10:52 2005] [notice] HP-UX_Apache-based_Web_Server/2.0.46 (Unix) DAV/2 PHP/4.2.3 configured -- resuming normal operatio
ns

Apache uses libgd.sl !
Ermin Borovac
Honored Contributor

Re: Apache, PHP and Images

Just a note that with newer versions of webserver, /usr/local/lib/libgd.sl is no longer required or used by /opt/hpws/apache/php/lib/php/extensions/gd.sl. It is built into gd.sl extension instead.

I suspect there is some incompatibility between gd.sl and libgd.sl you have and php doesn't like it.

MR VILLOT   MR MONTAGNE
Frequent Advisor

Re: Apache, PHP and Images

I upgraded my webserver and configured configuration files.

Now when i try to check my library with gd scripts on my host with mozilla, I get :

The image "http://machine/info/testgd.php" cannot displayed, because it contains erros.

error_log in apache gives :
[Thu May 12 15:54:20 2005] [error] an unknown filter was not added: PHP

Alex Lavrov.
Honored Contributor

Re: Apache, PHP and Images

If you execute it on it's own, not in tag:

http://machine/info/testgd.php

What are the PHP errors that you get?
I don't give a damn for a man that can only spell a word one way. (M. Twain)
MR VILLOT   MR MONTAGNE
Frequent Advisor

Re: Apache, PHP and Images

/opt/hpws/apache/htdocs/info#more imagepng.php
$image=imagecreate(100,100);
$bleu=imagecolorallocate($image,0,0,255);
imagefill($image,0,0,$bleu);
header('Content-type: image/png');
imagepng($image);
?>

url : http://machine/info/imagejpeg.php = OK
but http://machine/info/imagepng.php = same erros as before in my browser and in error _log.

with this script :
$im = imagecreatetruecolor (300, 200);
$black = imagecolorallocate ($im, 0, 0, 0);
$white = imagecolorallocate ($im, 255, 255, 255);

imagefilledrectangle($im,0,0,399,99,$white);
imagerectangle($im,20,20,250,190,$black);

header ("Content-type: image/png");
imagepng ($im);
?>
--> same thing
MR VILLOT   MR MONTAGNE
Frequent Advisor

Re: Apache, PHP and Images


New info :
I have this message in error_log file :
libpng warning: Application was compiled with png.h from libpng-1.0.11
libpng warning: Application is running with png.c from libpng-1.2.8

I have installed patch PHSS_30970 : ld(1) and linker tools cumulative patch on my host.

Alex Lavrov.
Honored Contributor

Re: Apache, PHP and Images

I don't think this patch gonna help, because you are not compiling and linking programs, you're installing precompiled binaries.

According to the message, you have a mistmatch in binaries. Did you install all the newest libraries? gd, libpng?
Never seen this message before.



I don't give a damn for a man that can only spell a word one way. (M. Twain)