Forum Moderators: open

Message Too Old, No Replies

Browsers fail to show images

Red "X" in middle of box

         

aragornking

3:37 pm on Oct 20, 2003 (gmt 0)

10+ Year Member



Hello. In using the Apache server via "localhost" to locally view some PHP/HTML code I am writing, I cannot get images to display: in IE, for example, I get a red X in the middle of a box.

I have PHP 4.11, and extension=php_gd2.dll uncommented in php.ini. I do have ACDSee installed and Symantec Antivirus in use which may be causing some interference. My registry entrees seem okay (e.g. "Content-type: image/png").

I must be overlooking something elementary. May I humbly ask if anyone has an idea of what may be the problem?

Thanks very much,
Eugene

korkus2000

3:50 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you right click on the picture nd look at properties, is that path valid?

Mark_A

3:52 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



check if the browser can load the image on its own from the same path as is in the outputted web page .. if it can then its odd indeed :-)

if it cant then

1) the path is wrong - the image is elsewhere
2) the path is right - the image is not in the right place

aragornking

4:24 pm on Oct 20, 2003 (gmt 0)

10+ Year Member



Thank you both for your speedy replies. I may have been unclear in my post: the images I am referring to are generated with the aid of the GD library. An example of a test code which yields an "X in a box" output (only) is this simple PHP example file:

<?php
header ("Content-type: image/png");
$img_handle = ImageCreate (230, 40);
$back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
$txt_color = ImageColorAllocate ($img_handle, 233, 114, 191);
ImageString ($img_handle, 31, 5, 5, "This is a simple test of GD", $txt_color);
ImagePng ($img_handle);
?>

I briefly got this to display the correct output yesterday using Localhost, but it then stopped working for no reason I could see (I changed nothing to make it work either, just pressed the "Back" button on IE a couple of times to exit out of other pages). When I tested it on a publicly-hosted site of mine, it worked, but only after I placed "ob_start();" at beginning of code (I got "headers" type errors otherwise).

Thanks
Eugene

DrDoc

5:06 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The "x" means that the script generated an error. Run the script "stand alone"...

aragornking

7:06 pm on Oct 20, 2003 (gmt 0)

10+ Year Member



