From f9bf2aa723d09a1735e773bd8765af926c7ee1f8 Mon Sep 17 00:00:00 2001 From: Thirumalai <98790479+mthirumalai2905@users.noreply.github.com> Date: Sat, 9 Mar 2024 15:21:43 +0530 Subject: [PATCH] Added How to save as a png We can save the qrcode generated in our local directory using fs --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 510e6b9f..d99457b4 100644 --- a/README.md +++ b/README.md @@ -352,6 +352,21 @@ QRCode.toFile( TypeScript users: if you are using [@types/qrcode](https://www.npmjs.com/package/@types/qrcode), you will need to add a `// @ts-ignore` above the data segment because it expects `data: string`. +## How To Save The QRcode as a PNG to your local Directory +```javascript +const QRCode = require('qrcode'); +const fs = require('fs'); + +//The png is hence generated and stored under the images directory +QRCode.toFile('./images/qrcode.png', 'I am a pony!', function (err, url) { + if (err) { + console.error(err); + return; + } + console.log('QR code image saved as qrcode.png'); +}); +``` + ## Multibyte characters Support for multibyte characters isn't present in the initial QR Code standard, but is possible to encode UTF-8 characters in Byte mode.