react-native-image-quality
v1.0.1
Published
High-performance, zero-dependency native device-level image quality (blur, exposure, brightness) validation for React Native using Nitro Modules.
Maintainers
Readme
react-native-image-quality 📸⚡
High-performance, zero-dependency native device-level image quality (blur, overexposure, underexposure) validation for React Native built on Nitro Modules.
Features sub-10ms native execution in Swift (iOS) and Kotlin (Android) using 3x3 Sobel edge density and Laplacian variance analysis.
⚡ Why react-native-image-quality vs react-native-fast-opencv?
| Feature | react-native-image-quality | react-native-fast-opencv |
| :--- | :--- | :--- |
| App Bundle Size Impact | ~50 KB (Ultra-lightweight) | ~20 MB – 50 MB+ (Bundles full OpenCV C++ SDK) |
| Dependencies | Zero C++ / SDK dependencies | Requires linking heavy OpenCV C++ frameworks & NDK |
| Out-of-the-box Metrics | Ready-to-use blurScore, sharpEdgeRatio, tenengradScore, meanLuminance, reason | Requires writing custom OpenCV matrix/filter pipelines in JS/C++ |
| Architecture | Modern Nitro Modules (Sub-10ms JSI speed) | JSI / Native C++ OpenCV wrappers |
| Build & Setup | Clean automatic autolinking (pod install) | Complex NDK configuration, C++ toolchains, iOS OpenCV framework linking |
| Memory Footprint | Extremely low (downsampled single-channel grayscale buffer) | High (allocates large OpenCV Mat matrices in memory) |
Installation
npm install react-native-image-quality react-native-nitro-modules
# OR
yarn add react-native-image-quality react-native-nitro-modulesiOS Setup
cd ios && pod installQuick Start
import { validateImageQuality, ImageQuality } from 'react-native-image-quality'
// Option 1: Quick helper with automatic user feedback callback
const isValid = await validateImageQuality(photoPath, {
onToast: (message) => showToast(message)
})
if (!isValid) {
console.log("Photo quality rejected")
}
// Option 2: Direct raw metrics analysis
const result = await ImageQuality.analyzeImageQuality(photoPath)
console.log(result)
/*
{
isValid: false,
isBlurry: true,
isDark: false,
isWhite: false,
blurScore: 195.4,
sharpEdgeRatio: 0.008,
tenengradScore: 450.2,
meanLuminance: 91.0,
stdDevLuminance: 75.3,
overexposedRatio: 0.0,
underexposedRatio: 0.36,
reason: 'IMAGE_BLURRY'
}
*/Integration Examples
React Native VisionCamera
const photoFile = await camera.current.takePhoto()
const photoPath = Platform.OS === 'android' ? `file://${photoFile.path}` : photoFile.path
const isValid = await validateImageQuality(photoPath, {
onToast: (msg) => Toast.show(msg)
})
if (isValid) {
saveAttachment(photoPath)
}react-native-image-crop-picker
const response = await ImagePicker.openCamera({ forceJpg: true })
const isValid = await validateImageQuality(response.path, {
onToast: (msg) => Toast.show(msg)
})
if (isValid) {
uploadFile(response.path)
}License
MIT © Avinash
