dneural / php-nullnude
NullNude client for PHP
Requires
- php: >=5.4.0
- ext-curl: *
Requires (Dev)
- phpdocumentor/phpdocumentor: 2.*
- phpunit/phpunit: 3.7.14
This package is not auto-updated.
Last update: 2025-05-16 20:20:46 UTC
README
This PHP SDK is a wrapper for our NullNude API, a nudity detection/moderation service.
Use the NullNude API to instantly moderate adult content in user-submitted photos.
Installation
The NullNude PHP SDK can be installed with Composer.
php composer.phar require dneural/php-nullnude dev-master
or by adding the repository to your composer.json by hand:
{ "require": { "dneural/php-nullnude": "dev-master" } }
and then installing the SDK by running:
php composer.phar install
Check the examples
directory to learn how to use the SDK effectivly.
Authenticate to NullNude API
Each application that uses NullNude API needs to be authenticated. For that reason you will have to register an account with us. It is a very easy process and can be done at this address: https://nullnude.com/register
Write down your api_key and api_secret and you're ready to go.
Checking for nudity, regions of interest.
Checking if images contain nudity in them is easy. Provide an URL or a local file path of the image you would like checked to one of the few methods that our API supports.
<?php require __DIR__ . '/vendor/autoload.php'; use NullNude\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(); }
Consider checking the examples
directory for more real life usage examples.
How to build the documentation?
Documentation is based on phpdocumentor. To install it clone the php-nullnude project:
git clone https://github.com/dneural/php-nullnude.git
cd php-nullnude
php composer.phar install
To generate documentation in the ./docs/nullnude directory run:
./vendor/bin/phpdoc -d ./src -t ./docs/nullnude
How to run tests?
Tests are based on phpunit. To run them clone the php-nullnude project:
git clone https://github.com/dneural/php-nullnude.git
cd php-nullnude
php composer.phar install
and run this command:
./vendor/bin/phpunit --coverage-text
License
The SDK code is released under a MIT style license, which means that it should
be easy to integrate it in your applications.
Check the LICENSE file for more information.