Search code examples
iosobjective-cimage-processing

API to manipulate photo overlays


I'm making an iPad app and I have this image:

EGG!

I'd like offer users the option to replace the egg's face with a photo from their own library (assuming I have an egg with a blank space for the head). I was wondering if there was a suitable API for manipulating/overlaying photos or images I can plug in? Any advice much appreciated.


Solution

  • You'll want to look at the CoreImage libraries if you want to do basic image manipulations as you're describing.

    First you'll get an image from the users library - you'll present a UIImagePicker modally (in the simplest scenario). This will give you back the selected image.

    You'll then proceed to identify a face - CoreImage gives you a CIDetector, and this can be used to obtain a rect containing the face. You'll then grab an image, presumably, from just the rectangle around the face.

    Then you take the face image, and place it behind your masked egg.