You can override the default ImageMagick and/or GD driver as described here. Then you can add custom stuff as you like.
I’m doing this with my Focus plugin, too:
You still need to figure out how to convert the images. I found these to links, but didn’t check if it works:
http://www.imagemagick.org/discourse-server/viewtopic.php?t=24048#p103330