Thanks DrDOC. I am at the moment unsure how to run PHP scripts in a standalone mode under Windows (XP), (I don't at the moment have access to my Linux box). I have seen this lack of proper image display with all scripts I have tried (my own + ones from the Web) and I am thinking it is something outside of the scripts.

Eugene

DrDoc

8:00 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



stand alone = type the URL in the browser, don't include it as the image source

aragornking

8:14 pm on Oct 20, 2003 (gmt 0)

10+ Year Member



Hi DrDoc. What I have been doing all along is typing in this line to the browser:

[localhost...]

where of course "fun2.php" is the name of the code file, which I showed earlier.

Is this what you mean? I double checked the output of phpinfo() and it does show GD to be properly intalled (php_gd2.dll).

Thanks for your patience.

Eugene

coopster

10:49 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



aragornking, your code should work as is. I tested it on my server (PHP 4.3.2) compiled with configure commands:

'--with-gd=/usr/local'
'--enable-gd-native-ttf'

Here are my GD settings:
=====================================

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

I would double check the installation configuration [us4.php.net] if you can't update your PHP version. But I recommend updating your PHP version, for, among other reasons, there is this NOTE from the manual:

Note: Since PHP 4.3 there is a bundled version of the GD lib. This bundled version has some additional features like alpha blending, and should be used in preference to the external library since it's codebase is better maintained and more stable.

Oh yeah, one last thing, it is probably a good practice to add an imagedestroy [us4.php.net] line to your code to free any memory associated with the image.

Regards,
coopster

aragornking

3:45 am on Oct 21, 2003 (gmt 0)

10+ Year Member



Thanks coopster. I followed your advice and upgraded PHP to 4.3.3. I had to alter php.ini slightly, such as commenting out php_gd2.dll, since it gave errors:

Unknown(): gd: Unable to initialize module
Module complied with module API=20010901, debug=0, thread-safety=1, etc.

I presume since the GD library is now integrated in to PHP, one does not need to "manually" incorporate php_gd2.dll? However, unlike you, I did not see a separate GD section when I ran phpinfo(). So something appears to be wrong.

I still have not got my php/GD-generated images to display.

Eugene

coopster

10:59 am on Oct 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I had to alter php.ini slightly, such as commenting out php_gd2.dll, since it gave errors

Yes, you would have to do this as it is states this point specifically in the link I sent you:

[us4.php.net...]

To enable GD-support configure PHP --with-gd[=DIR], where DIR is the GD base install directory. To use the recommended bundled version of the GD library (which was first bundled in PHP 4.3.0), use the configure option --with-gd. In Windows, you'll include the GD2 DLL php_gd2.dll as an extension in php.ini. The GD1 DLL php_gd.dll was removed in PHP 4.3.2.

I don't think you have your installation/configuration correct yet.

I assume you are still running the test against your local Windows box as opposed to the Linux box and you have updated PHP to 4.3.3 on the Windows box. The PHP Manual has a function reference page dedicated to the Image functions and the User Contributed notes add plenty of detail to help you nail the install and configuration down.

BTW, if you want to enhance GD to handle more image formats and fonts you need to download them. See the Requirements area of the link above.

aragornking

6:53 pm on Oct 21, 2003 (gmt 0)

10+ Year Member



Thanks ecoopster. I uncommented php_gd2.dll module in the relevant php.ini and I get the following error (a few times) when I run phpinfo():

PHP Warning: gd: Unable to initialize module
Module compiled with module API=20010901, debug=0, thread-safety=1
PHP compiled with module API=20020429, debug=0, thread-safety=1
These options need to match

I don't know what's up. Perhaps mixing of modules from PHP 4.1.1 and 4.3.3 is a problem. I clearly don't have a GD module section in the phpinfo() output (I had GD OK with PHP 4.1.1).

Eugene

DrDoc

7:15 pm on Oct 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you put the gd dll file in the php directory?

aragornking

7:51 pm on Oct 21, 2003 (gmt 0)

10+ Year Member



Yes DrDOC, I have. I have it in about seven locations, trying to cover all bases.

Thanks,
Eugene

coopster

7:59 pm on Oct 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It only needs to be in one, the one you designated in the php.ini file:

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
.
.
.
; Directory in which the loadable extensions (modules) reside.
extension_dir = "c:\php"
.
.
.

aragornking

9:27 pm on Oct 21, 2003 (gmt 0)

10+ Year Member



Hello again. For what it is worth, I originally installed PHP, Apache, and MYSQL as a bundle under the umbrella of the "PHPTriad" package. Perhaps I need to clean everthing PHP that is related to these installs from my PC, and start over. Yet I seem to be so close.

On the other hand, I would have more control over compiling/configuring if headed back to linux (RH), which I shall do this weekend if I don't fix this problem.

Eugene

aragornking

3:39 am on Oct 22, 2003 (gmt 0)

10+ Year Member



Hello again. I figured I had reached the end of the line for now with trying to solve this problem, so I dusted off my RH Linux box which had PHP 4.22, etc, which was GD enabled. I had no problem straight off the bat getting my PHP/GD images to display.

The reason I undertook this monsense of trying to get PHP/GD/MySQL to work under Windows 2000, is that the latter is on my laptop and I could do the necessary programming in the proximity of humankind without retiring to the attic where my Linux/desktop is located (it being the case that I lost the logon PW for my laptop Linux operating system).

Thank you all for your help. I will continue to chase the Windows problem of enabling GD in PHP 4.3.3/gettting images to display. If successful, I will post my findings here.

Cheers,
Eugene

aragornking

3:29 pm on Nov 9, 2003 (gmt 0)

10+ Year Member



Hello. I just wanted to add that I resolved my problems with GD in my Win200 box by downloading the latest version of the GD2 driver. Thanks again for all the help.

aragornking

jebster

5:42 am on Nov 20, 2003 (gmt 0)

10+ Year Member



I am having the same problem you were. Could you tell me where you got this driver? Thanks :)