Mike,
Have a look at: this to get you going.
Look at the javasource of Image-Resize module in the app-store Maybe you can re-use this code for your specific purposes.