PHP Classes
elePHPant
Icontem

Pixlab NSFW PHP Image Classifier: Check if images have nudity with Pixlab NSFW API

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-08-19 (9 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 105 This week: 1All time: 9,104 This week: 382Up
Version License PHP version Categories
pixlab-php-nsfw 1.0.0Custom (specified...5PHP 5, Graphics, Web services, Artifi...
Description Author

This package can check if images have nudity with Pixlab NSFW API.

It can take the URL of the location of a given image file and send a HTTP request to Pixlab NSFW (Not Suitable For Work) Web service API.

This Web service uses machine vision analysis methods to determine if the uploaded image may contain adult content and returns a number that represents a score of the degree of probability that the image may contain people in appearing nude.

It may also return the image blurred in the areas that contain nudity.

Innovation Award
PHP Programming Innovation award nominee
August 2018
Number 9
Many sites allow users to upload picture files to be published. This may be problematic if the site is not able to determine if a picture contains unsuitable content for exhibiting to the public.

This package provides a solution to avoid that pictures with nudity be published.

It uses the Pixlab NSFW API to determine if a picture has those problems, as well can blur images showing parts of nude bodies.

Manuel Lemos
Name: Symisc Systems <contact>
Classes: 2 packages by
Country: South Africa South Africa
Age: ???
All time rank: 373921 in South Africa South Africa
Week rank: 191 Up2 in South Africa South Africa Up
Innovation award
Innovation award
Nominee: 2x

Details

PHP NSFW Classifier

A single PHP Class to classify NSFW contents (i.e. Users image uploads) via the PixLab Machine Vision APIs - https://pixlab.io/cmd?id=nsfw

Requirements

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

Install

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

<?php
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 = 'https://i.redd.it/oetdn9wc13by.jpg';

# Your PixLab key - Get one from https://pixlab.io/dashboard
$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();
	die;
}
/Grab the NSFW score/
$score = $pix->json->score;
if( $score < 0.5 ){
	echo "No adult content were detected on this picture\n";
}else{
	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();
	}else{
		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.

  Files folder image Files  
File Role Description
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file nsfw_classify_example.php Example Example script
Plain text file pixlab.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:105
This week:1
All time:9,104
This week:382Up