1
0
Fork 0
mirror of synced 2024-06-29 19:50:26 +12:00

Merge pull request #700 from PedroCisnerosSantana/0.7.x

Changes BaconQRCode for QRCode
This commit is contained in:
Eldad A. Fux 2020-10-26 23:26:16 +02:00 committed by GitHub
commit 11b2ff7e64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 131 additions and 16 deletions

View file

@ -11,12 +11,10 @@ use Utopia\Cache\Cache;
use Utopia\Cache\Adapter\Filesystem;
use Appwrite\Resize\Resize;
use Appwrite\URL\URL as URLParse;
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
use Utopia\Config\Config;
use Utopia\Validator\HexColor;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
$avatarCallback = function ($type, $code, $width, $height, $quality, $response) {
/** @var Utopia\Response $response */
@ -365,13 +363,11 @@ App::get('/v1/avatars/qr')
/** @var Utopia\Response $response */
$download = ($download === '1' || $download === 'true' || $download === 1 || $download === true);
$renderer = new ImageRenderer(
new RendererStyle($size, $margin),
new ImagickImageBackEnd('png', 100)
);
$writer = new Writer($renderer);
$qropts = new QROptions([
'quietzone' => $size,
'outputType' => QRCode::OUTPUT_IMAGICK
]);
$qrcode = new QRCode($qropts);
if ($download) {
$response->addHeader('Content-Disposition', 'attachment; filename="qr.png"');
@ -380,7 +376,7 @@ App::get('/v1/avatars/qr')
$response
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)).' GMT') // 45 days cache
->setContentType('image/png')
->send($writer->writeString($text))
->send($qrcode->render($text))
;
}, ['response']);
@ -460,4 +456,4 @@ App::get('/v1/avatars/initials')
->setContentType('image/png')
->send($image->getImageBlob())
;
}, ['response', 'user']);
}, ['response', 'user']);

View file

@ -50,8 +50,8 @@
"dragonmantank/cron-expression": "3.0.1",
"domnikl/statsd": "3.0.*",
"influxdb/influxdb-php": "1.15.*",
"bacon/bacon-qr-code": "2.0.2",
"phpmailer/phpmailer": "6.1.7"
"phpmailer/phpmailer": "6.1.7",
"chillerlan/php-qrcode": "^4.2"
},
"require-dev": {
"swoole/ide-helper": "4.5.4",

121
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "9656df44d70d14709f83846019101927",
"content-hash": "6b4324f0371e508d691337551c00c74e",
"packages": [
{
"name": "appwrite/php-clamav",
@ -100,6 +100,125 @@
"homepage": "https://github.com/Bacon/BaconQrCode",
"time": "2020-07-30T16:40:58+00:00"
},
{
"name": "chillerlan/php-qrcode",
"version": "4.1.0",
"source": {
"type": "git",
"url": "https://github.com/chillerlan/php-qrcode.git",
"reference": "2cecb32cf618319dd01d9bc1fa64dc6bb683df85"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/2cecb32cf618319dd01d9bc1fa64dc6bb683df85",
"reference": "2cecb32cf618319dd01d9bc1fa64dc6bb683df85",
"shasum": ""
},
"require": {
"chillerlan/php-settings-container": "^2.0",
"ext-mbstring": "*",
"php": "^7.4"
},
"require-dev": {
"phan/phan": "^2.7",
"phpunit/phpunit": "^9.1",
"setasign/fpdf": "^1.8.2"
},
"suggest": {
"chillerlan/php-authenticator": "Yet another Google authenticator! Also creates URIs for mobile apps.",
"setasign/fpdf": "Required to use the QR FPDF output."
},
"type": "library",
"autoload": {
"psr-4": {
"chillerlan\\QRCode\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Kazuhiko Arase",
"homepage": "https://github.com/kazuhikoarase"
},
{
"name": "Smiley",
"email": "smiley@chillerlan.net",
"homepage": "https://github.com/codemasher"
},
{
"name": "Contributors",
"homepage": "https://github.com/chillerlan/php-qrcode/graphs/contributors"
}
],
"description": "A QR code generator. PHP 7.4+",
"homepage": "https://github.com/chillerlan/php-qrcode",
"keywords": [
"phpqrcode",
"qr",
"qr code",
"qrcode",
"qrcode-generator"
],
"funding": [
{
"url": "https://ko-fi.com/codemasher",
"type": "ko_fi"
}
],
"time": "2020-06-04T17:07:12+00:00"
},
{
"name": "chillerlan/php-settings-container",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/chillerlan/php-settings-container.git",
"reference": "75888345532373074fba482a6642c0f8cda996f0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/75888345532373074fba482a6642c0f8cda996f0",
"reference": "75888345532373074fba482a6642c0f8cda996f0",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^7.4"
},
"require-dev": {
"phan/phan": "^2.6",
"phpunit/phpunit": "^9.1"
},
"type": "library",
"autoload": {
"psr-4": {
"chillerlan\\Settings\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Smiley",
"email": "smiley@chillerlan.net",
"homepage": "https://github.com/codemasher"
}
],
"description": "A container class for immutable settings objects. Not a DI container. PHP 7.4+",
"homepage": "https://github.com/chillerlan/php-settings-container",
"keywords": [
"PHP7",
"Settings",
"container",
"helper"
],
"time": "2020-04-16T16:56:44+00:00"
},
{
"name": "colinmollenhour/credis",
"version": "v1.11.4",