Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

qreator

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qreator

QR Code generator for browser and node.js with tree shaking and logo support

  • 9.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
457
decreased by-16.91%
Maintainers
1
Weekly downloads
 
Created
Source

qreator

npm version

QR Code generator for browser and node.js with tree shaking and logo support

image

Overview

  • generate image in png, svg and pdf formats
  • numeric and alphanumeric modes
  • support UTF-8
  • supports color customization
  • supports logos
  • tree shaking support
  • browser / node.js

Releases

Installing

npm install qreator
# or
yarn add qreator

Usage

Example:

import { getSVG } from "qreator/lib/svg";
import { getPNG } from "qreator/lib/png"; // imports canvas implementation in browser and sharp module in node.js
import { getPDF } from "qreator/lib/pdf"; // this import is large, consider async import
const svgString = await getSVG("I love QR", {
    logo: fs.openFileSync("my-logo.svg"),
    color: "#000000",
    bgColor: "#FFFFFF",
});
const pngBuffer = await getPNG("I love QR", {
    logo: fs.openFileSync("my-logo.svg"),
    color: "rgb(0, 0, 0)",
    bgColor: "rgb(255, 255, 255)",
});

More examples

Syntax

  • getPNG(text, [options]): Readable stream with image data.
  • getSVG(text, [options]): Readable stream with image data.
  • getPDF(text, [options]): Readable stream with image data.

Options

  • text: text to encode
  • options: additional image options object
Additional Options
NameDescriptionTypePossible ValuesDefault
ec_levelerror correction levelstringL, M, Q, HM
typeimage typestringpng, svg, pdfpng
sizepng and svg only
size of one module in pixels
number0 - n5 (png)
0 (others)
marginwhite space around QR image in modulesnumber0 - n4 (png)
1 (others)
parse_urlEXPERIMENTAL
try to optimize QR-code for URLs
booleantrue, falsefalse
logobuffer with png/jpeg imageArrayBuffer-undefined
logoWidthheight of logo in percentnumber0 - 10020
logoHeightwidth of logo in percentnumber0 - 10020
colormodule color in rgba or hex formatnumber#000000 - #000000#000000
(black with 100% opacity)
bgColorbackground color in rgba or hex formatnumber#000000 - #FFFFFF#FFFFFF
(white with 100% opacity)
borderRadiusborder-radius (in pixels)number0 - size / 20

Benchmarks

getPNG x 229 ops/sec ±0.45% (84 runs sampled)
getPDF x 186 ops/sec ±24.91% (86 runs sampled)
getSVG x 2,482 ops/sec ±0.18% (90 runs sampled)
getPNG with logo x 69.96 ops/sec ±0.72% (68 runs sampled)
getPDF with logo x 44.83 ops/sec ±9.52% (77 runs sampled)
getSVG with logo x 2,494 ops/sec ±0.19% (88 runs sampled)

TODO

  • Use lighter versions of PDF library
  • Background

Keywords

FAQs

Package last updated on 05 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc