Skip to content

Commit

Permalink
added identicons
Browse files Browse the repository at this point in the history
  • Loading branch information
geek-at committed Sep 3, 2023
1 parent 4c1124d commit 21aa1fb
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ docker run -d -p 8080:80 --name=pictshare ghcr.io/hascheksolutions/pictshare

Then open http://localhost:8080 in your browser

## New Features in v2
## New Features

- Generate identicons based on strings in the URL [example1](https://pictshare.net/identicon/example1) [example2](https://pictshare.net/identicon/example2)
- Generate placeholder images by specifying the size in the URL. [example](https://pictshare.net/placeholder/555x250/color-white-blue)
- Added support for external storage
- [Encryption of files in external storage](/rtfm/ENCRYPTION.md)
Expand Down
38 changes: 38 additions & 0 deletions content-controllers/identicon/identicon.controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use Bitverse\Identicon\Identicon;
use Bitverse\Identicon\Color\Color;
use Bitverse\Identicon\Generator\RingsGenerator;
use Bitverse\Identicon\Preprocessor\MD5Preprocessor;

class IdenticonController implements ContentController
{
public const ctype = 'dynamic';

//returns all extensions registered by this type of content
public function getRegisteredExtensions(){return array('identicon');}

public function handleHash($hash,$url)
{
unset($url[array_search('identicon',$url)]);
$url = array_values($url);


$generator = new RingsGenerator();
$generator->setBackgroundColor(Color::parseHex('#EEEEEE'));

$identicon = new Identicon(new MD5Preprocessor(), $generator);

$icon = $identicon->getIcon($url[0]);

header('Content-type: image/svg+xml');
echo $icon;
}

public function handleUpload($tmpfile,$hash=false)
{
return array('status'=>'err','hash'=>$hash,'reason'=>'Cannot upload to Identicons');
}


}
3 changes: 2 additions & 1 deletion lib/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"require": {
"aws/aws-sdk-php": "^3.33"
"aws/aws-sdk-php": "^3.33",
"bitverse/identicon": "^1.1"
}
}
45 changes: 44 additions & 1 deletion lib/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 21aa1fb

Please sign in to comment.