That should be possible, using the ImageCopy function (part of PHP's GD extension).
Before you start using the ImageCopy()-function, you should get familiar with more simple image procedures. (Start by creating a 20x20 red box, for example - just to learn how the system works.)
The down-side:
The software which PHP currently uses for image manipulations ("GD") only handles 256 colors. This makes it close to useless if you work with JPEG images (and some PNG images).
If you need to work with more than 256 colors, then you need to use an external software like ImageMagick (unix only).
Hopefully, it will soon be easy to work with the "imlib2" software package directly from PHP.