KakkArlak Posted June 5, 2010 Share Posted June 5, 2010 So, got this new, very nice Quad Core server, for production. I've set up quite a few LAMP + Postfix/sendmail + Subversion servers, but this time the thing screwed me over. Only difference with this one is, I configured the network myself, and it's not the server edition. ( configured the network myself, because it's not a bought VPS / dedicated server overseas | and it's not the server edition, so that less technical people at the office can also understand it, in their own way. Not that I'd let them play around and screw shit up anyways ) So, the problem is.. Apache | PHP is installed, working fine. Easy enough. Mysql is on another server, so that's not a problem. The problem is, some of the sites uses PHPthumb to generate thumbnails and whatever. But, on this server, the resulting image is a 32x32 image, that says "no GD". If I do a phpInfo page, GD v2 + AND imagick is installed and enabled. Which is what PHPthumb needs. So what have I forgotten? Permissions on the website files/folders is 755, owner and group is the web server. So that shouldn't be a problem. Funny thing though, if I do a straight phpthumb call in the browser, it works. No problems. But the way in which generating was written on this particular site, gives me that crap. And it worked before, so I don't necessarily want to go and check and change all the websites. In short, the script saved the original uploaded image in a temp directory, does a phpthumb call to resize it on that temp image, and then does a file_get_contents of that resulting image, and a file_put_contents of that to the place where it's being saved. Then unlinks the temp image. In that scenario, the temp image is fine, no problems, but the after that file_put_contents the image is "no GD". From phpInfo() : gd GD Support enabled GD Version 2.0 or higher FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.3.9 T1Lib Support enabled GIF Read Support enabled GIF Create Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled ---- Any ideas? Show me where I'm being stupid! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 5, 2010 Share Posted June 5, 2010 You would need to troubleshoot what the script is dong and under what conditions it uses the "no GD" image instead of the actual one. Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 5, 2010 Author Share Posted June 5, 2010 Well, I know at which part it fails. I can show you the script. Funy thing is, this was working on our previous server though. But that crashed, so I can't compare the configuration. But basically that was probably way old, in terms of php. This one obviously has everything on the latest version. if (!file_put_contents('/var/www/websites/luckypet/website/media/images/products/temp/'.$origFile.'.jpg', file_get_contents($photo['tmp_name']))) { $return['error'][] = 'Could not save profile img'; } $img_a = "http://".$_SERVER['HTTP_HOST']."/library/classes/phpthumb/phpthumb.php?src=/var/www/websites/luckypet/website/media/images/products/temp/".$origFile.'.jpg&w=200&h=150&q=75&aoe=1&zc=1'; echo '<img src="'.$img_a.'" />'; // (this works fine) $img_b = file_get_contents($img_a); file_put_contents('/var/www/websites/luckypet/website/media/images/products/image_200.jpg',$img_b); echo '<img src="http://luckypet.dev/media/images/products/image_'.$sizes['medium']['width'].'.jpg" />'; // this shows "no GD" Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 5, 2010 Share Posted June 5, 2010 If that't the correct code, where is $sizes['medium']['width'] set to either the correct value or the value that results in the "no GD" image being used? Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 5, 2010 Author Share Posted June 5, 2010 Sorry, I tried to remove all the variables from the code, to avoid questions about the variables, because I have double checked the values. This same code worked on the previous server before it crashed. That variable's value is '200'. I have checked, the file's "date modified" date changes when I run this, so paths and whatever should be correct? ALthough the resulting image (image_200.jpg) is 32x32 and shows "no GD" Another thing, The above code is executed inside a function, in a file that is included in the original page. If I do the same thing on a standalone file it works fine, e.g. $file = file_get_contents("http://".$_SERVER['HTTP_HOST']."/library/classes/phpthumb/phpthumb.php?src=/media/Rugby_14May_056.jpg&w=230&h=300&aoe=1&zc=1"); unlink('/var/www/websites/luckypet/website/media/images/products/file.jpg'); file_put_contents('/var/www/websites/luckypet/website/media/images/products/file.jpg',$file); unlink('/var/www/websites/luckypet/website/media/images/products/image.jpg'); file_put_contents('/var/www/websites/luckypet/website/media/images/products/image.jpg',file_get_contents('/var/www/websites/luckypet/website/media/image/products/file.jpg')); echo '<img src="http://luckypet.dev/media/images/products/image.jpg />'; Is there some kind of php setting I'm missing? I've read something about register_globals should be On, so I turned it on... but that didn't make it work.. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 5, 2010 Share Posted June 5, 2010 I tried to remove all the variables from the code I'm going to guess that you removed code as well. It is simply impossible for someone to help you with what your code is doing without seeing the actual code responsible for the symptoms. The conditions under which your code decides to use the 'no GD' image instead of the actual image tells you what value or function call is failing and tells you where to look to find the problem. Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 5, 2010 Author Share Posted June 5, 2010 I tried to remove all the variables from the code I'm going to guess that you removed code as well. It is simply impossible for someone to help you with what your code is doing without seeing the actual code responsible for the symptoms. The conditions under which your code decides to use the 'no GD' image instead of the actual image tells you what value or function call is failing and tells you where to look to find the problem. I didn't remove any code.. I attached the full function and how it's used on the page (at the top ) [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 6, 2010 Author Share Posted June 6, 2010 Anything? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 6, 2010 Share Posted June 6, 2010 I'm going to guess that the image you see in front of you is a custom error image that someone has created and has setup in your phpthumb configuration file as - $PHPTHUMB_CONFIG['error_message_image_default'] = ''; If so, you need to change your phpthumb configuration so that it outputs the actual errors it detects instead of the default error image. Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 6, 2010 Author Share Posted June 6, 2010 I'm going to guess that the image you see in front of you is a custom error image that someone has created and has setup in your phpthumb configuration file as - $PHPTHUMB_CONFIG['error_message_image_default'] = ''; If so, you need to change your phpthumb configuration so that it outputs the actual errors it detects instead of the default error image. Yes, it is set to '' ... how/what do I change to see the specific error? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 6, 2010 Share Posted June 6, 2010 Yes, it is set to '' The line I posted is just the line setting the default error image. If your's is set to an empty string than that setting is not where the image is coming from. What exactly is the image you see? What does it say? What is the path where it is at? The following settings (defaults shown) determine if or what is output when an error occurs - $PHPTHUMB_CONFIG['disable_debug'] = false; // prevent phpThumb from displaying any information about your system. If true, phpThumbDebug and error messages will be disabled $PHPTHUMB_CONFIG['error_image_width'] = 400; // default width for error images $PHPTHUMB_CONFIG['error_image_height'] = 100; // default height for error images $PHPTHUMB_CONFIG['error_message_image_default'] = ''; // Set this to the name of a generic error image (e.g. '/images/error.png') that you want displayed in place of any error message that may occur. This setting is overridden by the 'err' parameter, which does the same thing. $PHPTHUMB_CONFIG['error_bgcolor'] = 'CCCCFF'; // background color of error message images $PHPTHUMB_CONFIG['error_textcolor'] = 'FF0000'; // color of text in error messages $PHPTHUMB_CONFIG['error_fontsize'] = 1; // size of text in error messages, from 1 (smallest) to 5 (largest) $PHPTHUMB_CONFIG['error_die_on_error'] = true; // die with error message on any fatal error (recommended with standalone phpThumb.php) $PHPTHUMB_CONFIG['error_silent_die_on_error'] = false; // simply die with no output of any kind on fatal errors (not recommended) $PHPTHUMB_CONFIG['error_die_on_source_failure'] = true; // die with error message if source image cannot be processed by phpThumb() (usually because source image is corrupt in some way). If false the source image will be passed through unprocessed, if true (default) an error message will be displayed. Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 6, 2010 Author Share Posted June 6, 2010 The image location is where my outputted file is suppose to be http://luckypet.dev/media/images/products/2/image_150.jpg And I attached that image.. I changed the loop in the function to this: foreach ($sizes as $key => $size) { /* small-medium ===================================*/ $name = $key; $width = $size['width']; $height = $size['height']; $img_src = "http://".$_SERVER['HTTP_HOST']."/library/classes/phpthumb/phpthumb.php"."?src=".$temp_path."/".$origFile.".jpg&w=".$width."&h=".$height.$size['paramaters']; $img = file_get_contents($img_src); echo '<img src="'.$img_src.'" />'; $fileName[$key] = '/image_'.$width.'.jpg'; /* save new image */ if (!file_put_contents($save_path.$fileName[$key],$img)) { $return['error'][] = 'Could not save : '.$save_path.$fileName[$key]; } else { $return['thumbsPaths'][$name] = $save_path.$fileName[$key]; } echo '<img src="http://'.$_SERVER['HTTP_HOST'].'/media/images/products/2'.$fileName[$key].'" />'; /* end medium ===============================*/ } exit(); And I attached a screenshot of that output. As you can see, the straight phpthumb call works and shows the image, but when I try to "file_get_contents" it... it fails! Really appreciate the help so far. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 6, 2010 Author Share Posted June 6, 2010 and then, on the same server, I do this: $img = "http://edge.dev/library/classes/phpthumb/phpthumb.php?src=/media/Rugby_14May_056.jpg&w=230&h=300&aoe=1&zc=1"; $new = file_get_contents($img); file_put_contents('new.jpg',$new); echo file_get_contents('new.jpg'); echo '<img src="'.$img.'" />'; echo '<img src="new.jpg" />'; And both images displays correctly... WIERD! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 6, 2010 Share Posted June 6, 2010 Are both your full code and the short test script in the same folder on the server? Based on URL's you have been posting, you likely have two different servers with possibly two different versions of phpthumb or two different versions of GD. Your short test code is using edge.dev while your full script is using luckypet.dev There is a phpThumb.demo.check.php file in the demo folder. What results do you get for the GD features: JPG/JPEG support? Red/green? Probably related to this, I have found that the current version of gd_info() returns a different value for "JPG Support" than what phpthumb is using (my phpThumb.demo.check.php says there is no JPEG support, but there is.) Code in the phpthumb class that is checking for $gd_info['JPG Support'] needs to be changed to $gd_info['JPEG Support'] I also suspect that your $PHPTHUMB_CONFIG['error_image_width'] and $PHPTHUMB_CONFIG['error_image_height'] have been set to 32 x 32 and you are not seeing all the error message. Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 6, 2010 Author Share Posted June 6, 2010 Sorry for the confusion, but luckypet.dev and edge.dev is both on the same server, just different "websites" with different Virtualhosts and whatever. phpThumb files are different though. I did not think that there would be differences in there... Obviously I assumed wrongly. ahhh! Thank you. I think we just made a big'ish breakthrough to find the problem. That "demo check" page revealed quite a few stuff. I didn't know about that... As for the error image ,the default size is 400 by 300 or something big'ish so it's not that. Critical stuff I noticed on the check page : ImageMagick isn't installed, although I have php5-imagick installed on the server? What else do I need? Although, how does the initial phpthumb call work ?? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 6, 2010 Share Posted June 6, 2010 Additional info to my post above (I'll address your last post separately) - If you are doing this on php 5.3.0 or higher, phpthumb is using one or more functions (ereg() ...) that have been depreciated and produce 'depreciated' error messages. phpThumb.php sets error_reporting/display_errors full on and these depreciated messages are being output and interfere with the output of an image. I'll guess that you have been using two different systems, but one is a low enough php version that the depreciated errors are not being generated. You can probably (assuming output buffering is off) check for these errors on the system where the code does not work by browsing directly to the URL you are using file_get_contents() on and doing a 'view source' in your browser. If the problem is only on a php5.3.x system, aside from updating the code to use current php functions, you can prevent phpThumb.php from causing php errors to be displayed by changing the following line - ini_set('display_errors', '1'); to this - ini_set('display_errors', '0'); Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 6, 2010 Author Share Posted June 6, 2010 I now installed "ImageMagick" .. and the check page says (in orange) "convert" n/a .... GD says, in yellow, "2.0 or higher" EDIT: only saw your last post now, will check that. EDIT2: btw, : PHP Version => 5.2.10-2ubuntu6.4 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 6, 2010 Share Posted June 6, 2010 Since they are different web sites, they could be using different php settings and could even be using different versions of php. ImageMagick isn't required. It's used if GD is not installed or if you are using features not supported in GD or if you are using ImageMagick specific features. But since it does not show up in the demo check page, there is something wrong with the installation. Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 6, 2010 Author Share Posted June 6, 2010 Since they are different web sites, they could be using different php settings and could even be using different versions of php. It's different websites, but both are run on the same apache server, using the same php version and settings.. I Set the error thing to 0 within phpthumb.php, and still nothing PS. I also downloaded the latest phpThumb version just now, so all settings are on default. No funny stuff that came from elsewhere... Only thing changed in phpthumb at the moment is the JPEG support thing, and the error thing Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 6, 2010 Author Share Posted June 6, 2010 But since it does not show up in the demo check page, there is something wrong with the installation. Any idea what I did wrong? I simply did apt-get install imagemagick ... Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 6, 2010 Share Posted June 6, 2010 Actually, I just installed ImageMagick to test this. There is a configuration line in the phpthumb configuration file that points to the ImageMagick 'convert' executable (at least on Windows.) The ImageMagick version information that it provides is different than what phpthumb expects, though I don't know if this affects the phpthumb script beyond what is displayed on the demo check page. Quote Link to comment Share on other sites More sharing options...
sspoke Posted June 6, 2010 Share Posted June 6, 2010 extension=php_gd2.dll extension=php_gd.dll @ php.ini if that fails your script is garbage Quote Link to comment Share on other sites More sharing options...
KakkArlak Posted June 7, 2010 Author Share Posted June 7, 2010 Thanks so so much for all the help PFMaBiSmAd. I really appreciate it. In the end, there wasn't actually a problem. Our DNS server was pointing to the wrong thing for luckypet.dev. I noticed just now when I was transferring other websites. Sorry for being such an idiot! 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.