npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qrcode-generator-sabai

v1.0.0

Published

qrcode-generator-sabai is a Node.js package designed to simplify QR code generation from various payloads to images. It offers ease of use and extensive customization options.

Downloads

23

Readme

qrcode-generator-sabai

npm version npm License

Overview

qrcode-generator-sabai is a Node.js package designed to simplify QR code generation from various payloads to images. It offers ease of use and extensive customization options.

Features

  • Generate QR Codes: Convert text, URLs, or any payload into QR codes effortlessly.
  • Customization: Tailor QR code attributes such as size, error correction level, and central logo placement to suit your needs.
  • Export Options: Export QR codes as PNG images, SVG strings, or Base64 encoded formats for versatile usage.

Installation

To install qrcode-generator-sabai, execute the following command in your terminal:

npm install qrcode-generator-sabai

Getting Started

Import the package into your Node.js project:

const QRCode = require('qrcode-generator-sabai');

Here's a basic example of generating a QR code:

PNG Format:

const QRCode = require('qr-code-sabai'); // Import the QRCode module

async function generateQRCode() {
    try {
        // Generate the QR code with the specified URL, size, and error correction level,
        // and convert it to PNG format
        const qrCode = await QRCode.generateQR(
            'https://github.com/iamlex01/qrcode-generator-sabai#readme', // URL or payload for the QR code
            400, // Size of the QR code in pixels
            "H" // Error correction level
        ).toPng(
            'qr-code.png', // Filename for the generated QR code image
            './public/images' // Directory path to save the generated QR code image
        );

        console.log('QR Code generated successfully:', qrCode);
    } catch (error) {
        console.error('Error generating QR Code:', error);
    }
}

generateQRCode(); // Call the async function to generate the QR code

SVG Format:

const QRCode = require('qrcode-generator-sabai'); // Import the QRCode module

async function generateQRCode() {
    try {
        // Generate the QR code with the specified URL, size, and error correction level,
        // and convert it to SVG format
        const qrCode = await QRCode.generateQR(
            'https://github.com/iamlex01/qrcode-generator-sabai#readme', // URL or payload for the QR code
            400, // Size of the QR code in pixels
            "H" // Error correction level
        ).toSvg();

        console.log('QR Code generated successfully:', qrCode);
    } catch (error) {
        console.error('Error generating QR Code:', error);
    }
}

generateQRCode(); // Call the async function to generate the QR code

Base64 Format:

const QRCode = require('qrcode-generator-sabai'); // Import the QRCode module

async function generateQRCode() {
    try {
        // Generate the QR code with the specified URL, size, and error correction level,
        // and convert it to Base64 format
        const qrCode = await QRCode.generateQR(
            'https://github.com/iamlex01/qrcode-generator-sabai#readme', // URL or payload for the QR code
            400, // Size of the QR code in pixels
            "H" // Error correction level
        ).toBase64();

        console.log('QR Code generated successfully:', qrCode);
    } catch (error) {
        console.error('Error generating QR Code:', error);
    }
}

generateQRCode(); // Call the async function to generate the QR code

Here's a basic example of generating a QR code with central logo placement:

QR Code with Central Logo (PNG Format):

const QRCode = require('qrcode-generator-sabai'); // Import the QRCode module

async function generateQRCode() {
    try {
        // Generate the QR code with the specified URL, size, and error correction level,
        // and embed a logo into the QR code
        const qrCode = await QRCode.generateQR(
            'https://github.com/iamlex01/qrcode-generator-sabai#readme', // URL or payload for the QR code
            400, // Size of the QR code in pixels
            "H" // Error correction level
        ).toImageWithLogo(
            'qr-code-with-logo.png', // Filename for the generated QR code image with logo
            './public/images', // Directory path to save the generated QR code image
            './path/to/logo.png', // Provide the path to your logo here
        );

        console.log('QR Code with logo generated successfully:', qrCode);
    } catch (error) {
        console.error('Error generating QR Code:', error);
    }
}

generateQRCode(); // Call the async function to generate the QR code

QR Code with Central Logo (Base64 Format):

const QRCode = require('qrcode-generator-sabai'); // Import the QRCode module

async function generateQRCode() {
    try {
        // Generate the QR code with the specified URL, size, and error correction level,
        // and embed a logo into the QR code
        const qrCode = await QRCode.generateQR(
            'https://github.com/iamlex01/qrcode-generator-sabai#readme', // URL or payload for the QR code
            400, // Size of the QR code in pixels
            "H" // Error correction level
        ).toImageWithLogo(
            './path/to/logo.png', // Provide the path to your logo here
        );

        console.log('QR Code with logo generated successfully:', qrCode);
    } catch (error) {
        console.error('Error generating QR Code:', error);
    }
}

generateQRCode(); // Call the async function to generate the QR code

Error Correction Level

Error correction capability allows QR codes to be scanned successfully even if the symbol is dirty or damaged. Four levels are available to choose from according to the operating environment.

Higher levels offer better error resistance but reduce the symbol's capacity. If the chances that the QR code symbol may be corrupted are low (for example, if it is displayed on a monitor), it is possible to safely use a low error level such as Low or Medium.

Possible levels are as follows:

| Level | Error Resistance | |-------------|------------------| | L (Low) | ~7% | | M (Medium) | ~15% | | Q (Quartile)| ~25% | | H (High) | ~30% |

The percentage indicates the maximum amount of damaged surface after which the symbol becomes unreadable.

License

qrcode-generator-sabai is licensed under the MIT License. Feel free to use and modify it according to your needs.