skew for 3d og image
This commit is contained in:
parent
5782f7b8c6
commit
563f2e22f9
|
@ -434,88 +434,100 @@ App::get('/v1/cards/cloud-og')
|
|||
->inject('dbForProject')
|
||||
->inject('response')
|
||||
->action(function (int $width, int $height, Document $user, Document $project, Database $dbForProject, Response $response) {
|
||||
if ($user->isEmpty()) {
|
||||
throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN);
|
||||
}
|
||||
// if ($user->isEmpty()) {
|
||||
// throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN);
|
||||
// }
|
||||
|
||||
$baseImage = new \Imagick("public/images/cards-cloud.png");
|
||||
$baseImage = new \Imagick("public/images/cards-cloud-og3.png");
|
||||
|
||||
$name = $user->getAttribute('name', 'Anonymous');
|
||||
$createdAt = new \DateTime($user->getCreatedAt());
|
||||
$memberSince = \strtoupper('Member since ' . $createdAt->format('M') . ' ' . $createdAt->format('d') . ', ' . $createdAt->format('o'));
|
||||
// $name = $user->getAttribute('name', 'Anonymous');
|
||||
// $createdAt = new \DateTime($user->getCreatedAt());
|
||||
// $memberSince = \strtoupper('Member since ' . $createdAt->format('M') . ' ' . $createdAt->format('d') . ', ' . $createdAt->format('o'));
|
||||
|
||||
try {
|
||||
$sessions = $user->getAttribute('sessions', []);
|
||||
$session = $sessions[0] ?? new Document();
|
||||
// try {
|
||||
// $sessions = $user->getAttribute('sessions', []);
|
||||
// $session = $sessions[0] ?? new Document();
|
||||
|
||||
$provider = $session->getAttribute('provider');
|
||||
$refreshToken = $session->getAttribute('providerRefreshToken');
|
||||
// $provider = $session->getAttribute('provider');
|
||||
// $refreshToken = $session->getAttribute('providerRefreshToken');
|
||||
|
||||
$appId = $project->getAttribute('authProviders', [])[$provider . 'Appid'] ?? '';
|
||||
$appSecret = $project->getAttribute('authProviders', [])[$provider . 'Secret'] ?? '{}';
|
||||
// $appId = $project->getAttribute('authProviders', [])[$provider . 'Appid'] ?? '';
|
||||
// $appSecret = $project->getAttribute('authProviders', [])[$provider . 'Secret'] ?? '{}';
|
||||
|
||||
$className = 'Appwrite\\Auth\\OAuth2\\' . \ucfirst($provider);
|
||||
// $className = 'Appwrite\\Auth\\OAuth2\\' . \ucfirst($provider);
|
||||
|
||||
if (!\class_exists($className)) {
|
||||
throw new Exception(Exception::PROJECT_PROVIDER_UNSUPPORTED);
|
||||
}
|
||||
// if (!\class_exists($className)) {
|
||||
// throw new Exception(Exception::PROJECT_PROVIDER_UNSUPPORTED);
|
||||
// }
|
||||
|
||||
$oauth2 = new $className($appId, $appSecret, '', [], []);
|
||||
// $oauth2 = new $className($appId, $appSecret, '', [], []);
|
||||
|
||||
$oauth2->refreshTokens($refreshToken);
|
||||
// $oauth2->refreshTokens($refreshToken);
|
||||
|
||||
$accessToken = $oauth2->getAccessToken('');
|
||||
$refreshToken = $oauth2->getRefreshToken('');
|
||||
// $accessToken = $oauth2->getAccessToken('');
|
||||
// $refreshToken = $oauth2->getRefreshToken('');
|
||||
|
||||
$session
|
||||
->setAttribute('providerAccessToken', $accessToken)
|
||||
->setAttribute('providerRefreshToken', $refreshToken)
|
||||
->setAttribute('providerAccessTokenExpiry', DateTime::addSeconds(new \DateTime(), (int)$oauth2->getAccessTokenExpiry('')));
|
||||
// $session
|
||||
// ->setAttribute('providerAccessToken', $accessToken)
|
||||
// ->setAttribute('providerRefreshToken', $refreshToken)
|
||||
// ->setAttribute('providerAccessTokenExpiry', DateTime::addSeconds(new \DateTime(), (int)$oauth2->getAccessTokenExpiry('')));
|
||||
|
||||
$dbForProject->updateDocument('sessions', $session->getId(), $session);
|
||||
// $dbForProject->updateDocument('sessions', $session->getId(), $session);
|
||||
|
||||
$dbForProject->deleteCachedDocument('users', $user->getId());
|
||||
// $dbForProject->deleteCachedDocument('users', $user->getId());
|
||||
|
||||
$githubUser = $oauth2->getUserSlug($accessToken);
|
||||
// $githubUser = $oauth2->getUserSlug($accessToken);
|
||||
|
||||
$gitHub = $githubUser;
|
||||
} catch (Exception $err) {
|
||||
$gitHub = '';
|
||||
\var_dump($err->getMessage());
|
||||
\var_dump($err->getTraceAsString());
|
||||
\var_dump($err->getLine());
|
||||
\var_dump($err->getFile());
|
||||
}
|
||||
// $gitHub = $githubUser;
|
||||
// } catch (Exception $err) {
|
||||
// $gitHub = '';
|
||||
// \var_dump($err->getMessage());
|
||||
// \var_dump($err->getTraceAsString());
|
||||
// \var_dump($err->getLine());
|
||||
// \var_dump($err->getFile());
|
||||
// }
|
||||
|
||||
// setlocale(LC_ALL, "en_US.utf8");
|
||||
// $name = \iconv("utf-8", "ascii//TRANSLIT", $name);
|
||||
// $memberSince = \iconv("utf-8", "ascii//TRANSLIT", $memberSince);
|
||||
// $gitHub = \iconv("utf-8", "ascii//TRANSLIT", $gitHub);
|
||||
|
||||
$name = 'Matej Bačo';
|
||||
$memberSince = 'Member since 12 Nov 2023';
|
||||
$gitHub = 'meldiron';
|
||||
|
||||
$text = new \ImagickDraw();
|
||||
$text->setTextAlignment(Imagick::ALIGN_CENTER);
|
||||
$text->setFont("public/fonts/Poppins-Bold.ttf");
|
||||
$text->setFillColor(new ImagickPixel('#FFFFFF'));
|
||||
$text->setFontSize(58);
|
||||
$text->setFontWeight(700);
|
||||
$baseImage->annotateImage($text, 550, 585, -22.88, $name);
|
||||
|
||||
$text = new \ImagickDraw();
|
||||
$text->setTextAlignment(Imagick::ALIGN_CENTER);
|
||||
$text->setFont("public/fonts/Inter-Medium.ttf");
|
||||
$text->setFillColor(new ImagickPixel('#FFB9CC'));
|
||||
$text->setFontSize(24);
|
||||
$text->setFontWeight(500);
|
||||
$text->setTextKerning(1.12);
|
||||
$baseImage->annotateImage($text, 570, 630, -22.24, $memberSince);
|
||||
$text->skewY(20);
|
||||
$text->skewX(20);
|
||||
$text->setGravity(Imagick::GRAVITY_CENTER);
|
||||
$text->annotation(350, 635, $name);
|
||||
|
||||
$text = new \ImagickDraw();
|
||||
$text->setTextAlignment(Imagick::ALIGN_CENTER);
|
||||
$text->setFont("public/fonts/Inter-Regular.ttf");
|
||||
$text->setFillColor(new ImagickPixel('#FFB9CC'));
|
||||
$text->setFontSize(26);
|
||||
$text->setFontWeight(400);
|
||||
$baseImage->annotateImage($text, 805, 380, 64.75, $gitHub);
|
||||
|
||||
$baseImage->drawImage($text);
|
||||
// $baseImage->annotateImage($text, 550, 535, -8.86, $name);
|
||||
|
||||
// $text = new \ImagickDraw();
|
||||
// $text->setTextAlignment(Imagick::ALIGN_CENTER);
|
||||
// $text->setFont("public/fonts/Inter-Medium.ttf");
|
||||
// $text->setFillColor(new ImagickPixel('#FFB9CC'));
|
||||
// $text->setFontSize(24);
|
||||
// $text->setFontWeight(500);
|
||||
// $text->setTextKerning(1.12);
|
||||
// $baseImage->annotateImage($text, 570, 630, -22.24, $memberSince);
|
||||
|
||||
// $text = new \ImagickDraw();
|
||||
// $text->setTextAlignment(Imagick::ALIGN_CENTER);
|
||||
// $text->setFont("public/fonts/Inter-Regular.ttf");
|
||||
// $text->setFillColor(new ImagickPixel('#FFB9CC'));
|
||||
// $text->setFontSize(26);
|
||||
// $text->setFontWeight(400);
|
||||
// $baseImage->annotateImage($text, 805, 380, 64.75, $gitHub);
|
||||
|
||||
// $metrics = $baseImage->queryFontMetrics($text, $gitHub);
|
||||
// \var_dump($metrics['textWidth']);
|
||||
|
|
71
composer.lock
generated
71
composer.lock
generated
|
@ -300,16 +300,16 @@
|
|||
},
|
||||
{
|
||||
"name": "colinmollenhour/credis",
|
||||
"version": "v1.14.0",
|
||||
"version": "v1.15.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/colinmollenhour/credis.git",
|
||||
"reference": "dccc8a46586475075fbb012d8bd523b8a938c2dc"
|
||||
"reference": "28810439de1d9597b7ba11794ed9479fb6f3de7c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/colinmollenhour/credis/zipball/dccc8a46586475075fbb012d8bd523b8a938c2dc",
|
||||
"reference": "dccc8a46586475075fbb012d8bd523b8a938c2dc",
|
||||
"url": "https://api.github.com/repos/colinmollenhour/credis/zipball/28810439de1d9597b7ba11794ed9479fb6f3de7c",
|
||||
"reference": "28810439de1d9597b7ba11794ed9479fb6f3de7c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -341,9 +341,9 @@
|
|||
"homepage": "https://github.com/colinmollenhour/credis",
|
||||
"support": {
|
||||
"issues": "https://github.com/colinmollenhour/credis/issues",
|
||||
"source": "https://github.com/colinmollenhour/credis/tree/v1.14.0"
|
||||
"source": "https://github.com/colinmollenhour/credis/tree/v1.15.0"
|
||||
},
|
||||
"time": "2022-11-09T01:18:39+00:00"
|
||||
"time": "2023-04-18T15:34:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dragonmantank/cron-expression",
|
||||
|
@ -408,22 +408,22 @@
|
|||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "7.5.0",
|
||||
"version": "7.5.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/guzzle.git",
|
||||
"reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba"
|
||||
"reference": "b964ca597e86b752cd994f27293e9fa6b6a95ed9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/b50a2a1251152e43f6a37f0fa053e730a67d25ba",
|
||||
"reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/b964ca597e86b752cd994f27293e9fa6b6a95ed9",
|
||||
"reference": "b964ca597e86b752cd994f27293e9fa6b6a95ed9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"guzzlehttp/promises": "^1.5",
|
||||
"guzzlehttp/psr7": "^1.9 || ^2.4",
|
||||
"guzzlehttp/psr7": "^1.9.1 || ^2.4.5",
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"psr/http-client": "^1.0",
|
||||
"symfony/deprecation-contracts": "^2.2 || ^3.0"
|
||||
|
@ -516,7 +516,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/guzzle/issues",
|
||||
"source": "https://github.com/guzzle/guzzle/tree/7.5.0"
|
||||
"source": "https://github.com/guzzle/guzzle/tree/7.5.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -532,7 +532,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-08-28T15:39:27+00:00"
|
||||
"time": "2023-04-17T16:30:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/promises",
|
||||
|
@ -620,22 +620,22 @@
|
|||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"version": "2.4.4",
|
||||
"version": "2.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf"
|
||||
"reference": "b635f279edd83fc275f822a1188157ffea568ff6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf",
|
||||
"reference": "3cf1b6d4f0c820a2cf8bcaec39fc698f3443b5cf",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6",
|
||||
"reference": "b635f279edd83fc275f822a1188157ffea568ff6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-message": "^1.0",
|
||||
"psr/http-message": "^1.1 || ^2.0",
|
||||
"ralouphie/getallheaders": "^3.0"
|
||||
},
|
||||
"provide": {
|
||||
|
@ -655,9 +655,6 @@
|
|||
"bamarni-bin": {
|
||||
"bin-links": true,
|
||||
"forward-command": false
|
||||
},
|
||||
"branch-alias": {
|
||||
"dev-master": "2.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -719,7 +716,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/psr7/issues",
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.4.4"
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.5.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -735,7 +732,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-03-09T13:19:02+00:00"
|
||||
"time": "2023-04-17T16:11:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "influxdb/influxdb-php",
|
||||
|
@ -1176,16 +1173,16 @@
|
|||
},
|
||||
{
|
||||
"name": "psr/http-message",
|
||||
"version": "1.1",
|
||||
"version": "2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/http-message.git",
|
||||
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba"
|
||||
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
|
||||
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
|
||||
"url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
|
||||
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1194,7 +1191,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1.x-dev"
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -1209,7 +1206,7 @@
|
|||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for HTTP messages",
|
||||
|
@ -1223,9 +1220,9 @@
|
|||
"response"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/http-message/tree/1.1"
|
||||
"source": "https://github.com/php-fig/http-message/tree/2.0"
|
||||
},
|
||||
"time": "2023-04-04T09:50:52+00:00"
|
||||
"time": "2023-04-04T09:54:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
|
@ -3574,16 +3571,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpstan/phpdoc-parser",
|
||||
"version": "1.18.1",
|
||||
"version": "1.20.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpdoc-parser.git",
|
||||
"reference": "22dcdfd725ddf99583bfe398fc624ad6c5004a0f"
|
||||
"reference": "90490bd8fd8530a272043c4950c180b6d0cf5f81"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/22dcdfd725ddf99583bfe398fc624ad6c5004a0f",
|
||||
"reference": "22dcdfd725ddf99583bfe398fc624ad6c5004a0f",
|
||||
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/90490bd8fd8530a272043c4950c180b6d0cf5f81",
|
||||
"reference": "90490bd8fd8530a272043c4950c180b6d0cf5f81",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -3613,9 +3610,9 @@
|
|||
"description": "PHPDoc parser with support for nullable, intersection and generic types",
|
||||
"support": {
|
||||
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
|
||||
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.18.1"
|
||||
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.20.2"
|
||||
},
|
||||
"time": "2023-04-07T11:51:11+00:00"
|
||||
"time": "2023-04-22T12:59:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
|
|
BIN
public/images/cards-cloud-og3.png
Normal file
BIN
public/images/cards-cloud-og3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 587 KiB |
Loading…
Reference in a new issue