feat(Release v3.1.0-beta.2): Add Image Scanning Functionality with Gallery Access - #70
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces image scanning functionality to the React Native Scanner library, allowing users to scan QR codes and barcodes from static images selected from the device gallery. This addresses issue #65 which requested support for decoding QR codes from existing images as a fallback for devices with low-quality cameras.
Changes:
- Added
scanImage(imageUri)method to scan barcodes from static images on both iOS and Android platforms - Integrated react-native-image-picker dependency for gallery access in the example app
- Updated documentation (README.md and new WIKI.md) with comprehensive usage examples and API reference
- Added platform-specific permissions for photo library access (iOS) and media storage (Android)
Reviewed changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/index.tsx | Added scanImage static method to BarcodeScanner class |
| src/NativeReactNativeScanner.ts | Extended TurboModule interface with scanImage method signature |
| src/tests/index.test.tsx | Added unit test for image scanning functionality |
| ios/ReactNativeScanner.mm | Implemented Objective-C++ bridge method for scanImage |
| ios/CameraManager.swift | Added image scanning with Vision framework and CIDetector fallback for QR codes |
| android/src/main/java/.../ReactNativeScannerModule.kt | Implemented native module method for image scanning |
| android/src/main/java/.../CameraManager.kt | Added ML Kit-based image scanning with Exif handling and fallback bitmap loading |
| example/src/App.tsx | Integrated gallery picker with image scanning demonstration |
| example/package.json | Added react-native-image-picker dependency |
| example/ios/ReactNativeScannerExample/Info.plist | Added NSPhotoLibraryUsageDescription for iOS photo access |
| example/ios/ReactNativeScannerExample/PrivacyInfo.xcprivacy | Added file timestamp access reason code (3B52.1) |
| example/android/app/src/main/AndroidManifest.xml | Added READ_EXTERNAL_STORAGE and READ_MEDIA_IMAGES permissions |
| package.json | Bumped version to 3.1.0-beta.1 |
| yarn.lock | Added [email protected] dependency |
| WIKI.md | New comprehensive project documentation with architecture and API details |
| README.md | Updated with image scanning usage examples and supported formats table |
| example/ios/Podfile.lock | Updated with react-native-image-picker pod dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Added optional bitmap parameter to processImage for recycling after processing - Implemented bitmap recycle logic with safety check to avoid double recycling - Passed bitmap to processImage call to enable cleanup of fallback bitmaps - Recycled original bitmap after drawing to free memory resources - Added debug logs for bitmap recycling events to track memory management
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 17 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ndling - Add URI scheme validation and path traversal prevention for scanImage - Android: implement retry logic with progressive resolution scaling - Android: add proper thread factory and executor lifecycle management - iOS: ensure callbacks run on MainActor with proper error handling - iOS: wrap image processing in autoreleasepool for better memory management - Add comprehensive input validation on TypeScript layer
This pull request introduces comprehensive improvements to the
@pushpendersingh/react-native-scannerlibrary, focusing on adding support for scanning barcodes from static images (e.g., gallery images), expanding documentation, and enhancing the Android implementation for image scanning. The changes include updates to the README, a new project wiki, and significant additions to the Android native code to support the new feature.Major new feature:
The most important changes include:
Feature: Image (Gallery) Barcode Scanning
scanImage(imageUri)method in theBarcodeScannerclass, including supported image formats and platform notes. [1] [2]Documentation Improvements
WIKI.mdfile describing the library's architecture, project structure, native implementation details, data flow, types, build system, error handling, and best practices for lifecycle management.Android Native Implementation Enhancements
CameraManager.ktto include image decoding, orientation handling, and thread management for efficient and robust static image barcode scanning. Introduced constants for bitmap size limits and improved executor thread creation for background tasks. [1] [2] [3] [4]Minor Improvements
📱 Platform Support
Closes: #65