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    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 72%Total: 274 All time: 7,660 This week: 182Up
Version License PHP version Categories
safe-preview 1.0.2GNU General Publi...5.3PHP 5, Graphics, Security
Description 

Author

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: 51
All time rank: 134516 in Argentina Argentina
Week rank: 312 Up4 in Argentina Argentina Up
Innovation award
Innovation award
Nominee: 9x

Example

<?php

include('SafePreview.php');

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

?>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<?php echo $html;?>


Details

lutian/safePreview

> graphics-tools

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

- Include integration with mashape.com 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)

Version

0.1

Authors

  • [Luciano Salvino] - <lsalvino@hotmail.com>

Installation

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

{
   "require":{
      "lutian/safePreview": "dev-master"
   }
}

Use


include('SafePreview.php');

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

License

MIT

[Luciano Salvino]:http://mueveloz.com/


Screenshots  
  • 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 README.md 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  
 88%
Total:274
This week:0
All time:7,660
This week:182Up
 User Ratings  
 
 All time
Utility:90%StarStarStarStarStar
Consistency:90%StarStarStarStarStar
Documentation:95%StarStarStarStarStar
Examples:85%StarStarStarStarStar
Tests:-
Videos:-
Overall:72%StarStarStarStar
Rank:208