Got one here https://github.com/owncloud/contacts/blob/master/lib/imageresponse.php