I tried it on my PC with wampserver (slightly different code - below)
The only way I could get ini_set() to fail was by using safe_mode = On in php.ini.
The user gets the message 2 file(s) of 2 could not be uploaded. For 2 file(s) the server had not enough memory to resize!
There is nothing in the PHP error log.
tfu.log contains
Code:
09.23.2009 10:53:16 - Trying to resize DSCF1785.JPG 3488x2616 Before: Memory needed 55796224 + 1223152 (in use) = 57019376 Limit:16M
09.23.2009 10:53:16 - After: Limit 16M
09.23.2009 10:53:16 - File DSCF1785.JPG cannot be processed because not enough memory is available! Needed: ~55796224. Available: 16777216
09.23.2009 10:53:17 - Trying to resize ox 109.JPG 2816x2112 Before: Memory needed 36732928 + 1223144 (in use) = 37956072 Limit:16M
09.23.2009 10:53:17 - After: Limit 16M
09.23.2009 10:53:17 - File ox 109.JPG cannot be processed because not enough memory is available! Needed: ~36732928. Available: 16777216
With safe_mode = Off the pictures are resized successfully.
tfu.log has
Code:
09.23.2009 10:49:32 - Trying to resize DSCF1074.JPG 3488x2616 Before: Memory needed 55796224 + 1223152 (in use) = 57019376 Limit:16M
09.23.2009 10:49:32 - After: Limit 57019376
09.23.2009 10:49:42 - Trying to resize ox 109.JPG 2816x2112 Before: Memory needed 36732928 + 1223272 (in use) = 37956200 Limit:16M
09.23.2009 10:49:42 - After: Limit 37956200
I notice that the memory limit reverts to 16M after the first file is processed.
Conclusion: If ini_set() fails, the program seems to operate as standard. If ini_set() works, it can resize bigger pictures. It seems to be a useful mod.
This is the corrected code I used
Code:
/* jb increase memory as needed */
$InUse=memory_get_usage();
// Check if we need to set it
if ($memory > return_kbytes(ini_get('memory_limit'))*1024 - $InUse)
{
debug('Trying to resize ' . $image_name . ' ' . $oldsize[0] . 'x' . $oldsize[1] . ' Before: Memory needed ' . $memory . ' + ' . $InUse . ' (in use) = ' . ($memory + $InUse) . ' Limit:' . ini_get('memory_limit'));
//Try to set it
ini_set('memory_limit',$memory + $InUse);
debug('After: Limit ' . ini_get('memory_limit'));
}