PHP code example of clickandmortar / rekognition-php

1. Go to this page and download the library: Download clickandmortar/rekognition-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

clickandmortar / rekognition-php example snippets




use ClickAndMortar\Rekognition\Service\DetectService;

ithubusercontent.com/ClickAndMortar/rekognition-php/master/img/tshirt.png';
$rekognitionImage = $detectService->detectFromUrl($url);
$minimumConfidence = 80;

print 'Labels:' . PHP_EOL;
foreach ($rekognitionImage->getLabels($minimumConfidence) as $label) {
    print $label;
}

print 'Texts:' . PHP_EOL;
foreach ($rekognitionImage->getTexts($minimumConfidence) as $text) {
    print $text;
}


$url = 'https://raw.githubusercontent.com/ClickAndMortar/rekognition-php/master/img/tshirt.png';
$rekognitionImage = $detectService->detectFromUrl($url);

$filename = 'img/tshirt.png';
$handle = fopen($filename, 'r');
$image = fread($handle, filesize($filename));
fclose($handle);

$rekognitionImage = $detectService->detect($image);

$filename = 'img/tshirt.png';
$handle = fopen($filename, 'r');
$image = fread($handle, filesize($filename));
fclose($handle);

$base64image = base64_encode($image);
$rekognitionImage = $detectService->detectFromBase64($base64image);

$detectService = new DetectService([
    'region' => 'eu-west-1',
    'version' => '2016-06-27',
]);
shell
composer 
shell
docker run --rm -it -e AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" -e AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" -v "$PWD":/app -w /app php:7.1-cli php main.php