Well, you've got to keep in mind that a JPEG is 24 bits per pixel. Since you have a 21600*21600 pixel square, you know there are 466560000 pixels. That's 11197440000 bits total, leaving you with an excess of 11196748800 bits that you cannot allocate.
So, just increase the memory limit a ton. Also, you'll need to increase the timeout limit, as this will probably take ages.
What you could do (what I would do, at least), is write a small C binary and shove the image through that. C will give you more speed, which you'll want.
Check out gd's Web page for some more info on using gd in a C program.