0
私はcloudinary顔検出APIをこのように使用しています:PHP顔検出:cloudinary API面数
require 'cloudinary/Cloudinary.php';
require 'cloudinary/Uploader.php';
require 'cloudinary/Api.php';
\Cloudinary::config(array(
"cloud_name" => "xxxxxxxxxxxx",
"api_key" => "9999999999999",
"api_secret" => "xxxxxxxxxxxxx"
));
$img = 'guy.jpg';
$imgid = time() . 'guy';
\Cloudinary\Uploader::upload($img, array("public_id" => $imgid));
$url = 'http://res.cloudinary.com/xxxxxx/image/upload/c_fill,g_face,h_500,w_375/' . $imgid . '.jpg';
file_put_contents('cropped' . $img, file_get_contents($url));
しかし、私も必要なのである。
\Cloudinary\Uploader::upload($img, array("public_id" => $imgid));
// what I need >>>
if('face_count != 1')
{
exit;
}
// <<< what I need
$url = 'http://res.cloudinary.com/xxxxxx/image/upload/c_fill,g_face,h_500,w_375/' . $imgid . '.jpg';
file_put_contents('cropped' . $img, file_get_contents($url));
私はどのように理解していませんここではドキュメントからface_countを使用する:答えNadavためhttp://cloudinary.com/documentation/image_transformations#specifying_conditions
これは、(face-count!= 1)の場合に達成したいことによって異なります。一般的に、このようなURLは次のようになります。https:// res.cloudinary.com/xxxxxx/image/upload/if_fc_eq_1/c_fill,g_face,h_500,w_375/if_else/some-fallback-transformation/if_end/sample.jpg とにかく、イメージを配信する必要があります。そうでない場合は、エラー(破損イメージ)が発生します。 –