Typically when I build out a new site, I do it on a real server hosted off-premises. I started building sites that way a long time ago, and it just stuck. Why? Out of convenience in showing the client, and probably because it was easier for me to push them live (back then, circa 2013). Now in 2021, much has changed. While I have a cloud server dedicated for new builds and development work, I decided I’d try development for this next new project locally on my Mac, using MAMP.
I’ve had MAMP PRO for a while, but never got the hang of it. But as I typically do, I persisted through and learned how it works. This new project is using a MAMP PRO with a hostname, https, Nginx, and MySQL 5 (because my version of MAMP does support MySQL 8 and I need to pay to update). I still can run Grunt on my Mac from terminal and do things pretty much the same as if I was developing on a cloud server like AWS Lightsail.
Post-Processing of Image Failed
Today I ran into the image roadblock that WordPress provided. An error message that states:
Post-processing of the image failed likely because the server is busy or does not have enough resources. Uploading a smaller image may help. Suggested maximum size is 2500 pixels.
And looks something like this:
Yea, my file was a few pixels bigger than the recommended 2500px (2560px wide to be exact). And it clocked in at 1.3 MB which is big for serving up on web, but not that big if you’re going to use an image optimization tool like EWWW.IO.
I started searching on Google and did everything everyone said to try, even though some of them didn’t seem to make sense:
- Increase php max_upload_size
- Increase php post_max_size
- Increase php memory_limit
- Increase php max_execution_time
- Increase php max_input_time
- Increase WP_MAX_MEMORY_LIMIT
- Disable the “big image size threshold“: add_filter( ‘big_image_size_threshold’, ‘__return_false’ ); — I thought this would surely do it, but it didn’t fix the problem
- Change PHP versions
But the one thing I didn’t do was the one thing I needed to do:
Increase NGINX client_max_body_size !!!!!!!!!!!!!
By default, in MAMP PRO, this is set to something like 1MB. It’s not even noted in the nginx.conf file.
In MAMP PRO, the global nginx settings (and PHP, etc) are located by going to File > Edit Template.
Open up the Nginx template, and go to around line 18. Add another line with the following setting:
client_max_body_size 10M;
You can set the value to whatever you want. You probably only need 5M or 10M. Most images bigger than that are just way too big as a starting point.
Save the template (I do a Command-S) but I think closing the editor will save it as well. Make sure your Nginx service restarts. then try uploading again.
It works!
The Nginx layer comes before PHP so that’s why the error appeared so quickly after trying to upload, and that’s why it failed. Make Nginx happy, and your troubles go away.
Satisfaction in Solving the Problem
You could say, “Nic, why not just knock down the image size in Photoshop first. You would have been done an hour ago.” And you would be right. I would have been done with my image uploads for this project.
But problems like this eat at my soul. They have to be explicable. And they usually are. It just comes down to how much patience you have. And how much you’re willing to get things right.
I figure there are more people like me out there who want to solve problems like these, and search the Internet for solutions. I genuinely hope I was able to help another soul get past such a silly default setting.
Happy Image Uploading!