예제 #1
0
// Toon alle errors
error_reporting(E_ALL);
ini_set('display_errors', 1);
// De library
require_once "lib/Imagga.php";
// Config met daarin API key
require_once "config/config.php";
// De client, hiermee doe je verzoeken.
$client = new \Imagga\Imagga\Client($config['api_key'], $config['api_secret']);
// Hier komt de response in
$response = [];
// Alle API calls
// Haal de categorieen op.
$categorization = $client->categorization('http://playground.imagga.com/static/img/example_photos/parrot-620345_1280.jpg');
// Haal de kleuren op van de afbeelding
$colors = $client->colorExtraction('http://playground.imagga.com/static/img/example_photos/parrot-620345_1280.jpg');
// Haal de beschrijving op van de afbeelding
$tags = $client->tagging('http://playground.imagga.com/static/img/example_photos/parrot-620345_1280.jpg');
function getColors($colors)
{
    foreach ($colors as $color) {
        echo $color->getHtmlCode();
    }
}
$responseCategorization = [];
foreach ($categorization->getResults() as $categorizationResult) {
    foreach ($categorizationResult->getCategories() as $categoryResult) {
        $responseCategorization[] = $categoryResult->getName();
    }
}
$response["categorization"] = $responseCategorization;
예제 #2
0
ini_set('display_errors', 1);
// De library
require_once "lib/Imagga.php";
// Config met daarin API key
require_once "config/config.php";
// De client, hiermee doe je verzoeken.
$client = new \Imagga\Imagga\Client($config['api_key'], $config['api_secret']);
// Hier komt de response in
$response = [];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $imageUrl = $_POST['imageUrl'];
    // Alle API calls
    // Haal de categorieen op.
    $categorization = $client->categorization($imageUrl);
    // Haal de kleuren op van de afbeelding
    $colors = $client->colorExtraction($imageUrl);
    // Haal de beschrijving op van de afbeelding
    $tags = $client->tagging($imageUrl);
    function getColors($colors)
    {
        foreach ($colors as $color) {
            echo $color->getHtmlCode();
        }
    }
    $responseCategorization = [];
    foreach ($categorization->getResults() as $categorizationResult) {
        foreach ($categorizationResult->getCategories() as $categoryResult) {
            $responseCategorization[] = $categoryResult->getName();
        }
    }
    $response["categorization"] = $responseCategorization;