Something like this would be quite complex to create. I think the best place to start is to look up some open source online image editing software and make modifications to those to get the functionality you want. Something like this would probably suit most of your needs:
open-source-php-based-ajax-image-editor
pixidou-an-open-source-ajax-image-editor-php-and-yui-based/
I've actually not had much experience working on something like this, but maybe a user on the forum can help you out. Maybe you could try posting in the job board to see if anyone would be able to help you out.