PHP Classes

PHP Avatar Stylizer: Detect predominant colors on avatar images

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 75%Total: 163 This week: 1All time: 8,920 This week: 560Up
Version License PHP version Categories
phpavatarstylizer 1.0.0GNU General Publi...5PHP 5, Graphics
Description 

Author

This class can detect predominant colors on avatar images.

It can take the path of a image file and detects what is the predominant color.

The class can also return the color that would contrast better when writing text on the top of the avatar image.

Innovation Award
PHP Programming Innovation award nominee
November 2017
Number 3
The best way to show a transparent avatar image is to display it on top of background with a color that contrasts better with the avatar image.

This package provides a good solution to display avatar images by determining the dominant color in the avatar image and then suggesting a background color that makes the image contrast better.

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: 411 Up3 in Argentina Argentina Up
Innovation award
Innovation award
Nominee: 9x

Example

<?php

require __DIR__ . '/PHPAvatarStylizer.php';

$avatarStylizer = new \PHPAvatarStylizer\PHPAvatarStylizer(TRUE);

$avatarPath = 'images/avatarDemo.jpg';

$userName = 'Lutian_the_Martian';

$userDesc = 'Give Me that Elephant!';

$avatarStylizer->getColorFromImage($avatarPath);

?>
<style>
.bgAvatar {
    background-color: <?php echo $avatarStylizer->bgColor;?>;
    width: 400px;
    height: 140px;
    padding: 20px;
}
.imgAvatar {
    float: left;
    background-image: url('<?php echo $avatarPath;?>');
    width: 120px;
    height: 120px;
    background-size: cover;
    border-radius: 50%;
}
.detailAvatar {
    float: left;
    width: 240px;
}
.title {
    margin-left: 20px;
    color: <?php echo $avatarStylizer->txtColor;?>;
    font-family: Arial;
    font-size: 22px;
}
.desc {
    margin-left: 20px;
    color: <?php echo $avatarStylizer->txtColor;?>;
    font-family: Arial;
    font-size: 16px;
}
</style>
<div class="bgAvatar">
    <div class="imgAvatar"></div>
    <div class="detailAvatar">
        <h2 class="title"><?php echo $userName;?></h2>
        <h3 class="desc"><?php echo $userDesc;?></h3>
    </div>
</div>


Details

{ "name": "lutian/PHPAvatarStylizer", "version": "1.0.0", "type": "library", "description": "Define automatically background color and text color depends on avatar predominant color", "keywords": ["lutian", "PHPAvatarStylizer", "text processing"], "homepage": "https://github.com/lutian/PHPAvatarStylizer.git", "license": "MIT", "authors": [ { "name": "Luciano Salvino", "email": "lsalvino@hotmail.com", "homepage": "http://getwayto.me" } ], "require": { "php": ">=5.4.0" }, "autoload": { "psr-4": { "Lutian\\PHPAvatarStylizer\\": "/" } } }

Screenshots  
  • Demo
  • Demo1
  • Demo2
  Files folder image Files  
File Role Description
Files folder imageimages (3 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Image file demo.JPG Icon Icon image
Accessible without login Plain text file demo.php Example Example script
Accessible without login Image file demo1.jpg Icon Icon image
Accessible without login Plain text file demo1.php Example Example script
Accessible without login Image file demo2.JPG Icon Icon image
Accessible without login Plain text file demo2.php Example Example script
Plain text file PHPAvatarStylizer.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  images  
File Role Description
  Accessible without login Image file avatarDemo.jpg Data Auxiliary data
  Accessible without login Image file avatarDemo1.jpg Data Auxiliary data
  Accessible without login Image file avatarDemo2.png Icon Icon image

 Version Control Unique User Downloads Download Rankings  
 80%
Total:163
This week:1
All time:8,920
This week:560Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:81%StarStarStarStarStar
Examples:93%StarStarStarStarStar
Tests:-
Videos:-
Overall:75%StarStarStarStar
Rank:74