Forum
Perch Gallery - Large Image Upload
When large images are uploaded to the gallery and gd is being used to resize them, the script can run out of memory and ends abruptly without giving any feedback to the user. This can be confusing.
Would it be possible to add a basic test prior to calling imagecreatefromjpeg to get a rough estimate of the memory that is likely to be used and if it exceeds what is available, ending the script gracefully with feedback to the user?
It's something we've looked into in the past, but it's quite hard to do. One of the common reasons for memory exhaustion is not hitting the configured limit, but running out of memory below the configured limit. In those cases we have a reasonable expectation that the process will succeed, but then the script exits before we can gracefully handle it.
Hi,
Yes, there doesn't seem to be a full-proof method for this, which is frustrating. I have used code in the past which takes a reasonable stab at getting the available memory and working out how much the image will consume. It does catch a number of cases but has never been 100%.
If the calculations were to err on the side of caution and we accepted that it wouldn't be perfect, do you think that some sort of implementation would, on balance, be better? That would get my personal vote, but I appreciate that you have a much wider picture to consider.
It's something we will keep revisiting. We have a big Assets update planned for a future release, so we'll certainly look at it again.
I appreciate that, thanks.