class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
Could you send me such an image, or send me a link to it if it is online?
In fact, I think the image, when manipulated by GD, is converted to a bitmap in memory. So 4000x4000 pixels requires a lot of memory. The fact that the source image is JPEG does not change that.
In fact, I think the image, when manipulated by GD, is converted to a bitmap in memory. So 4000x4000 pixels requires a lot of memory. The fact that the source image is JPEG does not change that.
Send me the image, I will do some tests.