PHP code example of dneural / php-nullnude

1. Go to this page and download the library: Download dneural/php-nullnude 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/ */

    

dneural / php-nullnude example snippets



ullNude\NullNude;

// Information about your API access.
$config = [
    'api_key'    => 'YOUR_API_KEY',
    'api_secret' => 'YOUR_API_SECRET'
];

// Initialize the NullNude client.
$nullNude = new NullNude($config);

// Image can be either a local path or an external url.
$image = "https://nullnude.com/wp-content/uploads/2016/01/vintage_porn_2.jpg";

// Check if the image has nuidty in it.
$nudityResource = $nullNude->checkNudity($image);
if ( $nudityResource->hasNudity() ) {
    // Take action based on your confidence preference.
    echo 'Image nudity confidence: ' . 
         $nudityResource->getNudityConfidence();
}

// Get the array of regions of interest within the image.
$roiResource = $nullNude->getRoi($image);
echo "<pre>";
print_r($roiResource->getRoi());
echo "</pre>";

// Check if the image has been moderated, moderate.json 
// applies the filter only if there was nudity present.
$moderateResource = $nullNude->moderate($image);
if ( $moderateResource->isModerated() ) {
    // Download and save the moderated image.
    echo 'Moderated image url: ' . 
         $moderateResource->getModeratedUrl();
}

json
{
    "neural/php-nullnude": "dev-master"
    }
}