diff --git a/birdavatar/README.md b/birdavatar/README.md new file mode 100644 index 00000000..4eb8fd80 --- /dev/null +++ b/birdavatar/README.md @@ -0,0 +1,14 @@ +# Bird Avatar Generator + +Generate a default avatar based on David Revoy's bird-avatar-generator https://www.peppercarrot.com/extras/html/2019_bird-generator/index.php + +## License: + +**Artworks:** +PNG and ORA files licensed under: [CC-By 4.0](https://creativecommons.org/licenses/by/4.0/) +attribution: David Revoy with the following exception: Generated pictures used as Avatar +(for blog,forum,social-network) don't need direct attribution and so, can be used + +**Original code** +Original PHP code is licensed under the short and simple permissive: +[MIT License](https://en.wikipedia.org/wiki/MIT_License) diff --git a/birdavatar/avatars/accessorie_1.png b/birdavatar/avatars/accessorie_1.png new file mode 100644 index 00000000..decd7486 Binary files /dev/null and b/birdavatar/avatars/accessorie_1.png differ diff --git a/birdavatar/avatars/accessorie_10.png b/birdavatar/avatars/accessorie_10.png new file mode 100644 index 00000000..f8e4529d Binary files /dev/null and b/birdavatar/avatars/accessorie_10.png differ diff --git a/birdavatar/avatars/accessorie_11.png b/birdavatar/avatars/accessorie_11.png new file mode 100644 index 00000000..783e968e Binary files /dev/null and b/birdavatar/avatars/accessorie_11.png differ diff --git a/birdavatar/avatars/accessorie_12.png b/birdavatar/avatars/accessorie_12.png new file mode 100644 index 00000000..dde3b6c1 Binary files /dev/null and b/birdavatar/avatars/accessorie_12.png differ diff --git a/birdavatar/avatars/accessorie_13.png b/birdavatar/avatars/accessorie_13.png new file mode 100644 index 00000000..64fe705c Binary files /dev/null and b/birdavatar/avatars/accessorie_13.png differ diff --git a/birdavatar/avatars/accessorie_14.png b/birdavatar/avatars/accessorie_14.png new file mode 100644 index 00000000..66f3d848 Binary files /dev/null and b/birdavatar/avatars/accessorie_14.png differ diff --git a/birdavatar/avatars/accessorie_15.png b/birdavatar/avatars/accessorie_15.png new file mode 100644 index 00000000..decd7486 Binary files /dev/null and b/birdavatar/avatars/accessorie_15.png differ diff --git a/birdavatar/avatars/accessorie_16.png b/birdavatar/avatars/accessorie_16.png new file mode 100644 index 00000000..aa011593 Binary files /dev/null and b/birdavatar/avatars/accessorie_16.png differ diff --git a/birdavatar/avatars/accessorie_17.png b/birdavatar/avatars/accessorie_17.png new file mode 100644 index 00000000..43f6968f Binary files /dev/null and b/birdavatar/avatars/accessorie_17.png differ diff --git a/birdavatar/avatars/accessorie_18.png b/birdavatar/avatars/accessorie_18.png new file mode 100644 index 00000000..43f6968f Binary files /dev/null and b/birdavatar/avatars/accessorie_18.png differ diff --git a/birdavatar/avatars/accessorie_19.png b/birdavatar/avatars/accessorie_19.png new file mode 100644 index 00000000..43f6968f Binary files /dev/null and b/birdavatar/avatars/accessorie_19.png differ diff --git a/birdavatar/avatars/accessorie_2.png b/birdavatar/avatars/accessorie_2.png new file mode 100644 index 00000000..f850aab0 Binary files /dev/null and b/birdavatar/avatars/accessorie_2.png differ diff --git a/birdavatar/avatars/accessorie_20.png b/birdavatar/avatars/accessorie_20.png new file mode 100644 index 00000000..43f6968f Binary files /dev/null and b/birdavatar/avatars/accessorie_20.png differ diff --git a/birdavatar/avatars/accessorie_3.png b/birdavatar/avatars/accessorie_3.png new file mode 100644 index 00000000..3e572e17 Binary files /dev/null and b/birdavatar/avatars/accessorie_3.png differ diff --git a/birdavatar/avatars/accessorie_4.png b/birdavatar/avatars/accessorie_4.png new file mode 100644 index 00000000..f850aab0 Binary files /dev/null and b/birdavatar/avatars/accessorie_4.png differ diff --git a/birdavatar/avatars/accessorie_5.png b/birdavatar/avatars/accessorie_5.png new file mode 100644 index 00000000..d70aeddc Binary files /dev/null and b/birdavatar/avatars/accessorie_5.png differ diff --git a/birdavatar/avatars/accessorie_6.png b/birdavatar/avatars/accessorie_6.png new file mode 100644 index 00000000..7e91f4ac Binary files /dev/null and b/birdavatar/avatars/accessorie_6.png differ diff --git a/birdavatar/avatars/accessorie_7.png b/birdavatar/avatars/accessorie_7.png new file mode 100644 index 00000000..20b6b505 Binary files /dev/null and b/birdavatar/avatars/accessorie_7.png differ diff --git a/birdavatar/avatars/accessorie_8.png b/birdavatar/avatars/accessorie_8.png new file mode 100644 index 00000000..3453d5f2 Binary files /dev/null and b/birdavatar/avatars/accessorie_8.png differ diff --git a/birdavatar/avatars/accessorie_9.png b/birdavatar/avatars/accessorie_9.png new file mode 100644 index 00000000..decd7486 Binary files /dev/null and b/birdavatar/avatars/accessorie_9.png differ diff --git a/birdavatar/avatars/bec_1.png b/birdavatar/avatars/bec_1.png new file mode 100644 index 00000000..cf290f7d Binary files /dev/null and b/birdavatar/avatars/bec_1.png differ diff --git a/birdavatar/avatars/bec_2.png b/birdavatar/avatars/bec_2.png new file mode 100644 index 00000000..5b1be9a2 Binary files /dev/null and b/birdavatar/avatars/bec_2.png differ diff --git a/birdavatar/avatars/bec_3.png b/birdavatar/avatars/bec_3.png new file mode 100644 index 00000000..3739b558 Binary files /dev/null and b/birdavatar/avatars/bec_3.png differ diff --git a/birdavatar/avatars/bec_4.png b/birdavatar/avatars/bec_4.png new file mode 100644 index 00000000..e16d0d54 Binary files /dev/null and b/birdavatar/avatars/bec_4.png differ diff --git a/birdavatar/avatars/bec_5.png b/birdavatar/avatars/bec_5.png new file mode 100644 index 00000000..8a1be081 Binary files /dev/null and b/birdavatar/avatars/bec_5.png differ diff --git a/birdavatar/avatars/bec_6.png b/birdavatar/avatars/bec_6.png new file mode 100644 index 00000000..5bd87c20 Binary files /dev/null and b/birdavatar/avatars/bec_6.png differ diff --git a/birdavatar/avatars/bec_7.png b/birdavatar/avatars/bec_7.png new file mode 100644 index 00000000..b71b04f8 Binary files /dev/null and b/birdavatar/avatars/bec_7.png differ diff --git a/birdavatar/avatars/bec_8.png b/birdavatar/avatars/bec_8.png new file mode 100644 index 00000000..fbf95a01 Binary files /dev/null and b/birdavatar/avatars/bec_8.png differ diff --git a/birdavatar/avatars/bec_9.png b/birdavatar/avatars/bec_9.png new file mode 100644 index 00000000..16a2d2ef Binary files /dev/null and b/birdavatar/avatars/bec_9.png differ diff --git a/birdavatar/avatars/body_1.png b/birdavatar/avatars/body_1.png new file mode 100644 index 00000000..490d75ef Binary files /dev/null and b/birdavatar/avatars/body_1.png differ diff --git a/birdavatar/avatars/body_2.png b/birdavatar/avatars/body_2.png new file mode 100644 index 00000000..0c6e36f5 Binary files /dev/null and b/birdavatar/avatars/body_2.png differ diff --git a/birdavatar/avatars/body_3.png b/birdavatar/avatars/body_3.png new file mode 100644 index 00000000..ccbcf0fd Binary files /dev/null and b/birdavatar/avatars/body_3.png differ diff --git a/birdavatar/avatars/body_4.png b/birdavatar/avatars/body_4.png new file mode 100644 index 00000000..14a295bc Binary files /dev/null and b/birdavatar/avatars/body_4.png differ diff --git a/birdavatar/avatars/body_5.png b/birdavatar/avatars/body_5.png new file mode 100644 index 00000000..2e06406b Binary files /dev/null and b/birdavatar/avatars/body_5.png differ diff --git a/birdavatar/avatars/body_6.png b/birdavatar/avatars/body_6.png new file mode 100644 index 00000000..cf6195d3 Binary files /dev/null and b/birdavatar/avatars/body_6.png differ diff --git a/birdavatar/avatars/body_7.png b/birdavatar/avatars/body_7.png new file mode 100644 index 00000000..dc1b34be Binary files /dev/null and b/birdavatar/avatars/body_7.png differ diff --git a/birdavatar/avatars/body_8.png b/birdavatar/avatars/body_8.png new file mode 100644 index 00000000..07d571f9 Binary files /dev/null and b/birdavatar/avatars/body_8.png differ diff --git a/birdavatar/avatars/body_9.png b/birdavatar/avatars/body_9.png new file mode 100644 index 00000000..9dd1da4d Binary files /dev/null and b/birdavatar/avatars/body_9.png differ diff --git a/birdavatar/avatars/eyes_1.png b/birdavatar/avatars/eyes_1.png new file mode 100644 index 00000000..2d347cb5 Binary files /dev/null and b/birdavatar/avatars/eyes_1.png differ diff --git a/birdavatar/avatars/eyes_2.png b/birdavatar/avatars/eyes_2.png new file mode 100644 index 00000000..584afa99 Binary files /dev/null and b/birdavatar/avatars/eyes_2.png differ diff --git a/birdavatar/avatars/eyes_3.png b/birdavatar/avatars/eyes_3.png new file mode 100644 index 00000000..5434f9c7 Binary files /dev/null and b/birdavatar/avatars/eyes_3.png differ diff --git a/birdavatar/avatars/eyes_4.png b/birdavatar/avatars/eyes_4.png new file mode 100644 index 00000000..7c9cee1b Binary files /dev/null and b/birdavatar/avatars/eyes_4.png differ diff --git a/birdavatar/avatars/eyes_5.png b/birdavatar/avatars/eyes_5.png new file mode 100644 index 00000000..89859b25 Binary files /dev/null and b/birdavatar/avatars/eyes_5.png differ diff --git a/birdavatar/avatars/eyes_6.png b/birdavatar/avatars/eyes_6.png new file mode 100644 index 00000000..7acdd69a Binary files /dev/null and b/birdavatar/avatars/eyes_6.png differ diff --git a/birdavatar/avatars/eyes_7.png b/birdavatar/avatars/eyes_7.png new file mode 100644 index 00000000..098a066a Binary files /dev/null and b/birdavatar/avatars/eyes_7.png differ diff --git a/birdavatar/avatars/eyes_8.png b/birdavatar/avatars/eyes_8.png new file mode 100644 index 00000000..64267cfa Binary files /dev/null and b/birdavatar/avatars/eyes_8.png differ diff --git a/birdavatar/avatars/eyes_9.png b/birdavatar/avatars/eyes_9.png new file mode 100644 index 00000000..1807e049 Binary files /dev/null and b/birdavatar/avatars/eyes_9.png differ diff --git a/birdavatar/avatars/hoop_1.png b/birdavatar/avatars/hoop_1.png new file mode 100644 index 00000000..d1606934 Binary files /dev/null and b/birdavatar/avatars/hoop_1.png differ diff --git a/birdavatar/avatars/hoop_10.png b/birdavatar/avatars/hoop_10.png new file mode 100644 index 00000000..f8426701 Binary files /dev/null and b/birdavatar/avatars/hoop_10.png differ diff --git a/birdavatar/avatars/hoop_2.png b/birdavatar/avatars/hoop_2.png new file mode 100644 index 00000000..e2f089d7 Binary files /dev/null and b/birdavatar/avatars/hoop_2.png differ diff --git a/birdavatar/avatars/hoop_3.png b/birdavatar/avatars/hoop_3.png new file mode 100644 index 00000000..b985f340 Binary files /dev/null and b/birdavatar/avatars/hoop_3.png differ diff --git a/birdavatar/avatars/hoop_4.png b/birdavatar/avatars/hoop_4.png new file mode 100644 index 00000000..cde95f8a Binary files /dev/null and b/birdavatar/avatars/hoop_4.png differ diff --git a/birdavatar/avatars/hoop_5.png b/birdavatar/avatars/hoop_5.png new file mode 100644 index 00000000..1fc8312e Binary files /dev/null and b/birdavatar/avatars/hoop_5.png differ diff --git a/birdavatar/avatars/hoop_6.png b/birdavatar/avatars/hoop_6.png new file mode 100644 index 00000000..95a7f498 Binary files /dev/null and b/birdavatar/avatars/hoop_6.png differ diff --git a/birdavatar/avatars/hoop_7.png b/birdavatar/avatars/hoop_7.png new file mode 100644 index 00000000..389d538f Binary files /dev/null and b/birdavatar/avatars/hoop_7.png differ diff --git a/birdavatar/avatars/hoop_8.png b/birdavatar/avatars/hoop_8.png new file mode 100644 index 00000000..b0cf84c6 Binary files /dev/null and b/birdavatar/avatars/hoop_8.png differ diff --git a/birdavatar/avatars/hoop_9.png b/birdavatar/avatars/hoop_9.png new file mode 100644 index 00000000..f58e8d2b Binary files /dev/null and b/birdavatar/avatars/hoop_9.png differ diff --git a/birdavatar/avatars/tail_1.png b/birdavatar/avatars/tail_1.png new file mode 100644 index 00000000..e544ca3e Binary files /dev/null and b/birdavatar/avatars/tail_1.png differ diff --git a/birdavatar/avatars/tail_2.png b/birdavatar/avatars/tail_2.png new file mode 100644 index 00000000..5ca71c88 Binary files /dev/null and b/birdavatar/avatars/tail_2.png differ diff --git a/birdavatar/avatars/tail_3.png b/birdavatar/avatars/tail_3.png new file mode 100644 index 00000000..aebf9b4c Binary files /dev/null and b/birdavatar/avatars/tail_3.png differ diff --git a/birdavatar/avatars/tail_4.png b/birdavatar/avatars/tail_4.png new file mode 100644 index 00000000..e549eb26 Binary files /dev/null and b/birdavatar/avatars/tail_4.png differ diff --git a/birdavatar/avatars/tail_5.png b/birdavatar/avatars/tail_5.png new file mode 100644 index 00000000..7bf9a2df Binary files /dev/null and b/birdavatar/avatars/tail_5.png differ diff --git a/birdavatar/avatars/tail_6.png b/birdavatar/avatars/tail_6.png new file mode 100644 index 00000000..081446a4 Binary files /dev/null and b/birdavatar/avatars/tail_6.png differ diff --git a/birdavatar/avatars/tail_7.png b/birdavatar/avatars/tail_7.png new file mode 100644 index 00000000..99d38880 Binary files /dev/null and b/birdavatar/avatars/tail_7.png differ diff --git a/birdavatar/avatars/tail_8.png b/birdavatar/avatars/tail_8.png new file mode 100644 index 00000000..338a82a5 Binary files /dev/null and b/birdavatar/avatars/tail_8.png differ diff --git a/birdavatar/avatars/tail_9.png b/birdavatar/avatars/tail_9.png new file mode 100644 index 00000000..eda337d1 Binary files /dev/null and b/birdavatar/avatars/tail_9.png differ diff --git a/birdavatar/avatars/wing_1.png b/birdavatar/avatars/wing_1.png new file mode 100644 index 00000000..14aadd7c Binary files /dev/null and b/birdavatar/avatars/wing_1.png differ diff --git a/birdavatar/avatars/wing_2.png b/birdavatar/avatars/wing_2.png new file mode 100644 index 00000000..5b5c25ca Binary files /dev/null and b/birdavatar/avatars/wing_2.png differ diff --git a/birdavatar/avatars/wing_3.png b/birdavatar/avatars/wing_3.png new file mode 100644 index 00000000..bb84cdf0 Binary files /dev/null and b/birdavatar/avatars/wing_3.png differ diff --git a/birdavatar/avatars/wing_4.png b/birdavatar/avatars/wing_4.png new file mode 100644 index 00000000..44ad10e6 Binary files /dev/null and b/birdavatar/avatars/wing_4.png differ diff --git a/birdavatar/avatars/wing_5.png b/birdavatar/avatars/wing_5.png new file mode 100644 index 00000000..f7a8fcbb Binary files /dev/null and b/birdavatar/avatars/wing_5.png differ diff --git a/birdavatar/avatars/wing_6.png b/birdavatar/avatars/wing_6.png new file mode 100644 index 00000000..c29b31e8 Binary files /dev/null and b/birdavatar/avatars/wing_6.png differ diff --git a/birdavatar/avatars/wing_7.png b/birdavatar/avatars/wing_7.png new file mode 100644 index 00000000..a4ed6610 Binary files /dev/null and b/birdavatar/avatars/wing_7.png differ diff --git a/birdavatar/avatars/wing_8.png b/birdavatar/avatars/wing_8.png new file mode 100644 index 00000000..ed0738cb Binary files /dev/null and b/birdavatar/avatars/wing_8.png differ diff --git a/birdavatar/avatars/wing_9.png b/birdavatar/avatars/wing_9.png new file mode 100644 index 00000000..07d59f89 Binary files /dev/null and b/birdavatar/avatars/wing_9.png differ diff --git a/birdavatar/bird_src.ora b/birdavatar/bird_src.ora new file mode 100644 index 00000000..c88532a4 Binary files /dev/null and b/birdavatar/bird_src.ora differ diff --git a/birdavatar/birdavatar.php b/birdavatar/birdavatar.php new file mode 100644 index 00000000..3e0eca52 --- /dev/null +++ b/birdavatar/birdavatar.php @@ -0,0 +1,266 @@ + + */ + +use Friendica\App; +use Friendica\Core\Hook; +use Friendica\Core\Logger; +use Friendica\Core\Renderer; +use Friendica\Core\Worker; +use Friendica\Database\DBA; +use Friendica\DI; +use Friendica\Model\Contact; +use Friendica\Model\Photo; +use Friendica\Model\Profile; +use Friendica\Network\HTTPException\NotFoundException; + +define("BIRDAVATAR_SIZE", 256); + +/** + * Installs the addon hook + */ +function birdavatar_install() +{ + Hook::register('avatar_lookup', 'addon/birdavatar/birdavatar.php', 'birdavatar_lookup'); + Hook::register('addon_settings', 'addon/birdavatar/birdavatar.php', 'birdavatar_addon_settings'); + Hook::register('addon_settings_post', 'addon/birdavatar/birdavatar.php', 'birdavatar_addon_settings_post'); + + Logger::log('registered birdavatar'); +} + +/** + * Bird avatar user settings page + */ +function birdavatar_addon_settings(App $a, &$s) +{ + if (!local_user()) { + return; + } + + $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/birdavatar/'); + $s .= Renderer::replaceMacros($t, [ + '$postpost' => !empty($_POST['birdavatar-morebird']) || !empty($_POST['birdavatar-emailbird']), + '$uncache' => time(), + '$uid' => local_user(), + '$usebird' => DI::l10n()->t('Use Bird as Avatar'), + '$morebird' => DI::l10n()->t('More Random Bird!'), + '$emailbird' => DI::l10n()->t('Reset to email Bird'), + '$seed' => DI::pConfig()->get(local_user(), 'birdavatar', 'seed', false), + '$header' => DI::l10n()->t('Bird Avatar Settings'), + '$setrandomize' => DI::l10n()->t('Set default profile avatar or randomize the bird.'), + ]); +} + +/** + * Bird avatar user settings POST handle + */ +function birdavatar_addon_settings_post(App $a, &$s) +{ + if (!local_user()) { + return; + } + + if (!empty($_POST['birdavatar-usebird'])) { + $url = DI::baseUrl()->get() . '/birdavatar/' . local_user() . '?ts=' . time(); + + $self = DBA::selectFirst('contact', ['id'], ['uid' => local_user(), 'self' => true]); + if (!DBA::isResult($self)) { + notice(DI::l10n()->t("The bird has not found itself.")); + return; + } + + Photo::importProfilePhoto($url, local_user(), $self['id']); + + $condition = ['uid' => local_user(), 'contact-id' => $self['id']]; + $photo = DBA::selectFirst('photo', ['resource-id'], $condition); + if (!DBA::isResult($photo)) { + notice(DI::l10n()->t('There was an error, the bird flew away.')); + return; + } + + DBA::update('photo', ['profile' => false], ['profile' => true, 'uid' => local_user()]); + + $fields = ['profile' => true, 'album' => DI::l10n()->t('Profile Photos'), 'contact-id' => 0]; + DBA::update('photo', $fields, ['uid' => local_user(), 'resource-id' => $photo['resource-id']]); + + Photo::importProfilePhoto($url, local_user(), $self['id']); + + Contact::updateSelfFromUserID(local_user(), true); + + // Update global directory in background + Profile::publishUpdate(local_user()); + + info(DI::l10n()->t('Meow!')); + return; + } + + if (!empty($_POST['birdavatar-morebird'])) { + DI::pConfig()->set(local_user(), 'birdavatar', 'seed', time()); + } + + if (!empty($_POST['birdavatar-emailbird'])) { + DI::pConfig()->delete(local_user(), 'birdavatar', 'seed'); + } +} + +/** + * Returns the URL to the bird avatar + * + * @param $a array + * @param &$b array + */ +function birdavatar_lookup(App $a, &$b) +{ + $user = DBA::selectFirst('user', ['uid'], ['email' => $b['email']]); + if (DBA::isResult($user)) { + $url = DI::baseUrl()->get() . '/birdavatar/' . $user['uid']; + } else { + $url = DI::baseUrl()->get() . '/birdavatar/' . md5(trim(strtolower($b['email']))); + } + + switch ($b['size']) { + case 300: $url .= "/4"; break; + case 80: $url .= "/5"; break; + case 48: $url .= "/6"; break; + } + + $b['url'] = $url; + $b['success'] = true; +} + +function birdavatar_module() +{ +} + +/** + * Returns image for user id + * + * @throws NotFoundException + * + */ +function birdavatar_content(App $a) +{ + if (DI::args()->getArgc() < 2 || DI::args()->getArgc() > 3) { + throw new NotFoundException(); // this should be catched on index and show default "not found" page. + } + + if (is_numeric(DI::args()->getArgv()[1])) { + $uid = intval(DI::args()->getArgv()[1]); + $condition = ['uid' => $uid, + 'account_expired' => false, 'account_removed' => false]; + $user = DBA::selectFirst('user', ['email'], $condition); + + if ($user === false) { + throw new NotFoundException(); + } + + $seed = DI::pConfig()->get($uid, "birdavatar", "seed", md5(trim(strtolower($user['email'])))); + } elseif (!empty(DI::args()->getArgv()[1])) { + $seed = DI::args()->getArgv()[1]; + } else { + throw new NotFoundException(); + } + + $size = 0; + if (DI::args()->getArgc() == 3) { + $size = intval(DI::args()->getArgv()[2]); + } + + // start generation + ob_start(); + + // render the picture: + build_bird($seed, $size); + + ob_end_flush(); + + exit(); +} + +/** + * ==================== + * CAT-AVATAR-GENERATOR + * ==================== + * + * @authors: Andreas Gohr, David Revoy + * + * This PHP is licensed under the short and simple permissive: + * [MIT License](https://en.wikipedia.org/wiki/MIT_License) + * + **/ + +function build_bird($seed = '', $size = 0) +{ + // init random seed + if ($seed) { + srand(hexdec(substr(md5($seed), 0, 6))); + } + + // throw the dice for body parts + $parts = [ + 'tail' => rand(1,9), + 'hoop' => rand(1,10), + 'body' => rand(1,9), + 'wing' => rand(1,9), + 'eyes' => rand(1,9), + 'bec' => rand(1,9), + 'accessorie' => rand(1,20) + ]; + + // create backgound + $bird = @imagecreatetruecolor(BIRDAVATAR_SIZE, BIRDAVATAR_SIZE) + or die("GD image create failed"); + $white = imagecolorallocate($bird, 255, 255, 255); + imagefill($bird, 0, 0, $white); + + // add parts + foreach ($parts as $part => $num) { + $file = dirname(__FILE__) . '/avatars/' . $part . '_' . $num . '.png'; + + $im = @imagecreatefrompng($file); + if (!$im) { + die('Failed to load ' . $file); + } + imageSaveAlpha($im, true); + imagecopy($bird, $im, 0, 0, 0, 0, BIRDAVATAR_SIZE, BIRDAVATAR_SIZE); + imagedestroy($im); + } + + // scale image + if ($size > 3 && $size < 7) { + switch ($size) { + case 4: + $size = 300; + break; + case 5: + $size = 80; + break; + case 6: + $size = 48; + break; + } + + $dest = imagecreatetruecolor($size, $size) or die("GD image create failed"); + imagealphablending($dest, false); + imagesavealpha($dest, true); + imagecopyresampled($dest, $bird, 0, 0, 0, 0, $size, $size, BIRDAVATAR_SIZE, BIRDAVATAR_SIZE); + imagedestroy($bird); + $bird = $dest; + } + + // restore random seed + if ($seed) { + srand(); + } + + header('Pragma: public'); + header('Cache-Control: max-age=86400'); + header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 86400)); + header('Content-Type: image/jpg'); + imagejpeg($bird, null, 90); + imagedestroy($bird); +} diff --git a/birdavatar/lang/C/messages.po b/birdavatar/lang/C/messages.po new file mode 100644 index 00000000..35db2528 --- /dev/null +++ b/birdavatar/lang/C/messages.po @@ -0,0 +1,54 @@ +# ADDON birdavatar +# Copyright (C) +# This file is distributed under the same license as the Friendica birdavatar addon package. +# +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-11-24 12:04+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: birdavatar.php:49 +msgid "Use Bird as Avatar" +msgstr "" + +#: birdavatar.php:50 +msgid "More Random Bird!" +msgstr "" + +#: birdavatar.php:51 +msgid "Reset to email Bird" +msgstr "" + +#: birdavatar.php:53 +msgid "Bird Avatar Settings" +msgstr "" + +#: birdavatar.php:54 +msgid "Set default profile avatar or randomize the bird." +msgstr "" + +#: birdavatar.php:72 +msgid "The bird has not found itself." +msgstr "" + +#: birdavatar.php:81 +msgid "There was an error, the bird flew away." +msgstr "" + +#: birdavatar.php:87 +msgid "Profile Photos" +msgstr "" + +#: birdavatar.php:97 +msgid "Meow!" +msgstr "" diff --git a/birdavatar/templates/settings.tpl b/birdavatar/templates/settings.tpl new file mode 100644 index 00000000..a31acfdb --- /dev/null +++ b/birdavatar/templates/settings.tpl @@ -0,0 +1,24 @@ + +

{{$header}}

+
+
+ +

{{$header}}

+
+ +

{{$setrandomize}}

+
+ + +
+ + +
+
+