PHP automatically identify users upload indecent pictures concurrent mailbox prompts

Source: Internet
Author: User


Download: Http://www.rrpowered.com/code/RRPowered-NudityFilter.zip


I stumbled across a very useful phpclasses.org, developed by Bakr Alsharif, that could help developers detect pictures based on their skin pixel points.
It analyzes the colors used in different parts of a picture and determines whether they match the color tones of the human skin.
As a result of the analysis, he will return a reflection of the picture contains the possibility of XX LU score.
In addition, he can output the parsed picture, which marks the pixels that use the color of the given colour.
It is currently available to analyze png,gif and JPEG images.

Php
The following shows how to use this PHP class.
Let's start with the Include filter, nf.php file.

The code is as follows Copy Code

Include (' nf.php ');

Next, create a new class called ImageFilter, and then put it in a variable called $filter.

The code is as follows Copy Code
$filter = new ImageFilter;

Gets the score of the picture and places it in a $score variable.

The code is as follows Copy Code


$score = $filter-> getscore ($_files[' img '] [' tmp_name ']);

If the picture score is greater than or equal to 60%, show an (alert) message.

The code is as follows Copy Code

if ($score >= 60) {
/*message*/
}

Here are all the PHP code:

The code is as follows Copy Code
<?php
/*include the nudity Filter file*/
Include (' nf.php ');
/*create a new class called $filter * *
$filter = new ImageFilter;
/*get the score of the image*/
$score = $filter-> getscore ($_files[' img '] [' tmp_name ']);
/*if the $score variable is set*/
if (Isset ($score)) {
/*if The image contains nudity, display image score and message. Score value if more than 60%, it are considered an adult image.*/
if ($score >= 60) {
echo "Image scored". $score. "%, It seems that you have uploaded a nude the picture."
/*if the image doesn ' t contain nudity*/
else if ($score < 0) {
echo "Congratulations, you have uploaded a non-nude image."
}
}
?>

Markup language

We can upload images using a basic HTML form.

The code is as follows Copy Code

<form method= "POST" enctype= "Multipart/form-data" action= "<?php echo $SERVER [' php_self '];? > ">
Upload Image:
<input type= "file" Name= "img" id= "img"/>
<input type= "Submit" value= "Sumit Image"/>
</form>

Summarize

Please remember that PHP is not able to detect all the pictures, so it is not completely believable. I hope you think it's useful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.