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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-image-code-scanner

v1.1.3

Published

A lightweight, high-performance React Native library for scanning QR codes and barcodes from images with automatic preprocessing for optimal recognition.

Downloads

665

Readme

React Native Image Code Scanner

Scan QR code/barcode from image files in React Native.

  • Native engine: iOS Vision Framework + Android ML Kit
  • Cross-platform: iOS, Android
  • Auto preprocessing: grayscale, contrast boost, rotation retry
  • TypeScript support

Requirements

  • React Native >=0.70.0
  • React >=17.0.0
  • iOS 13.4+
  • Android minSdkVersion 21+
  • Node >=18

Installation

Expo (recommended)

This package uses native modules, so it works with Expo prebuild, not Expo Go.

npx expo install react-native-image-code-scanner
npx expo prebuild --clean
npx expo run:ios
# or
npx expo run:android

React Native CLI

npm install react-native-image-code-scanner
# or
yarn add react-native-image-code-scanner

iOS

cd ios && pod install

If your app picks image from camera, add this to Info.plist:

<key>NSCameraUsageDescription</key>
<string>This app needs camera access to scan barcodes</string>

Android

No extra setup.

Usage

Example 1: Pick image with expo-image-picker, then scan

import * as ImagePicker from 'expo-image-picker';
import ImageCodeScanner, {
  BarcodeFormat,
} from 'react-native-image-code-scanner';

async function pickAndScan() {
  const picked = await ImagePicker.launchImageLibraryAsync({
    mediaTypes: ImagePicker.MediaTypeOptions.Images,
    quality: 1,
  });

  if (picked.canceled || !picked.assets?.[0]?.uri) {
    return [];
  }

  return ImageCodeScanner.scan({
    path: picked.assets[0].uri,
    formats: [BarcodeFormat.QR_CODE],
  });
}

Example 2: Pick image with react-native-image-picker, then scan

import { launchImageLibrary } from 'react-native-image-picker';
import ImageCodeScanner, {
  BarcodeFormat,
} from 'react-native-image-code-scanner';

async function pickAndScanWithRNImagePicker() {
  const picked = await launchImageLibrary({
    mediaType: 'photo',
    selectionLimit: 1,
  });

  const imagePath = picked.assets?.[0]?.uri;
  if (!imagePath) {
    return [];
  }

  return ImageCodeScanner.scan({
    path: imagePath,
    formats: [BarcodeFormat.QR_CODE, BarcodeFormat.CODE_128],
  });
}

API

ImageCodeScanner.scan(options: ScanOptions): Promise<ScanResult[]>
interface ScanOptions {
  path: string;
  formats?: BarcodeFormat[]; // default: QR_CODE
}

interface ScanResult {
  content: string;
  format: string;
}

Supported BarcodeFormat values:

  • QR_CODE
  • CODE_128
  • CODE_39
  • CODE_93
  • EAN_13
  • EAN_8
  • UPC_A
  • UPC_E
  • PDF_417
  • DATA_MATRIX
  • AZTEC
  • ITF
  • CODABAR

Preprocessing Techniques

To maximize recognition, scanner will try these techniques automatically:

  1. Original image scan
  2. Grayscale conversion
  3. Contrast enhancement
  4. Rotation attempts (, 90°, 180°, 270°)

When a barcode is detected, the scan stops early and returns results.

Performance Tips

  1. Resize very large images before scanning.
  2. Pass only needed formats instead of scanning all formats.
  3. Process images sequentially for batch jobs to reduce memory spikes.
  4. Test on both iOS and Android for critical use cases.

Troubleshooting

  • No result found:
    • Check image quality and resolution
    • Limit formats to what you actually need
    • Ensure barcode type is in supported list
    • Crop image closer to barcode when possible
  • iOS build issues:
    • Reinstall pods: cd ios && pod install
    • Ensure deployment target is 13.4+
  • Android build issues:
    • Clean project: cd android && ./gradlew clean
    • Ensure minSdkVersion >= 21
  • Expo:
    • Must run prebuild
    • Not supported in Expo Go

Example App

See example app and example README.

Contributing

Please read CONTRIBUTING.md.

License

MIT