在phpclasses.org上面偶然发现一个很有用的,由Bakr Alsharif开发的可以帮助开发者基于皮肤像素点来检测图片裸照的类文件.
它会分析在一张图片的不同部分使用的颜色,并决定其是否匹配人类皮肤颜色的色调.
作为分析的结果,他会返回一个反映图片包含裸露的可能性的分值.
此外,他还可以输出被分析的图片,上面对使用给定颜色的肤色的像素进行了标记.
当前它可以对PNG,GIF和JPEG图片进行分析.

HTML表单上传图片
<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>
<?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']);//获取图片的分值并将其放到一个$score变量中
/*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 is considered an adult image.*/
    if ($score >= 60) {
        echo "Image scored " . $score . "%, It seems that you have uploaded a nude picture.";
    /*If the image doesn't contain nudity*/    
    } else if ($score < 0) {
        echo "Congratulations, you have uploaded an non-nude image.";
    }
}?>