PHP Classes

PHP Safe Image Preview: Blur an image when it is not safe for non-adults

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-10-21 (11 months ago) RSS 2.0 feedStarStarStarStar 72%Total: 273 All time: 7,666 This week: 94Up
Version License PHP version Categories
safe-preview 1.0.2GNU General Publi...5.3PHP 5, Graphics, Security


This class can blur an image when it is not safe for non-adults.

It can check if a given image is safe for non-adult users by sending a API request to Mashape.

The class can generate a blurred version of the image when it is not safe.

Innovation Award
PHP Programming Innovation award nominee
October 2016
Number 4

Prize: 1 year subscription to the Basic Plan of an API product of choice
Some sites need to receive images from users that may not be safe for displaying to non-adults.

In this case it may be better to avoid showing those images to children. However, when you don't know if the user is not an adult, it would be better to show an obfuscated version of the image.

This class can use an API to determine if an image is not safe for showing to non-adults. It can also return a blurred version when it is the case, thus avoid showing the image explicitly.

Manuel Lemos
Picture of Luciano Salvino
  Performance   Level  
Name: Luciano Salvino <contact>
Classes: 11 packages by
Country: Argentina Argentina
Age: 50
All time rank: 135116 in Argentina Argentina
Week rank: 373 Up4 in Argentina Argentina Up
Innovation award
Innovation award
Nominee: 9x



> graphics-tools

Show blured image and alert message with your logo when picture is not safe

- Include integration with to recognize if picture contain porn or adult content
- Add logo of your company inside the blured image
- Add alert message inside the blured image (optional, if condition is FALSE you can not view the original image)
- You can add diferents font files to change the font type of alert message (arial by default)




  • [Luciano Salvino] - <>


To use the tools of this repo only has to be required in your composer.json:

      "lutian/safePreview": "dev-master"



// Init
$safePreview = new SafePreview();
// set lang
// set logo path
$pathLogo = 'images/logo/logo.png';
// set image path
$pathImage = 'images/origin/image.jpg';
// set image blured path
$pathBlured = 'images/blured/blured.jpg';
// set image url
$urlImage = 'http://{YOUR_URL}/safePreview/src/images/origin/image.jpg';
// set image blured url
$urlBlured = 'http:/{YOUR_URL}/safePreview/src/images/blured/blured.jpg';
// set the condition (add alert message: do you want to see it anyway?)
// verify if image safe
$isSafe = $safePreview->isImageSafe();
if(!$isSafe) {
	// if image not safe
	// show blured image
	$html = $safePreview->showPreview();
} else {
	// show original image
	$html = $safePreview->showOriginal();
echo $html;



[Luciano Salvino]:

  • example_result
  Files folder image Files  
File Role Description
Files folder imagesrc (2 files, 1 directory)
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 Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageimages (3 directories)
  Accessible without login Plain text file example.php Example example
  Plain text file SafePreview.php Class Class

  Files folder image Files  /  src  /  images  
File Role Description
Files folder imageblured (1 file)
Files folder imagelogo (1 file)
Files folder imageorigin (1 file)

  Files folder image Files  /  src  /  images  /  blured  
File Role Description
  Accessible without login Image file blured.jpg Output outup image

  Files folder image Files  /  src  /  images  /  origin  
File Role Description
  Accessible without login Image file image.jpg Data origin image

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,666
This week:94Up
 User Ratings  
 All time