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

react-native-qupid

v0.1.1

Published

QR Code scanning made simple stupid (and fast)

Downloads

101

Readme

react-native-qupid

QR Code scanning stupid simple: Qupid.

React Native library for both android and iOS to read QR codes from images. This library is designed to be simple to use and fast. It can read QR codes from images and raw bitmaps.

This library uses the react native new architecture with TurboModules significantly improving the performance compared packages using the old architecture.

All react-native code is in TypeScript, android code is full Kotlin and iOS code is Objective-C.

Under the hood it uses BoofCV for android (which is 1.8 faster than the google MLKit. For more info check the performance section) and CIDetector for iOS.

This project has the TurboModule javascript interface in src and the native codes in android / ios folders.

There is also a example project to test the library. The example project has multiple use case demos e.g.

More about performance can be found in the performance document.

Installation

yarn add react-native-qupid
npm install react-native-qupid

Setup

To enable the new architecture for your apps (it's enabled by default in the example project), follow the instructions in the here

Android

This library doesn't require any additional setup for android.

iOS

Add the following to your Podfile:

  pod 'zxing-cpp'

Usage

This library exports the functions readImage, readRaw with the useQupid hook for ease of use.

Basic Usage of the hook useQupid


import { useQupid } from 'react-native-qupid';

const App = () => {
  const [imagePath, setImagePath] = useState<string>('')
  const [qrCodes, error, processImage] = useQupid()

  useEffect(() => {
    if (!imagePath) return
    processImage(imagePath)
  }, [imagePath, processImage])

  ...

  return (
    {qrCodes.map((qrCode, index) => (
      <Text key={index}>{qrCode.data}</Text>
    ))}
  )
}    

Basic Usage of the function readImage

import { readImage } from 'react-native-qupid';

const filePath = 'path/to/image'
const qrCodes = await readImage(filePath)

Basic Usage of the function readRaw

import { readRaw } from 'react-native-qupid';

const rawBytes: number[] = [0x00, ..., 0x00]
const qrCodes = await readRaw(rawBytes)

API

useQupid

This is a hook that provides QR code data, error messages, and a function to process an image.

Return Type

| Name | Type | Description | | --- | --- | --- | | qrData | QRCode[] | An array of QR codes. Each QRCode object contains the data encoded in the QR code and its position in the image. | | error | string | An error message. If there is no error, this will be an empty string. | | processImage | (uri: string) => void | A function that takes a URI of an image, reads the image, and sets qrData and error based on the image content. |

Usage

const [qrData, error, processImage] = useQupid();

Call processImage with the URI of an image to read QR codes from the image. After the image is processed, qrData will be an array of QR codes found in the image, and error will be an error message if there was an error reading the image.

readImage

This function reads QR codes from an image file.

Parameters

| Name | Type | Description | | --- | --- | --- | | filePath | string | The path to the image file. | | inputSubSample | number | The subsample factor for the image. A value of 1 means no subsample, 2 means every other pixel (1/2 of the image size). |

Return Type

| Type | Description | | --- | --- | | Promise<QRCode[]> | A promise that resolves to an array of QR codes found in the image. Each QRCode object contains the data encoded in the QR code and its position in the image. |

Usage

const qrCodes = await readImage(filePath, inputSubSample);

readRaw

This function reads QR codes from a raw bitmap.

Parameters

| Name | Type | Description | | --- | --- | --- | | data | number[] | The raw bitmap data. Android will parse it to a ReadableArray, and iOS will parse it to an NSArray<NSNumber>. |

Return Type

| Type | Description | | --- | --- | | Promise<QRCode[]> | A promise that resolves to an array of QR codes found in the raw bitmap. Each QRCode object contains the data encoded in the QR code and its position in the image. |

Usage

const qrCodes = await readRaw(data);

QRCode

type QRCode = {
  data: string
  x: number
  y: number
  width: number
  height: number
}

Properties

| Name | Type | Description | | --- | --- | --- | | data | string | The data encoded in the QR code. | | x | number | The x-coordinate of the top-left corner of the QR code in the image. | | y | number | The y-coordinate of the top-left corner of the QR code in the image. | | width | number | The width of the QR code in the image. | | height | number | The height of the QR code in the image. |

Contributing

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

License

MIT


Made with create-react-native-library