In my case, with a VPS managed with a cloud panel, I did the following:
1. Temporarily disabled the Cloudflare Proxy for the WordPress site.
2. Temporarily disabled the default WordPress image autoscaling on upload using the following filter:
add_filter( 'big_image_size_threshold', '__return_false' );
3. SSH-ed into VPS, installed the missing PHP extension called “ImageMagick” and reloaded PHP-FPM.
And the error disappeared, I successfully uploaded 6.6MB image-screenshot (2850×19720).