goterpsgo Posted May 10, 2012 Share Posted May 10, 2012 We recently migrated over to a new AMP platform that I built from source and now we can't dynamically generate images. It seems like GD is properly included into PHP (although I didn't know then I could do it using dynamic modules): My PHP configure is as follows: ================================================== './configure' '--prefix=/export/appl/pkgs/php/v5.3.9' '--with-apxs2=/export/appl/pkgs/httpd/latest/bin/apxs' '--with-mysql=/export/appl/pkgs/mysql/latest' '--with-mysqli=/export/appl/pkgs/mysql/latest/bin/mysql_config' '--with-gd=/export/appl/pkgs/libgd/latest' '--with-pear' '--with-png-dir=/export/appl/pkgs/libpng/latest' '--with-jpeg-dir=/export/appl/pkgs/jpeg/latest' '--with-curl=/export/appl/pkgs/curl/latest' '--with-freetype-dir=/export/appl/pkgs/freetype/latest' '--with-mhash=/export/appl/pkgs/mhash/latest' '--with-mcrypt=/export/appl/pkgs/libmcrypt/latest' '--enable-pcntl' '--enable-soap' '--enable-mbstring' '--with-zlib-dir=/export/appl/zlib/v1.2.5' '--with-ldap' ================================================== The GD section in phpinfo is as follows: ================================================== GD Support enabled GD Version 2.0 FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.4.6 GIF Read Support enabled GIF Create Support enabled JPEG Support enabled libJPEG Version unknown PNG Support enabled libPNG Version 1.5.5 WBMP Support enabled Directive Local Value Master Value gd.jpeg_ignore_warning 0 0 ================================================== I get broken image icons in IE and Chrome, and I get an "image cannot be displayed" msg in FF. I'd appreciate someone clubbing me with a cluestick. - Joe 18332_.php Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 10, 2012 Share Posted May 10, 2012 When you browse directly to the URL of the shapeimage0.php dynamic image file and do a 'view source' in your browser, what do you get? Quote Link to comment Share on other sites More sharing options...
Andy-H Posted May 10, 2012 Share Posted May 10, 2012 Your code uses short_open_tag (<?) which I think defaults to off in php 5.3 or greater, use <?php Quote Link to comment Share on other sites More sharing options...
goterpsgo Posted May 10, 2012 Author Share Posted May 10, 2012 When you browse directly to the URL of the shapeimage0.php dynamic image file and do a 'view source' in your browser, what do you get? It's completely blank. I forgot to mention that when I used the same file on a yum-managed platform, the image appears as designed. Quote Link to comment Share on other sites More sharing options...
xyph Posted May 10, 2012 Share Posted May 10, 2012 You should program on your development server with error reporting turned on! Quote Link to comment Share on other sites More sharing options...
Andy-H Posted May 10, 2012 Share Posted May 10, 2012 When you browse directly to the URL of the shapeimage0.php dynamic image file and do a 'view source' in your browser, what do you get? It's completely blank. I forgot to mention that when I used the same file on a yum-managed platform, the image appears as designed. That's it; ignore my post because I don't have a green badge under my name... Quote Link to comment Share on other sites More sharing options...
goterpsgo Posted May 11, 2012 Author Share Posted May 11, 2012 Your code uses short_open_tag (<?) which I think defaults to off in php 5.3 or greater, use <?php That didn't make a difference. Quote Link to comment Share on other sites More sharing options...
goterpsgo Posted May 11, 2012 Author Share Posted May 11, 2012 You should program on your development server with error reporting turned on! As a matter of practice this is good advice, but in this case I go no additional information from this setting. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2012 Share Posted May 11, 2012 Is the posted code all the relevant code in that file? There's a user function call in it that doesn't exist in the posted code, implying you are including a file into that code or there's more to the actual code that could be causing a fatal parse error. Also, temporarily comment out the content header statement (if php's output_buffering is on, you won't see any php produced error messages that are generated prior to the header statement.) Quote Link to comment Share on other sites More sharing options...
goterpsgo Posted May 11, 2012 Author Share Posted May 11, 2012 Is the posted code all the relevant code in that file? There's a user function call in it that doesn't exist in the posted code, implying you are including a file into that code or there's more to the actual code that could be causing a fatal parse error. Also, temporarily comment out the content header statement (if php's output_buffering is on, you won't see any php produced error messages that are generated prior to the header statement.) That function was my attempt to redirect STDERR to a file so I can see it; it didn't show anything of use. Here's the code I've been looking at: <?php error_reporting(E_ALL); ini_set("display_errors", 1); // $im = @ImageCreate(150, 150) or die("Could not create image"); $im = @ImageCreate(150, 150); $bg_color = ImageColorAllocate($im, 240, 240, 240); // $text_color = ImageColorAllocate($im, 0, 0, 0); // ImageRectangle($im, 40, 40, 140, 140, $text_color); // ImageString($im, 3, 5, 5, "Square", $text_color); // header("content-type: image/png"); ImagePng($im); ImageDestroy($im); ?> I commented out the header statement and also changed it to "text/plain" - it looks like there's absolutely no content being generated. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2012 Share Posted May 11, 2012 You need to get the @ error suppressor out of your code (forever - there's no need to ever put them in code. On a development system you want to see all php detected the errors, on a live server you want to log php detected errors.) Can you echo a string in that file and see the string when you browse directly to that file? Are the error_reporting/ini_set statements enabled on your server? Quote Link to comment Share on other sites More sharing options...
xyph Posted May 11, 2012 Share Posted May 11, 2012 Fatal errors are 'thrown' before any functions are executed, so turning on error reporting within the script can still lead you a blank page. You have to set these in your php.ini, and restart the server. Quote Link to comment Share on other sites More sharing options...
goterpsgo Posted May 11, 2012 Author Share Posted May 11, 2012 The pertinent values in my php.ini are as follows: error_reporting = E_ALL | E_STRICT display_errors = On When I echo text content after what was supposed to be image data, I get nothing but my test echo. Here's my code: <?php error_reporting(-1); ini_set('display_errors', 1); // $im = @ImageCreate(150, 150) or die("Could not create image"); $im = ImageCreate(150, 150); $bg_color = ImageColorAllocate($im, 240, 240, 240); // $text_color = ImageColorAllocate($im, 0, 0, 0); // ImageRectangle($im, 40, 40, 140, 140, $text_color); // ImageString($im, 3, 5, 5, "Square", $text_color); // header("content-type: image/png"); header("content-type: text/plain"); ImagePng($im); ImageDestroy($im); echo "foo"; ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2012 Share Posted May 11, 2012 How about echoing a non-existent variable to see if errors are actually being reported/displayed. Your content header text/plain causes a prompt to download the .php file on my server. As already suggested, comment out the header() statement, in case output buffing is turned on. Is there anything else that doesn't work as expected on this server? Quote Link to comment Share on other sites More sharing options...
goterpsgo Posted May 11, 2012 Author Share Posted May 11, 2012 The server/stack seems to behave itself otherwise. It's displaying errors properly... <?php error_reporting(-1); ini_set('display_errors', 1); // $im = @ImageCreate(150, 150) or die("Could not create image"); $im = ImageCreate(150, 150); $bg_color = ImageColorAllocate($im, 240, 240, 240); // $text_color = ImageColorAllocate($im, 0, 0, 0); // ImageRectangle($im, 40, 40, 140, 140, $text_color); // ImageString($im, 3, 5, 5, "Square", $text_color); // header("content-type: image/png"); // header("content-type: text/plain"); ImagePng($im); ImageDestroy($im); echo "foo"; echo $foo; ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2012 Share Posted May 11, 2012 Since there are no errors occurring at the gd function calls, either they are outputting something and it is getting eaten or they are not actually doing anything. How about setting the parameters in the ImageCreate() to an incorrect number of parameters to see if you can trigger an error at the ImageCreate() statement. What does the phpinfo output show for the the zlib.output_compression setting? You typically need to turn off compression when dynamically outputting images (though I would expect there to be some kind of output reaching the browser, even if this setting is on and with no content-type header.) Next, I would start examining the response data/headers/content that is actually being output to the browser, using a tool like firebug. Quote Link to comment Share on other sites More sharing options...
goterpsgo Posted May 11, 2012 Author Share Posted May 11, 2012 Finally getting something... <?php error_reporting(-1); ini_set('display_errors', 1); $im = ImageCreate(150, 150, 150); $bg_color = ImageColorAllocate($im, 240, 240, 240); ImagePng($im); ImageDestroy($im); ?> Warning: imagecreate() expects exactly 2 parameters, 3 given in /export/appl/pkgs/httpd/v2.2.21/htdocs/opensys/dsy_ops/dci/assets/Layout/shapeimage0.php on line 5 Warning: imagecolorallocate() expects parameter 1 to be resource, null given in /export/appl/pkgs/httpd/v2.2.21/htdocs/opensys/dsy_ops/dci/assets/Layout/shapeimage0.php on line 6 Warning: imagepng() expects parameter 1 to be resource, null given in /export/appl/pkgs/httpd/v2.2.21/htdocs/opensys/dsy_ops/dci/assets/Layout/shapeimage0.php on line 12 Warning: imagedestroy() expects parameter 1 to be resource, null given in /export/appl/pkgs/httpd/v2.2.21/htdocs/opensys/dsy_ops/dci/assets/Layout/shapeimage0.php on line 13 Directive Local Value Master Value zlib.output_compression Off Off When I remove the invalid configuration for ImageCreate, and use FB to look at the header responses, I get *nothing* for content. I wonder if PHP is actually OK and our culprit is actually GD. Quote Link to comment Share on other sites More sharing options...
xyph Posted May 11, 2012 Share Posted May 11, 2012 The issue is right at your first error. You've got one too many arguments in your imagecreate call. According to the manual, and your error, it only wants 2. Width and Height. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2012 Share Posted May 11, 2012 ^^^ That was due to a suggestion to try and trigger errors to see if the gd functions were doing anything. What were the content type/content length.. headers in firebug? You looking at the information does us no good in helping you find what the problem is if you don't share what you saw. I got the following when I tried your code - Cache-Control no-store, no-cache, must-revalidate, max-age=0 Connection Keep-Alive Content-Length 98 Content-Type image/png Date Fri, 11 May 2012 18:59:26 GMT Keep-Alive timeout=5, max=100 Pragma no-cache Server Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.10 X-Powered-By PHP/5.3.10 Quote Link to comment Share on other sites More sharing options...
goterpsgo Posted May 11, 2012 Author Share Posted May 11, 2012 I looked previously but I thought the server was returning nothing. I just found the response headers; I'll include everything just in case: Response Headers HTTP/1.1 200 OK Content-Encoding: gzip Content-Type: text/html Date: Fri, 11 May 2012 19:27:49 GMT P3P: CP="NON CUR OTPi OUR NOR UNI" x-old-content-length: 0 Transfer-Encoding: chunked X-Powered-By: PHP/5.3.9 Request Headers GET /dsy/dsy_ops/dci/assets/Layout/shapeimage0.php HTTP/1.1 Host: home2dev.xxx.xxx User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive Cookie: wta_trp2=12459F6A193BBF5B; PD-S-SESSION-ID=2_1_EU4SUkwIgyVU61XR3jZ81BLm7cEm-85kLM5pRV3w3xKcJs2b X-ClickOnceSupport: ( .NET CLR 3.5.30729; .NET4.0E) Cache-Control: max-age=0 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 12, 2012 Share Posted May 12, 2012 x-old-content-length: 0 I've never seen that before, but in general the x- headers indicate the response went through a proxy or forwarding of some kind ... Do you have some server based hotlink protection or similar that looks at the content-type in the response and perhaps forwards to a empty page when the http referrer doesn't match the site? Quote Link to comment Share on other sites More sharing options...
goterpsgo Posted May 14, 2012 Author Share Posted May 14, 2012 Yeah mgmt insists we use Tivoli Access Manager for SSO for all our apps. Here's the header for the non-TAM-modified content: Response Headers Date Mon, 14 May 2012 13:41:21 GMT Server Apache/2.2.21 (Unix) PHP/5.3.9 mod_perl/2.0.6 Perl/v5.14.2 x-powered-by PHP/5.3.9 Content-Length 0 Content-Type text/html Request Headers Host didsy11.xxx.xxx:8090 User-Agent Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection keep-alive Cookie pma_lang=en; pma_theme=original; pma_collation_connection=utf8_general_ci; wta_trp2=12459F6A193BBF5B; pma_navi_width=200; phpMyAdmin=a5nepdffqr00ug5kmto781rps5fl3me7 X-ClickOnceSupport ( .NET CLR 3.5.30729; .NET4.0E) I'm still returning squat for content. I'm wondering if my GD is somehow not installed correctly If not, I wonder how I can verify that. I saw there was a small tool called fly that could have done that, but it won't compile under Solaris 10. Quote Link to comment Share on other sites More sharing options...
goterpsgo Posted May 14, 2012 Author Share Posted May 14, 2012 I was going through the blurbs from the gd site (http://www.boutell.com/gd/) and I saw this: If you are anything other than C programmer gd is probably included with your system or available with a single package manager command. If you're compiling stuff, you're doin' it wrong. php 4.3.x is available, and it includes a version of gd as "standard equipment." php_gd2.dll is included in a standard PHP installation for Windows, it's just not enabled by default. So I wonder if (aside from compiling from source) I did it all wrong and didn't need to use a reference to an external GD library for compiling PHP? Quote Link to comment Share on other sites More sharing options...
goterpsgo Posted May 14, 2012 Author Share Posted May 14, 2012 OK I got it!!! Someone might say it's a matter of not reading instructions but it's so obscure... It turns out I needed to use the GD that's already included in the PHP source code (I didn't think it was included). I'd just use --with-gd=shared and not provide an explicit path to a GD install. (Then I'd include "extension=gd.so" in php.ini to use that module.) I hope my suffering helps others... - Joe Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.