free hit counter

Prevent uploads nude or adult images using php

Prevent uploads nude or adult images using php

Prevent uploads nude or adult images using php

 

Image Nudity Filter can be used to determine whether an image may contain nudity. It analyses the colors used in different sections of an image to determine whether those colors match the human skin color tones.

As result of the analysis it returns a score value that reflects the probability of the image to contain nudity. Additionally, it can output a the analysed image marking the pixels with color skin tones with a given color.

Currently Image Nudity Filter can analyze images in the PNG, GIF and JPEG images.

Code  (Download class.ImageFilter.php_.zip)

 

  1. error_reporting(0);  
  2.         require_once(‘class.ImageFilter.php’);  
  3.         $arr =  array(‘a.jpg’,‘b.jpg’,‘c.jpg’,‘d.jpg’,‘e.jpg’);  
  4.         $filter = new ImageFilter();  
  5.           
  6.         foreach ($arr as $a )  
  7.         {  
  8.         $ab = SITEURL.‘images/’.$a;  
  9.         $score = $filter->GetScore($ab);  
  10.           
  11.         echo ‘<img src=”‘.$ab.‘” style=”height:100px; width:100px;”>’;  
  12.         if($score > 60)  
  13.         { echo “It seems that you have uploaded a nude picture :-(“ ; }  
  14.         elseecho “It seems that you have uploaded a nice picture :-) “; }  
  15.         echo “<br>”;  
  16.         }