Пример #1
0
        $files = recursive_listdir($dir);
        $storage->processCode($files);
        if ($least_empty) {
            topTenEmpty($storage->codes);
        }
        if ($top_lines) {
            topTenLines($storage->codes);
        }
        if ($least_comments) {
            topTenComments($storage->codes);
        }
        if ($changes) {
            printChanges($storage->codes);
        }
        if ($review) {
            $storage->printReview();
        }
        if ($authors) {
            $storage->userStats();
        }
        if ($virgin_only) {
            printVirgins($storage->codes);
        }
        if ($status) {
            printColors($storage->codes);
        }
        if ($userstats) {
            printUserStats($storage->codes);
        }
    }
}
Пример #2
0
$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 printColors($colors, $label)
{
    echo '<p> <strong>' . $label . ':</strong> </p>';
    echo '<ul style="margin:0;padding:0;margin-top:10px;list-style: none;">';
    foreach ($colors as $color) {
        echo '<li style="display:inline-block;text-align:center;padding: 10px 50px;background-color:' . $color->getHtmlCode() . '; color: #fff;"></li>';
    }
    echo '</ul>';
}
foreach ($categorization->getResults() as $categorizationResult) {
    echo '<img width="500" src="' . $categorizationResult->getImage() . '" />';
    echo '<p><strong>Category: </strong>' . $categorizationResult->getTopCategory()->getName() . '</p>';
}
foreach ($colors->getResults() as $colorExtractionResult) {
    echo '<p> <strong>Object Percentage: </strong>' . $colorExtractionResult->getObjectPercentage() . '</p>';
    printColors($colorExtractionResult->getDominantColors(), 'Dominant Colors');
    printColors($colorExtractionResult->getObjectColors(), 'Object Colors');
    printColors($colorExtractionResult->getBackgroundColors(), 'Background Colors');
}
if ($tags->getErrors()) {
    foreach ($response->getErrors() as $err) {
        echo 'Error: ' . $err->getMessage() . ', status code: ' . $err->getStatusCode();
    }
    exit;
}
foreach ($tags->getResults() as $taggingResult) {
    echo '<p>' . implode(', ', $taggingResult->getTagsLabels()) . '</p>';
}