react-native-add-qrcode
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

react-native-add-qrcode

Add a QRCode to a image.

This libs just supports JPEG images at this moment. We might add other types support if necessary.

Installation

npm install react-native-add-qrcode

Usage

import { addQRCodeToImage } from 'react-native-add-qrcode';

// ...

const result = await addQRCodeToImage('path/to/image', 
                                      'path/to/result/image',
                                      'QR Code Data',
                                      {
                                        x: 10, 
                                        y: 10, 
                                        height: 250,
                                        width: 250,
                                        foregroundColor: '#FFFFFF',
                                        backgroundColor: '#000000'
                                      }
                                    );

API

Signature:

static addQRCodeToImage(imagePath: string, destinationPath: string, data: string, options?: OptionsType): Promise<ResultType>

type OptionsType = {
  x?: number;                   // Horizontal position of the QR Code
  y?: number;                   // Vertical position of the QR Code
  height?: number;              // Height of the QR Code
  width?: number;               // Width of the QR Code
  quality?: number;             // JPEG quality for the final image
  backgroundColor?: string;     // Color for the background of the QR Code
  foregroundColor?: string;     // Color for the foreground of the QR Code
}

type ResultType = {
  uri: string;          // URI for the final image
  finalWidth: number,   // QR code final width
  finalHeight: number   // QR code final height
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Package Sidebar

Install

npm i react-native-add-qrcode

Weekly Downloads

7

Version

0.1.2

License

MIT

Unpacked Size

34.9 kB

Total Files

20

Last publish

Collaborators

  • chriteixeira