Generate a QR code as SVG from text
{ } EncodeGenerate a QR code for a URL
$ echo "https://pipr.tools" | qr-encode async (input, opts = {}) => {
if (!input.trim()) return "";
try {
const qrOpts = {
type: "svg",
errorCorrectionLevel: opts.ecl || "M",
margin: parseInt(opts.margin) || 4,
};
const w = parseInt(opts.width);
if (w > 0) qrOpts.width = w;
return await QRCode.toString(input, qrOpts);
} catch (e) {
return `Error: ${e.message}`;
}
}