Memory limit problems: High resolution images vs thumbnails generation

Memory limit problems: High resolution images vs thumbnails generation

by Jean-Philippe Gaudreau -
Number of replies: 0

Hi everyone,


We happen to have recurrent memory exhaustion problems in production when users try to upload high resolution images in many different areas in Moodle that generate a thumbnail using the GD library (Mostly through the file manager).

For example, a jpeg image like this one -> https://drive.google.com/file/d/0B0H8CbGn160eMHg3cGZrSmtzRTA/view with dimensions of 16,313 x 3,621 would take 236,277,492 bytes of image data to generate the thumbnail (4 bytes per pixel) because GD has to decompress the data to be able to use it.

Note: The problem apply to servers using the GD library bundled with PHP (Recommended) and not the one from the OS. See the following issue I created in the PHP bug tracker for more details: https://bugs.php.net/bug.php?id=71093


Actually the only way I see to resolve this problem without modifying the Moodle core code is to increase the PHP memory limit in the php.ini config which is overkill and leave the server more vulnerable. The other way would be to modify the functions that generate the thumbnails in "lib/gdlib.php" to raise the memory limit -> raise_memory_limit(MEMORY_EXTRA)


Is there anyone having the same problems in their Moodle instance? Do you think the idea of modifying the core to raise memory limit would be acceptable? Is there any other suggestions or recommandations?


Thanks for your feedbacks!

Average of ratings: -