Replies: 2 comments 6 replies
-
Hey,
This is completely up to you. the scale just defines the size of one QR Code pixel (module as per spec). you can use the scale like you suggested to get near the desired image size. Alternatively, you could resize the final image, in which case you may set scale that the generated QR Code is larger, e.g. 1.5x the size of the final resized output.
No, it is not, because the logo space uses up a lot of the error correction bits and the QR Code may become unreadable. However, I've suggested in another thread to add an option to manually adjust this threshold.
Also, i see that you're manually decoding the base64 output to save it to a file. this is not necessary. You can just set |
Beta Was this translation helpful? Give feedback.
-
Hi Codesmasher, I highly appreciate your prompt replies, we tried this with your normal library downloaded through composer and it says that GDImage script is missing. Do you know any reason for this? Thanks! |
Beta Was this translation helpful? Give feedback.
-
Kindly would like to request some answers to the following.
Does it make sense to use an absolute pixel size when combining front and background colors or transparency with a logo with Logospace around it? or does it create better quality to "scale" a little bit OVER 2046 Pixels and then use it in this size?
Is there a possibility to use Errorlevel Q with a logo with logo space?
is it possible to generate an output image with dynamic width & height? We have tried to this extended function called “LogoOptions” and unfortunately, it's not working. Hence, Could you please advise us if is there any solution you had to this issue?
My Index File:
require_once('./../vendor/autoload.php');
include 'separateData.php';
$data = $prefix_url;
$options = new LogoOptions(
[
'eccLevel' => QRCode::ECC_H,
'imageBase64' => true,
'logoSpaceHeight' => 12,
'logoSpaceWidth' => 12,
// 'scale' => 10,
'qrCodeHeight' => 500,
'qrCodeWidth' => 500,
'version' => 7,
'outputType' => QRCode::OUTPUT_IMAGE_PNG,
'moduleValues' => $qrCodeOptions,
]
);
$qrOutputInterface = new QRImageWithLogo(
$options,
(new QRCode($options))->getMatrix($data)
);
$qrCode = $qrOutputInterface->dump(
null,
DIR.'/../public/img/'.$logo.'.png'
);
$qrCode = str_replace('data:image/svg;base64,', '', $qrCode);
$qrCode = str_replace(' ', '+', $qrCode);
$qrCode = base64_decode($qrCode);
$qrCode = imagecreatefromstring($qrCode);
$qrCode = imagepng($qrCode, DIR.'/../public/cache/'.$logo.'.png');
Extended LogoOptions file:
declare(strict_types=1);
namespace App\QR\Options;
use chillerlan\QRCode\QROptions;
class LogoOptions extends QROptions
{
// size in QR modules, multiply with QROptions::$scale for pixel size
protected int $logoSpaceWidth;
protected int $logoSpaceHeight;
// additional options for logo
protected int $qrCodeHeight;
protected int $qrCodeWidth;
public function __construct(array $options = [])
{
parent::__construct($options);
$this->logoWidth = $options['logoWidth'] ?? 0;
$this->logoHeight = $options['logoHeight'] ?? 0;
$this->qrCodeWidth = $options['qrCodeWidth'] ?? 0;
$this->qrCodeHeight = $options['qrCodeHeight'] ?? 0;
}
public function getLogoWidth(): int
{
return $this->logoWidth;
}
public function getLogoHeight(): int
{
return $this->logoHeight;
}
public function getQrCodeWidth(): int
{
return $this->qrCodeWidth;
}
public function getQrCodeHeight(): int
{
return $this->qrCodeHeight;
}
}
Beta Was this translation helpful? Give feedback.
All reactions