endroid / qr-code

QR Code Generator
https://endroid.nl
MIT License
4.46k stars 728 forks source link

qrcode image can't parse string, when i add a logo #216

Closed guihouchang closed 5 years ago

guihouchang commented 5 years ago

image

$qrCode = new QrCode(SHARE_URL . '?inviteCode=' . $userInfo->getInvitCode());
            $iconPath = $this->config->resource->commonDir . '/icon.png';
            $qrCode->setLogoPath($iconPath);
            $qrCode->setLogoSize(100, 100);
            $inviteCode = $userInfo->getInvitCode();
            util::mkdirs($qrCodeDir);
            $qrCode->setRoundBlockSize(true);
            $qrCode->setWriterOptions(['exclude_xml_declaration' => true]);
            $qrCode->writeFile($qrCodeDir . $inviteCode . '.png');
endroid commented 5 years ago

Hi @guihouchang what is the exact error message?

guihouchang commented 5 years ago

No exact error messages I think the size of the logo is too large, covering the qr code

endroid commented 5 years ago

Ah ok, that is a possibility of course. If the logo is too big it will wreck your code ;) You can use the built-in validator to see if the QR code is readable and experiment with different error correction level / sizes, but in general adding a logo will make your code less readable.