PHP Classes


Recommend this page to a friend!
  Classes of Symisc Systems  >  Pixlab NSFW PHP Image Classifier  >  >  Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: Pixlab NSFW PHP Image Classifier
Check if images have nudity with Pixlab NSFW API
Author: By
Last change:
Date: 3 years ago
Size: 1,931 bytes


Class file image Download

PHP NSFW Classifier

A single PHP Class to classify NSFW contents (i.e. Users image uploads) via the PixLab Machine Vision APIs -


PixLab PHP NSFW Classify Class works with PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, and HHVM.


To install PHP NSFW Class, simply:

$ composer require symisc/pixlab-php-nsfw

Or simply drop *pixlab.php* on your source tree and you're done!

Usage Example

require_once "pixlab.php";

# Target Image: Change to any link (Possibly adult) you want or switch to POST 
# if you want to upload your image directly. 
$img = '';

# Your PixLab key - Get one from
$key = 'My_Pixlab_Key';

# Blur an image based on its NSFW score
$pix = new Pixlab($key);
/Invoke NSFW/
if( !$pix->get('nsfw',['img' => $img]) ){
	echo $pix->get_error_message();
/Grab the NSFW score/
$score = $pix->json->score;
if( $score < 0.5 ){
	echo "No adult content were detected on this picture\n";
	echo "Censuring NSFW picture...\n";
	/Call blur with the highest possible radius and sigma/
	if( !$pix->get('blur',array('img' => $img,'rad' => 50,'sig' =>30)) ){
		echo $pix->get_error_message();
		echo "Censured Picture: ".$pix->json->link."\n";

PixLab Resources

PixLab Resources &amp; Sample Set. The Sample Set are practical usage, working code available in various programming languages intended to familiarize the reader with the PixLab API. For an introduction course, please refer to: * The PixLab API in 5 minutes or less. * List of API endpoints. * The PixLab API Reference Guide. * The PixLab Sample Set.

You?re welcome to copy/paste and run these examples to see the API in action.

For more information send a message to info at phpclasses dot org.