I'm getting an HTTP Error
message when uploading a big jpg file (about 30 - 40MB) and I can see 500 Internal Server Error
response in the Chrome dev tools network tab returned by the async-upload.php
.
The error appears after the file is uploaded. I can see the file in the wp-content/uploads
directory, so the problem is not related to the uploading process.
I suppose that the problem is related to images resizing process that happens after the file is uploaded. I tried to rebuild thumbnails manually (using several regenerate thumbnails plugins) to prove that the problem is related to the resizing process. All of them failed to resize a large image.
Things I did before posting this question:
- I've increased the memory limit to 256MB in the
php.ini
file (memory_limit = 256M
) - set
post_max_size = 256M
- Set up a fresh WP instance. No plugins, default theme.
- Tested on a different machine (on VPS, same PHP settings)
I've turned off
mod_security
settings:<IfModule mod_security.c> SecFilterEngine Off SecFilterScanPOST Off </IfModule>
I've also tried to change the default image library:
add_filter('wp_image_editors', function () { return ['WP_Image_Editor_GD', 'WP_Image_Editor_Imagick']; });
UPDATE:
I've just realised that the filter I've applied didn't do anything. I have check the WP source code, and found that default value for this filter is: ['WP_Image_Editor_Imagick', 'WP_Image_Editor_GD']
. I've changed the order, but I didn't have Image Magic library installed, so WordPress has been using GD library anyway.
So I have installed the Image Magic PHP extension to give it try. I've also removed the filter because it's default value works for me.
Replacing GD library with Image Magic solved the problem., but I'm still curious why GD library can't handle such big images. Is there any way to solve this issue in a different way? I don't want to be dependent on third party libraries. I would rather use a standard PHP setup (in case of deploying the site on a shared hosting where it's not possible to install custom PHP extensions).