Finn Rudolph




RSSShoutbox RSS Feed

29
Dec
2009

19:12 - Alex

Hey Finn. First of all, congratulations and thanks for the great job you've done developing "ImageFlow". I just got a little improvement suggestion concerning the ImageFlow memory management (or rather the memory management of your PHP reflect scripts). Problem description: picture a situation where one is not allowed (or just don't know how) to manually re-configure the php.ini settings (e.g. on a server of a free webhoster or on a local webserver) to be able to proccess larger images (i.e. usual digicam-images). If the memory limit variable in the php.ini is very small your reflection script won't be able to do its job. ImageFlow (thus the reflect script) will just show empty boxes including the typical ... image - nor an error neighter a warning (that the requested memory the script is trying to use is too large) will be thrown. That's why you should add a couple of lines to your source code to improve that. Here's the code I suggest to use (this code is trying to dynamically increase the php memory limit during the scriprt runtime): // Read the memory limit variable (a string) from the php.ini file into $mem_limit, cut the letter off // the string and convert the rest of the string into an integer (int) value (int) $mem_limit = str_replace(array('b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'), '', strtolower(@ini_get('memory_limit'))); // Check whether the memory limit is too low (if so lets try to change that) if((isset($mem_limit)) && (!empty($mem_limit)) && ($mem_limit < 1024)) { // Try to reset the php ini value for the scripts memory limit (try to set it to 1024Mb) for($i=1024; $i>=(int)$mem_limit; $i-=2) { if(@ini_set('memory_limit', ((string)$i.'M')) == false) { } else { $i=0; } } } Just add it at the very beginning of reflect2.php and reflect3.php and everything will be fine :o) Kind regards, Alex

2012 | 2011 | 2010 | 2009 | 2008 | 2007