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

qrean

v0.1.0

Published

A portable QR and Barcode generation / manipulation library written in C

Downloads

34

Readme

QR and Barcode library libqrean

What's this?

A portable QR and Barcode generation / manipulation library written in C.

animation rmqr-animation

DEMO

Wasm (thanks @taisukef)

CLI Usage

Generation

% qrean -t rmqr Hello
███████████████████████████████
██ ▄▄▄▄▄ █ ▀ █ █ █▄█ █▄█▄█▄▄ ██
██ █   █ ██▄ ▄█▀▄▄  ▄▄   ▀█ ▄██
██ █▄▄▄█ ██▀▀▀▄█▄▄█▀█▄   █▀▀▄██
██▄▄▄▄▄▄▄█▄██ ▄ ▀▄█▀▀█▀▄ ▄▄▄ ██
██ ▄▀▀ ▀▄ ▄█▄███▀▀▄▄▀▄▀▄ █▄█ ██
██▄▄▄█▄█▄█▄█▄█▄█▄█▄█▄█▄█▄▄▄▄▄██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
% qrean -t mQR Hello > mqr.png     # CAVEAT: Outputs PNG stream for not a tty
% qrean -o qr.png Hello            # You can also specify output filename
% qrean -h
Usage: qrean [OPTION]... [STRING]
Generate QR/Barcode image

  General options:
    -h                Display this help
    -o FILENAME       Image save as FILENAME
    -i FILENAME       Data read from FILENAME
    -f FORMAT         Output format, one of the following:
                          TXT    (default for tty)
                          PNG    (default for non tty)
                          PPM
    -t CODE           Output CODE, one of the following:
                          QR, mQR, rMQR, tQR
                          EAN13, EAN8, UPCA
                          CODE39, CODE93
                          ITF, NW7
    -p PADDING        Comma-separated PADDING for the code

  QR family specific options:
    -v VERSION        Use VERSION, one of the following:
                          1 ... 40           (for QR)
                          M1 ... M4          (for mQR)
                          R7x43 ... R17x139  (for rMQR)
                            R{H}x{W}
                              H: 7, 9, 11, 13, 15, 17
                              W: 43, 59, 77, 99, 139
                          tQR                (for tQR)
    -m MASK           Use MASK pattern, one of the following:
                          0 ... 7            (for QR)
                          0 ... 4            (for mQR)
    -l LEVEL          Use ecc LEVEL, one of the following:
                          L, M, Q, H         (for QR)
                          L, M, Q            (for mQR)
                             M,    H         (for rMQR)

Detection

% qrean-detect qr.png   # The source file must be a PNG file so far
Hello
%

Library Usage

qrean_t qrean = create_qrean(QREAN_CODE_TYPE_QR);
qrean_write_string(&qrean, "Hello, world", QREAN_DATA_TYPE_AUTO);

size_t len = qrean_read_bitmap(&qrean, buffer, sizeof(buffer), 8);
fwrite(buffer, 1, len, stdout);
qrean_write_pixel(&qrean, qrean.canvas.symbol_width - 1, qrean.canvas.symbol_height - 1, 0);
qrean_fix_errors(&qrean);

qrean_read_string(&qrean, buffer, sizeof(buffer));
printf("%s\n", buffer);
qrean_t *qrean = new_qrean(QREAN_CODE_TYPE_QR);
qrean_set_qr_version(qrean, QR_VERSION_3);
qrean_set_qr_errorlevel(qrean, QR_ERRORLEVEL_M);
qrean_set_qr_maskpattern(qrean, QR_MASKPATTERN_7);

qrean_write_qr_finder_pattern(qrean);
qrean_write_qr_alignment_pattern(qrean);
qrean_write_qr_timing_pattern(qrean);
qrean_write_qr_format_info(qrean);
qrean_write_qr_version_info(qrean);

See examples/ directory for working examples.

JavaScript / TypeScript Usage (Powered by Wasm)

import { Qrean } from 'qrean';

const qrean = new Qrean();
const img = await qrean.encode('Hello, world');
console.log(img);
// {
//   width: 116,
//   height: 116,
//   data: Uint8ClampedArray(53824) [
//    :

const { detected } = await qrean.detect(img);
console.log(detected[0].text);
// Hello, world

It requires Wasm to run, but don't worry, most engines support it; Node, Deno, Bun and browsers.

Install

As a CLI

  • Windows
  • UNIX-like systems (Linux / macOS / *BSD)
    • Just make install

As a JavaScript / TypeScript library

% npm install qrean

As a C library for embedded systems

Take a look at src/ and include (or copy) them!

Why?

As you can see, you can take control. I love QR and Barcodes.

The core (encode/decode) doesn't rely on malloc() for portability. It uses a stack instead of a heap, but you can still use new_qrean for example if you prefer.

You can also configure a callback to draw a pixel directly on a screen for example.

Supported codes

| type | encode | decode | detect |---------------------|--------|--------|----------- | QR | ✓ | ✓ | ✓ | mQR | ✓ | ✓ | ✓ | rMQR | ✓ | ✓ | ✓ | tQR | ✓ | ✓ | ✓ | UPCA / EAN13 / EAN8 | ✓ | ✓ | ✓ | CODE39 | ✓ | ✓ | ✓ | CODE93 | ✓ | ✓ | ✓ | NW7 | ✓ | ✓ | ✓ | ITF | ✓ | ✓ | ✓