From c59d58afc6073467f54f82dded2a123c18b58070 Mon Sep 17 00:00:00 2001 From: OElesin Date: Fri, 15 May 2015 10:01:21 +0100 Subject: [PATCH] Update alchemyapi.php --- alchemyapi.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/alchemyapi.php b/alchemyapi.php index bc734c8..5fae73f 100644 --- a/alchemyapi.php +++ b/alchemyapi.php @@ -101,6 +101,8 @@ public function AlchemyAPI() { $this->_ENDPOINTS['image']['url'] = '/url/URLGetImage'; $this->_ENDPOINTS['image_keywords']['url'] = '/url/URLGetRankedImageKeywords'; $this->_ENDPOINTS['image_keywords']['image'] = '/image/ImageGetRankedImageKeywords'; + $this->_ENDPOINTS['face_detection']['url'] = '/url/URLGetRankedImageFaceTags'; + $this->_ENDPOINTS['face_detection']['image'] = '/image/ImageGetRankedImageFaceTags'; $this->_ENDPOINTS['taxonomy']['url'] = '/url/URLGetRankedTaxonomy'; $this->_ENDPOINTS['taxonomy']['html'] = '/html/HTMLGetRankedTaxonomy'; $this->_ENDPOINTS['taxonomy']['text'] = '/text/TextGetRankedTaxonomy'; @@ -145,6 +147,38 @@ public function image_keywords($flavor, $image, $options) { return $this->analyzeImage($this->_ENDPOINTS['image_keywords'][$flavor], $options, $image); } } + + /** + * Returns tag for an image URL or image included in the body of the http request. + * For an overview, please refer to: http://www.alchemyapi.com/products/features/image-tagging/ + * For the docs, please refer to: http://www.alchemyapi.com/api/image-tagging/ + * + * INPUT: + * flavor -> which version of the call, i.e. url or image. + * image -> the image to analyze, either the url or image data. + * options -> various parameters that can be used to adjust how the API works, see below for more info on the available options. + * + * Available Options: + * imagePostMode -> (only applicable to image flavor) + * not-raw : pass an unencoded image file with "image=URI_ENCODED_DATA" + * raw : pass an unencoded image file using POST + * extractMode -> + * always-infer : (more CPU intensive, more accurate) + * trust-metadata : (less CPU intensive, less accurate) (default) + * only-metadata : (even less CPU intensive, less accurate) + * + * OUTPUT: + * The response, already converted from JSON to a PHP object. + */ + public function face_detection($flavor, $image, $options) { + //Make sure this request supports the flavor + if (!array_key_exists($flavor, $this->_ENDPOINTS['face_detection'])) { + return array('status'=>'ERROR', 'statusInfo'=>'Face detection for ' . $flavor . ' not available'); + } + //Add the image url to the options and analyze + $options[$flavor] = $image; + return $this->analyzeImage($this->_ENDPOINTS['face_detection'][$flavor], $options, $image); + } /**