This is happening during the file resize. It takes a lot of memory to load an image into the GD library and calculate how to make it smaller. Can you increase the memory_limit setting to 64M? That is your best option. The upload max filesize is not the issue. The memory_limit needs to be about 20x the maximum image file size that will be resized.