kazuhikoarase / qrcode-generator

QR Code Generator implementation in JavaScript, Java and more.
https://kazuhikoarase.github.io/qrcode-generator/js/demo/
MIT License
2.1k stars 674 forks source link

Add support to generate PNG Image #84

Open almcken opened 4 years ago

almcken commented 4 years ago

Hello. I think it would be a nice feature to able to generate a PNG image.

mghignet commented 4 years ago

That would be awesome! Thanks for your work on this lib. đź‘Ť

ygoe commented 3 years ago

If you're using the JavaScript library and you're okay with using an HTML5 <canvas> for that, you can do that with the renderTo2dContext function. See my new sample page in PR #91. Direct generation of the PNG binary data is another thing…

JBES commented 3 years ago

PHP: qrcode.php

static function createPNG($text='',$filename='',$size,$margin,$ec=QR_ERROR_CORRECT_LEVEL_L){
$qr=QRCode::getMinimumQRCode($text,$ec);
$im=$qr->createImage($size,$margin);
imagepng($im,$filename);
imagedestroy($im);
}