{"id":30596353,"url":"https://github.com/jaredwray/qrbit","last_synced_at":"2026-02-23T10:17:34.952Z","repository":{"id":312200838,"uuid":"1046650117","full_name":"jaredwray/qrbit","owner":"jaredwray","description":"QR Code Generating for Javascript","archived":false,"fork":false,"pushed_at":"2025-08-29T03:47:28.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-29T07:34:33.237Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaredwray.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-29T02:29:19.000Z","updated_at":"2025-08-29T03:47:31.000Z","dependencies_parsed_at":"2025-08-29T07:44:37.229Z","dependency_job_id":null,"html_url":"https://github.com/jaredwray/qrbit","commit_stats":null,"previous_names":["jaredwray/qrbit"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/jaredwray/qrbit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredwray%2Fqrbit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredwray%2Fqrbit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredwray%2Fqrbit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredwray%2Fqrbit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredwray","download_url":"https://codeload.github.com/jaredwray/qrbit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredwray%2Fqrbit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272767113,"owners_count":24989436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-29T21:42:24.956Z","updated_at":"2026-02-23T10:17:34.939Z","avatar_url":"https://github.com/jaredwray.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\u003cimg src=\"./site/logo.svg\" alt=\"QrBit Logo\" /\u003e\u003c/div\u003e\n\n# Qrbit\n\n[![codecov](https://codecov.io/gh/jaredwray/qrbit/graph/badge.svg?token=VEUXLsudSh)](https://codecov.io/gh/jaredwray/qrbit)\n[![tests](https://github.com/jaredwray/qrbit/actions/workflows/tests.yml/badge.svg)](https://github.com/jaredwray/qrbit/actions/workflows/tests.yml)\n[![npm](https://img.shields.io/npm/v/qrbit)](https://www.npmjs.com/package/qrbit)\n[![npm](https://img.shields.io/npm/dm/qrbit)](https://www.npmjs.com/package/qrbit)\n[![license](https://img.shields.io/github/license/jaredwray/qrbit)](https://github.com/jaredwray/qrbit/blob/main/LICENSE)\n\nA fast QR code generator with logo embedding support, built with Rust and native node packages for best performance while avoiding additional modules (example: canvas).\n\n# Features\n\n- **Fast**: Built with Rust (for logos) for maximum performance and caching 🚀\n- **Fast SVG**: High performance SVG support via `QrCode` when no logo is needed\n- **Cross-platform**: Works on iOS, Windows, Linux, and macOS\n- **Logo embedding**: Add custom logos to your QR codes with no need for node canvas!\n- **Error correction**: Configurable error correction levels (L, M, Q, H)\n- **Customizable**: Custom colors, sizes, and margins\n- **Multiple formats**: Generate SVG, PNG, JPEG, and WebP outputs\n- **Scalable**: With caching you can also use a secondary store for persistence\n- **Well-tested**: Comprehensive test coverage with Vitest\n- **Maintained**: Actively maintained with regular updates\n\n# Table of Contents\n- [Installation](#installation)\n- [Requirements](#requirements)\n- [API](#api)\n  - [Constructor](#constructoroptions-qroptions)\n  - [Properties](#properties)\n    - [text](#text)\n    - [size](#size)\n    - [margin](#margin)\n    - [logo](#logo)\n    - [logoSizeRatio](#logosizeratio)\n    - [backgroundColor](#backgroundcolor)\n    - [foregroundColor](#foregroundcolor)\n    - [errorCorrection](#errorcorrection)\n    - [cache](#cache)\n  - [Methods](#methods)\n    - [.toSvg()](#tosvgoptions-tooptions)\n    - [.toSvgNapi()](#tosvgnapi)\n    - [.toSvgFile()](#tosvgfilefilepath-string-options-tooptions)\n    - [.toPng()](#topngoptions-tooptions)\n    - [.toPngFile()](#topngfilefilepath-string-options-tooptions)\n    - [.toJpg()](#tojpgoptions-tooptions)\n    - [.toJpgFile()](#tojpgfilefilepath-string-options-tooptions)\n    - [.toWebp()](#towebpoptions-tooptions)\n    - [.toWebpFile()](#towebpfilefilepath-string-options-tooptions)\n    - [Utility Methods](#utility-methods)\n    - [Static Methods](#static-methods)\n- [Benchmarks](#benchmarks)\n- [Examples](#examples)\n- [Contributing](#contributing)\n- [License and Copyright](#license-and-copyright)\n\n# Installation\n\n```bash\nnpm install qrbit\n```\n\n# Requirements\n\n- Node.js \u003e= 18\n- Supported platforms: Windows (x86, x64), macOS (Arm, Intel), Linux (x64)\n\n# Usage\n\n```javascript\nconst qr = new QrBit({ text: \"https://github.com/jaredwray/qrbit\", size: 200 });\nconst svg = await qr.toSvg();\nconsole.log(svg); // here is the svg!\n```\n\nHere is how you add a logo:\n\n```javascript\nconst qr = new QrBit({ \n  text: \"https://github.com/jaredwray/qrbit\", \n  logo: '/path/to/logo.png',\n  size: 200 });\nconst svg = await qr.toSvg();\nconsole.log(svg); // here is the svg with an embedded logo!\n```\n\n```javascript\nconst qr = new QrBit({ \n  text: \"https://github.com/jaredwray/qrbit\", \n  logo: '/path/to/logo.png',\n  size: 200 });\nconst png = await qr.toPng(); // buffer of the png!\n```\n\n# API\n\n## constructor(options: QrOptions)\n\nCreates a new QrBit instance with the specified options.\n\n**Parameters:**\n- `options` (QrOptions): Configuration object for the QR code\n\n```typescript\ninterface QrOptions {\n  text: string;                    // The text content to encode\n  size?: number;                   // Size in pixels (default: 200)\n  margin?: number;                 // Margin in pixels (default: undefined)\n  logo?: string | Buffer;          // Logo file path or buffer\n  logoSizeRatio?: number;          // Logo size ratio (default: 0.2)\n  backgroundColor?: string;        // Background color (default: \"#FFFFFF\")\n  foregroundColor?: string;        // Foreground color (default: \"#000000\")\n  errorCorrection?: ECLevel;       // \"L\"|\"M\"|\"Q\"|\"H\"|\"Low\"|\"Medium\"|\"Quartile\"|\"High\" (default: \"M\")\n  cache?: Cacheable | boolean;     // Caching configuration (default: true)\n}\n\ninterface toOptions {\n  cache?: boolean;                 // Enable/disable caching (default: true)\n  quality?: number;                // Quality 1-100 (default: 90) - for toJpg; reserved for toWebp\n}\n```\n\n**Example:**\n```javascript\nimport { QrBit } from 'qrbit';\n\nconst qr = new QrBit({\n  text: \"https://github.com/jaredwray/qrbit\",\n  size: 300,\n  margin: 20,\n  logo: \"./logo.png\",\n  logoSizeRatio: 0.25,\n  backgroundColor: \"#FFFFFF\",\n  foregroundColor: \"#000000\",\n  errorCorrection: \"H\"\n});\n```\n\n## Properties\n\n### text\nGet or set the text content for the QR code.\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nconsole.log(qr.text); // \"Hello World\"\nqr.text = \"New content\";\n```\n\n### size\nGet or set the size of the QR code in pixels.\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nconsole.log(qr.size); // 200 (default)\nqr.size = 400;\n```\n\n### margin\nGet or set the margin around the QR code in pixels.\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nconsole.log(qr.margin); // undefined (default)\nqr.margin = 20;\n```\n\n### logo\nGet or set the logo as a file path or buffer.\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nqr.logo = \"./path/to/logo.png\";\n// or\nqr.logo = fs.readFileSync(\"./logo.png\");\n```\n\n### logoSizeRatio\nGet or set the logo size ratio relative to QR code size (0.0 to 1.0).\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nqr.logoSizeRatio = 0.3; // 30% of QR code size\n```\n\n### backgroundColor\nGet or set the background color in hex format.\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nqr.backgroundColor = \"#FF0000\"; // Red background\n```\n\n### foregroundColor\nGet or set the foreground color in hex format.\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nqr.foregroundColor = \"#FFFFFF\"; // White foreground\n```\n\n### errorCorrection\nGet or set the error correction level. Higher levels recover more damage but produce denser codes.\n\nAccepts initials or full names:\n- `\"L\"` / `\"Low\"` — Low (~7% recovery)\n- `\"M\"` / `\"Medium\"` — Medium (~15% recovery, default)\n- `\"Q\"` / `\"Quartile\"` — Quartile (~25% recovery)\n- `\"H\"` / `\"High\"` — High (~30% recovery, recommended when using logos)\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nqr.errorCorrection = \"H\";\nqr.errorCorrection = \"High\"; // equivalent\n```\n\n### cache\nGet or set the cache instance for performance optimization.\n\n```javascript\nimport { Cacheable } from 'cacheable';\n\nconst qr = new QrBit({ text: \"Hello World\" });\nqr.cache = new Cacheable(); // Custom cache instance\nqr.cache = false; // Disable caching\n```\n\n## Methods\n\n### .toSvg(options?: toOptions)\n\nGenerate SVG QR code with optional caching. Uses native QRCode library for simple cases, Rust implementation for logos.\n\n**Parameters:**\n- `options.cache?: boolean` - Whether to use caching (default: true)\n\n**Returns:** Promise\u003cstring\u003e - The SVG string\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nconst svg = await qr.toSvg();\nconsole.log(svg); // \u003csvg xmlns=\"http://www.w3.org/2000/svg\"...\n\n// Without caching\nconst svgNoCache = await qr.toSvg({ cache: false });\n```\n\n### .toSvgNapi()\n\nGenerate SVG QR code using the native Rust implementation directly. Automatically selects between file path and buffer logo functions. If a logo file path doesn't exist, a `QrBitEvents.error` event is emitted.\n\n\u003e **Note:** By default (`throwOnEmitError = true`), emitting an error with no registered listener will **throw** rather than fall back to generating the SVG without a logo. To handle the error and still receive the SVG, register an error listener before calling this method.\n\n**Returns:** Promise\\\u003cstring\\\u003e - The SVG string\n\n```javascript\n// Default behavior – throws if logo file is missing and no error listener is registered\nconst qr = new QrBit({ text: \"Hello World\", logo: \"./logo.png\" });\nconst svg = await qr.toSvgNapi();\nconsole.log(svg); // \u003csvg xmlns=\"http://www.w3.org/2000/svg\"...\n\n// To fall back gracefully, register an error listener first\nqr.on(\"error\", (err) =\u003e console.warn(\"Logo not found:\", err));\nconst svgFallback = await qr.toSvgNapi(); // generates SVG without logo\n```\n\n### .toSvgFile(filePath: string, options?: toOptions)\n\nGenerate SVG QR code and save it to a file. Creates directories if they don't exist.\n\n**Parameters:**\n- `filePath: string` - The file path where to save the SVG\n- `options.cache?: boolean` - Whether to use caching (default: true)\n\n**Returns:** Promise\u003cvoid\u003e\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nawait qr.toSvgFile(\"./output/qr-code.svg\");\n\n// With options\nawait qr.toSvgFile(\"./output/qr-code.svg\", { cache: false });\n```\n\n### .toPng(options?: toOptions)\n\nGenerate PNG QR code with optional caching. Uses high-performance SVG to PNG conversion.\n\n**Parameters:**\n- `options.cache?: boolean` - Whether to use caching (default: true)\n\n**Returns:** Promise\u003cBuffer\u003e - The PNG buffer\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nconst pngBuffer = await qr.toPng();\n\n// Save to file\nfs.writeFileSync(\"qr-code.png\", pngBuffer);\n\n// Without caching\nconst pngNoCache = await qr.toPng({ cache: false });\n```\n\n### .toPngFile(filePath: string, options?: toOptions)\n\nGenerate PNG QR code and save it to a file. Creates directories if they don't exist.\n\n**Parameters:**\n- `filePath: string` - The file path where to save the PNG\n- `options.cache?: boolean` - Whether to use caching (default: true)\n\n**Returns:** Promise\u003cvoid\u003e\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nawait qr.toPngFile(\"./output/qr-code.png\");\n\n// With options\nawait qr.toPngFile(\"./output/qr-code.png\", { cache: false });\n```\n\n### .toJpg(options?: toOptions)\n\nGenerate JPEG QR code with optional caching and quality control. Uses high-performance SVG to JPEG conversion.\n\n**Parameters:**\n- `options.cache?: boolean` - Whether to use caching (default: true)\n- `options.quality?: number` - JPEG quality from 1-100 (default: 90)\n\n**Returns:** Promise\u003cBuffer\u003e - The JPEG buffer\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nconst jpgBuffer = await qr.toJpg();\n\n// With high quality\nconst jpgHigh = await qr.toJpg({ quality: 95 });\n\n// With compression for smaller file size\nconst jpgCompressed = await qr.toJpg({ quality: 70 });\n\n// Save to file\nfs.writeFileSync(\"qr-code.jpg\", jpgBuffer);\n\n// Without caching\nconst jpgNoCache = await qr.toJpg({ cache: false, quality: 85 });\n```\n\n### .toJpgFile(filePath: string, options?: toOptions)\n\nGenerate JPEG QR code and save it to a file. Creates directories if they don't exist.\n\n**Parameters:**\n- `filePath: string` - The file path where to save the JPEG\n- `options.cache?: boolean` - Whether to use caching (default: true)\n- `options.quality?: number` - JPEG quality from 1-100 (default: 90)\n\n**Returns:** Promise\u003cvoid\u003e\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nawait qr.toJpgFile(\"./output/qr-code.jpg\");\n\n// With high quality\nawait qr.toJpgFile(\"./output/qr-code.jpg\", { quality: 95 });\n\n// With compression\nawait qr.toJpgFile(\"./output/qr-code.jpg\", { quality: 70, cache: false });\n```\n\n### .toWebp(options?: toOptions)\n\nGenerate WebP QR code with optional caching. Uses high-performance SVG to WebP conversion with lossless encoding.\n\n**Parameters:**\n- `options.cache?: boolean` - Whether to use caching (default: true)\n- `options.quality?: number` - Reserved for future lossy WebP support\n\n**Returns:** Promise\u003cBuffer\u003e - The WebP buffer\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nconst webpBuffer = await qr.toWebp();\n\n// Save to file\nfs.writeFileSync(\"qr-code.webp\", webpBuffer);\n\n// Without caching\nconst webpNoCache = await qr.toWebp({ cache: false });\n```\n\n### .toWebpFile(filePath: string, options?: toOptions)\n\nGenerate WebP QR code and save it to a file. Creates directories if they don't exist.\n\n**Parameters:**\n- `filePath: string` - The file path where to save the WebP\n- `options.cache?: boolean` - Whether to use caching (default: true)\n- `options.quality?: number` - Reserved for future lossy WebP support\n\n**Returns:** Promise\u003cvoid\u003e\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nawait qr.toWebpFile(\"./output/qr-code.webp\");\n\n// With options\nawait qr.toWebpFile(\"./output/qr-code.webp\", { cache: false });\n```\n\n### Utility Methods\n\n#### .generateCacheKey(renderKey: string)\n\nGenerate a hash-based cache key from the current QR code options. Useful for custom caching strategies.\n\n**Parameters:**\n- `renderKey: string` - Format identifier (e.g., `napi-png`, `native-svg`, `napi-svg`)\n\n**Returns:** Promise\\\u003cstring\\\u003e - The hash string\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nconst key = await qr.generateCacheKey(\"napi-png\");\nconsole.log(key); // hash string based on current options\n```\n\n#### .isLogoString()\n\nCheck if the logo property is a string (file path) rather than a Buffer.\n\n**Returns:** boolean - `true` if logo is a string, `false` otherwise\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\", logo: \"./logo.png\" });\nconsole.log(qr.isLogoString()); // true\n\nqr.logo = fs.readFileSync(\"./logo.png\");\nconsole.log(qr.isLogoString()); // false\n```\n\n#### .logoFileExists(filePath: string)\n\nCheck if a file exists at the specified path.\n\n**Parameters:**\n- `filePath: string` - The file path to check\n\n**Returns:** Promise\\\u003cboolean\\\u003e - `true` if file exists and is accessible, `false` otherwise\n\n```javascript\nconst qr = new QrBit({ text: \"Hello World\" });\nconst exists = await qr.logoFileExists(\"./logo.png\");\nconsole.log(exists); // true or false\n```\n\n### Static Methods\n\n#### QrBit.convertSvgToPng(svgContent: string, width?: number, height?: number)\n\nConvert SVG content to PNG buffer using the native Rust implementation.\n\n**Parameters:**\n- `svgContent: string` - The SVG content as a string\n- `width?: number` - Optional width for the PNG output\n- `height?: number` - Optional height for the PNG output\n\n**Returns:** Buffer - The PNG buffer\n\n```javascript\nconst svg = '\u003csvg\u003e...\u003c/svg\u003e';\nconst pngBuffer = QrBit.convertSvgToPng(svg, 400, 400);\n```\n\n#### QrBit.convertSvgToJpeg(svgContent: string, width?: number, height?: number, quality?: number)\n\nConvert SVG content to JPEG buffer using the native Rust implementation.\n\n**Parameters:**\n- `svgContent: string` - The SVG content as a string\n- `width?: number` - Optional width for the JPEG output\n- `height?: number` - Optional height for the JPEG output\n- `quality?: number` - JPEG quality from 1-100 (default: 90)\n\n**Returns:** Buffer - The JPEG buffer\n\n```javascript\nconst svg = '\u003csvg\u003e...\u003c/svg\u003e';\nconst jpegBuffer = QrBit.convertSvgToJpeg(svg, 400, 400, 85);\n```\n\n#### QrBit.convertSvgToWebp(svgContent: string, width?: number, height?: number, quality?: number)\n\nConvert SVG content to WebP buffer using the native Rust implementation with lossless encoding.\n\n**Parameters:**\n- `svgContent: string` - The SVG content as a string\n- `width?: number` - Optional width for the WebP output\n- `height?: number` - Optional height for the WebP output\n- `quality?: number` - Reserved for future lossy WebP support\n\n**Returns:** Buffer - The WebP buffer\n\n```javascript\nconst svg = '\u003csvg\u003e...\u003c/svg\u003e';\nconst webpBuffer = QrBit.convertSvgToWebp(svg, 400, 400);\n```\n\n# Benchmarks\n\n## QR Codes SVG (No Logo)\n|                  name                   |  summary  |  ops/sec  |  time/op  |  margin  |  samples  |\n|-----------------------------------------|:---------:|----------:|----------:|:--------:|----------:|\n|  QRCode toString (v1.5.4)               |    🥇     |       6K  |    162µs  |  ±0.37%  |       6K  |\n|  QrBit toSvg (Native) (v1.0.0)          |   -3.2%   |       6K  |    172µs  |  ±0.92%  |       6K  |\n|  QrBit toSvg (Rust) (v1.0.0)            |   -85%    |     945   |      1ms  |  ±1.17%  |     912   |\n|  styled-qr-code-node toBuffer (v1.5.2)  |   -89%    |     709   |      1ms  |  ±1.07%  |     701   |\n\n`Rust` is there for performance and when doing heavy image processing without needing node `canvas` installed. If you do not add a logo then the `Native` version is what you will get for SVG. \n\n## QR Codes PNG (No Logo)\n|                  name                   |  summary  |  ops/sec  |  time/op  |  margin   |  samples  |\n|-----------------------------------------|:---------:|----------:|----------:|:---------:|----------:|\n|  QrBit toPng (v1.4.0) Cached            |    🥇     |       6K  |      1ms  |  ±12.19%  |     992   |\n|  QrBit toPng (v1.4.0)                   |   -52%    |       3K  |      1ms  |  ±16.23%  |     899   |\n|  QRCode toBuffer (v1.5.4)               |   -92%    |     437   |      2ms  |  ±1.23%   |     428   |\n|  styled-qr-code-node toBuffer (v1.5.2)  |   -98%    |     141   |      7ms  |  ±0.82%   |     141   |\n\n## QR Codes JPG (No Logo)\n|                  name                   |  summary  |  ops/sec  |  time/op  |  margin   |  samples  |\n|-----------------------------------------|:---------:|----------:|----------:|:---------:|----------:|\n|  QrBit toJpg (v1.4.0)                   |    🥇     |       1K  |      3ms  |  ±32.99%  |     372   |\n|  QrBit toJpg (v1.4.0) Cached            |   -19%    |   1,000   |      3ms  |  ±36.82%  |     367   |\n|  styled-qr-code-node toBuffer (v1.5.2)  |   -78%    |     269   |      4ms  |  ±1.13%   |     266   |\n\n## QR Codes WebP (No Logo)\n|              name              |  summary  |  ops/sec  |  time/op  |  margin   |  samples  |\n|--------------------------------|:---------:|----------:|----------:|:---------:|----------:|\n|  QrBit toWebp Cached (v1.4.0)  |    🥇     |       7K  |    911µs  |  ±11.27%  |       1K  |\n|  QrBit toWebp (v1.4.0)         |   -44%    |       4K  |    998µs  |  ±14.47%  |       1K  |\n\n`Rust` is used for `toPng()`, `toJpg()`, and `toWebp()` to optimize performance for image generation and heavy image processing without needing node `canvas` installed.\n\n## QR Codes with Embedded Logos\n|                name                |  summary  |  ops/sec  |  time/op  |  margin  |  samples  |\n|------------------------------------|:---------:|----------:|----------:|:--------:|----------:|\n|  QrBit SVG (Path) (v1.0.0)         |    🥇     |     819   |      1ms  |  ±1.04%  |     794   |\n|  QrBit SVG (Buffer) (v1.0.0)       |   -58%    |     341   |      3ms  |  ±1.08%  |     339   |\n|  QrBit PNG (Path) (v1.0.0)         |   -61%    |     319   |      3ms  |  ±1.95%  |     314   |\n|  styled-qr-code-node PNG (v1.5.2)  |   -81%    |     159   |      6ms  |  ±0.75%  |     159   |\n|  QrBit PNG (Buffer) (v1.0.0)       |   -81%    |     154   |      7ms  |  ±1.05%  |     154   |\n|  styled-qr-code-node SVG (v1.5.2)  |   -84%    |     134   |      7ms  |  ±0.59%  |     135   |\n\n`Buffer` is much slower as we have to push the stream across to the rust module. For fastest performance provide the path of the image.\n\n# Examples\n\nThe `examples/` directory contains various QR code examples showcasing different features and use cases. You can generate these examples by running:\n\n```bash\npnpm generate-examples\n```\n\n## 1. Basic QR Code\nSimple QR code with default settings.\n```javascript\nconst qr = new QrBit({ text: \"Hello World!\" });\nawait qr.toPngFile(\"01_basic.png\");\n```\n![Basic QR Code](examples/01_basic.png)\n\n## 2. URL QR Code  \nQR code encoding a GitHub URL.\n```javascript\nconst qr = new QrBit({ text: \"https://github.com/jaredwray/qrbit\", size: 200 });\nawait qr.toSvgFile(\"02_url.svg\");\n```\n![URL QR Code](examples/02_url.svg)\n\n## 3. Large Size QR Code\nQR code with increased size for better scanning.\n```javascript\nconst qr = new QrBit({ text: \"Large QR\", size: 400 });\nawait qr.toPngFile(\"03_large_size.png\");\n```\n![Large QR Code](examples/03_large_size.png)\n\n## 4. Inverted Colors\nBlack background with white foreground.\n```javascript\nconst qr = new QrBit({\n  text: \"Inverted Colors\",\n  backgroundColor: \"#000000\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toSvgFile(\"04_inverted.svg\");\n```\n![Inverted QR Code](examples/04_inverted.svg)\n\n## 5. Red Theme\nCustom red background theme.\n```javascript\nconst qr = new QrBit({\n  text: \"Red Theme\",\n  backgroundColor: \"#FF0000\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toPngFile(\"05_red_theme.png\");\n```\n![Red Theme QR Code](examples/05_red_theme.png)\n\n## 6. Small Logo\nQR code with a small embedded logo.\n```javascript\nconst qr = new QrBit({\n  text: \"logo small\",\n  logo: \"./logo.png\",\n  logoSizeRatio: 0.2\n});\nawait qr.toPngFile(\"06_logo_small.png\");\n```\n![Small Logo QR Code](examples/06_logo_small.png)\n\n## 7. Large Logo with Custom Colors\nLarge logo with red background theme.\n```javascript\nconst qr = new QrBit({\n  text: \"logo large red\",\n  logo: \"./logo.png\",\n  size: 400,\n  logoSizeRatio: 0.3,\n  backgroundColor: \"#FF0000\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toSvgFile(\"07_logo_large_red.svg\");\n```\n![Large Logo QR Code](examples/07_logo_large_red.svg)\n\n## 8. WiFi QR Code\nQR code for WiFi network connection.\n```javascript\nconst qr = new QrBit({ \n  text: \"WIFI:T:WPA;S:MyNetwork;P:MyPassword;;\" \n});\nawait qr.toPngFile(\"08_wifi.png\");\n```\n![WiFi QR Code](examples/08_wifi.png)\n\n## 9. Large Margin with Blue Theme\nCustom margin and blue color scheme.\n```javascript\nconst qr = new QrBit({\n  text: \"https://github.com/jaredwray/qrbit\",\n  size: 300,\n  margin: 40,\n  backgroundColor: \"#0000FF\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toSvgFile(\"09_large_margin_blue.svg\");\n```\n![Large Margin Blue QR Code](examples/09_large_margin_blue.svg)\n\n## 10. Buffer Logo\nUsing a logo loaded from a Buffer instead of file path.\n```javascript\nconst logoBuffer = fs.readFileSync(\"./logo.png\");\nconst qr = new QrBit({\n  text: \"Buffer Logo\",\n  logo: logoBuffer,\n  logoSizeRatio: 0.2,\n  backgroundColor: \"#F0F0F0\",\n  foregroundColor: \"#333333\"\n});\nawait qr.toPngFile(\"10_buffer_logo.png\");\n```\n![Buffer Logo QR Code](examples/10_buffer_logo.png)\n\n## 11. High Quality JPEG\nJPEG format with high quality setting.\n```javascript\nconst qr = new QrBit({\n  text: \"High Quality JPEG\",\n  size: 300\n});\nawait qr.toJpgFile(\"11_jpg_high_quality.jpg\", { quality: 95 });\n```\n![High Quality JPEG QR Code](examples/11_jpg_high_quality.jpg)\n\n## 12. JPEG with Logo and Blue Theme\nJPEG with embedded logo and custom blue background.\n```javascript\nconst qr = new QrBit({\n  text: \"JPEG with Logo\",\n  logo: \"./logo.png\",\n  size: 400,\n  logoSizeRatio: 0.25,\n  backgroundColor: \"#2196F3\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toJpgFile(\"12_jpg_logo_blue.jpg\", { quality: 90 });\n```\n![JPEG with Logo Blue QR Code](examples/12_jpg_logo_blue.jpg)\n\n## 13. Compressed JPEG with Green Theme\nJPEG with lower quality for smaller file size.\n```javascript\nconst qr = new QrBit({\n  text: \"https://github.com/jaredwray/qrbit\",\n  size: 300,\n  backgroundColor: \"#4CAF50\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toJpgFile(\"13_jpg_compressed_green.jpg\", { quality: 70 });\n```\n![Compressed JPEG Green QR Code](examples/13_jpg_compressed_green.jpg)\n\n## 14. JPEG with Buffer Logo and Orange Theme\nJPEG using buffer-based logo with orange background.\n```javascript\nconst logoBuffer = fs.readFileSync(\"./logo.png\");\nconst qr = new QrBit({\n  text: \"JPEG Buffer Logo\",\n  logo: logoBuffer,\n  size: 350,\n  logoSizeRatio: 0.2,\n  backgroundColor: \"#FF9800\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toJpgFile(\"14_jpg_buffer_logo_orange.jpg\", { quality: 85 });\n```\n![JPEG Buffer Logo Orange QR Code](examples/14_jpg_buffer_logo_orange.jpg)\n\n## 15. Basic WebP\nWebP format with lossless encoding.\n```javascript\nconst qr = new QrBit({\n  text: \"Basic WebP QR Code\",\n  size: 300\n});\nawait qr.toWebpFile(\"15_webp_basic.webp\");\n```\n![Basic WebP QR Code](examples/15_webp_basic.webp)\n\n## 16. WebP with Logo and Blue Theme\nWebP with embedded logo and custom blue background.\n```javascript\nconst qr = new QrBit({\n  text: \"WebP with Logo\",\n  logo: \"./logo.png\",\n  size: 400,\n  logoSizeRatio: 0.25,\n  backgroundColor: \"#1e3a5f\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toWebpFile(\"16_webp_logo_blue.webp\");\n```\n![WebP with Logo Blue QR Code](examples/16_webp_logo_blue.webp)\n\n## 17. Large WebP with Green Theme\nLarge WebP QR code with green color scheme.\n```javascript\nconst qr = new QrBit({\n  text: \"https://github.com/jaredwray/qrbit\",\n  size: 500,\n  backgroundColor: \"#4CAF50\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toWebpFile(\"17_webp_large_green.webp\");\n```\n![Large WebP Green QR Code](examples/17_webp_large_green.webp)\n\n## 18. WebP with Buffer Logo and Purple Theme\nWebP using buffer-based logo with purple background.\n```javascript\nconst logoBuffer = fs.readFileSync(\"./logo.png\");\nconst qr = new QrBit({\n  text: \"WebP Buffer Logo\",\n  logo: logoBuffer,\n  size: 350,\n  logoSizeRatio: 0.2,\n  backgroundColor: \"#9C27B0\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toWebpFile(\"18_webp_buffer_logo_purple.webp\");\n```\n![WebP Buffer Logo Purple QR Code](examples/18_webp_buffer_logo_purple.webp)\n\n## 19. Low Error Correction\nQR code with low (L) error correction level, suitable for clean environments with minimal risk of damage.\n```javascript\nconst qr = new QrBit({\n  text: \"https://github.com/jaredwray/qrbit?test=this+is+an+error+correction+test\",\n  size: 400,\n  errorCorrection: \"L\",\n  backgroundColor: \"#1e3a5f\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toPngFile(\"19_ec_low.png\");\n```\n![Low Error Correction QR Code](examples/19_ec_low.png)\n\n## 20. High Error Correction\nQR code with high (H) error correction level, recovers up to 30% damage — ideal for logos or printed codes.\n```javascript\nconst qr = new QrBit({\n  text: \"https://github.com/jaredwray/qrbit?test=this+is+an+error+correction+test\",\n  size: 400,\n  errorCorrection: \"H\",\n  backgroundColor: \"#1e3a5f\",\n  foregroundColor: \"#FFFFFF\"\n});\nawait qr.toPngFile(\"20_ec_high.png\");\n```\n![High Error Correction QR Code](examples/20_ec_high.png)\n\nThese examples demonstrate the versatility and capabilities of QrBit for generating QR codes with various customizations, from simple text encoding to complex styled codes with embedded logos, supporting SVG, PNG, JPEG, and WebP formats.\n\n## Contributing\n\nPlease read our [Contributing Guidelines](./CONTRIBUTING.md) and also our [Code of Conduct](./CODE_OF_CONDUCT.md). \n\n## License and Copyright\n\n[MIT \u0026 Copyright (c) Jared Wray](https://github.com/jaredwray/qrbit/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredwray%2Fqrbit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredwray%2Fqrbit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredwray%2Fqrbit/lists"}