you are correct, the code is incomplete.
I've update my post above.
as of the error message, your server doesn't allow manipulate such large images, you'll need either ask your host administrator to increase the memory limit, or switch to ImageMagick or NetPBM (or change the host)