Skip to content

Add configurable scanner preprocessing options#50

Closed
anngth wants to merge 10 commits into
mainfrom
codex/scanner-preprocessing-options
Closed

Add configurable scanner preprocessing options#50
anngth wants to merge 10 commits into
mainfrom
codex/scanner-preprocessing-options

Conversation

@anngth

@anngth anngth commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

Adds configurable image preprocessing options for scanner calls and improves local image path handling across platforms.

Changes

  • Add enhanceContrast, convertToGrayscale, and tryRotations scan options, defaulting to the existing behavior.
  • Pass preprocessing options from the TypeScript wrapper to native Android and iOS implementations.
  • Support Android content:// image URIs and safer percent-decoded file path handling.
  • Gate native debug logging behind debug builds.
  • Align Android minimum SDK with documented support.
  • Tighten lint/typecheck scripts for the library and example app.
  • Update package validation to check the actual podspec filename.
  • Document preprocessing options, URI support, release flow, and compatibility updates.

Verification

  • yarn typecheck
  • yarn lint
  • yarn test --runInBand --watchman=false
  • yarn build
  • node scripts/validate-package.js
  • git diff --check

Notes

  • Full native Gradle/Xcode builds were not run in this pass.
  • yarn test --runInBand without --watchman=false failed in the sandbox because Watchman could not write its state file.

Summary by CodeRabbit

  • New Features
    • Added optional preprocessing controls for scans: enhanceContrast, convertToGrayscale, and tryRotations.
    • Improved support for image picker URIs, including Android content:// URIs and iOS percent-encoded file:// paths.
  • Bug Fixes
    • More robust image path/URI loading with clearer invalid-path vs load-error behavior.
  • Documentation
    • Updated compatibility tables and expanded README usage and npm publishing/release guidance.
  • Build & Compatibility
    • Lowered Android minimum SDK requirement to 21.
  • Tests
    • Added a unit test to verify preprocessing options are forwarded correctly.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@anngth, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a63b4c8b-97f8-41a5-844a-cc6ecabc46b4

📥 Commits

Reviewing files that changed from the base of the PR and between 8a387da and 9aa7422.

📒 Files selected for processing (2)
  • android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt
  • ios/ImageCodeScanner.swift

Walkthrough

This PR adds optional preprocessing flags to the JS scan API, forwards them to native Android and iOS implementations, and updates docs, build settings, and tooling to match the new behavior.

Changes

Preprocessing Options Feature

Layer / File(s) Summary
ScanOptions API and native option forwarding
src/index.tsx, src/__tests__/index.test.tsx
Adds enhanceContrast, convertToGrayscale, and tryRotations to ScanOptions, forwards them with defaults to native scanFromPath, and tests option forwarding.
Android preprocessing and logging
android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt
Adds URI-aware image loading, conditional preprocessing candidate generation, debug-only logging helpers, and distinct invalid-path vs image-load rejection handling.
iOS preprocessing and logging
ios/ImageCodeScanner.swift
Adds preprocessing option parsing, conditional image-variant generation, file-path normalization, and debug logging across the Vision scan flow.
Build config, tooling, and docs
android/gradle.properties, scripts/validate-package.js, eslint.config.mjs, example/package.json, example/tsconfig.json, package.json, README.md, COMPATIBILITY.md
Updates Android SDK requirements, podspec validation, lint/typecheck scripts, example path aliasing, package metadata/dependencies, and docs for preprocessing, publishing, and compatibility.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: configurable scanner preprocessing options were added.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/scanner-preprocessing-options

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt (1)

123-129: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider handling non-boolean values for cross-platform parity.

The iOS boolOption helper (ImageCodeScanner.swift:114-123) falls back to NSNumber.boolValue when the value isn't a Bool. The Android readBooleanOption calls getBoolean directly, which throws if the bridge delivers a non-boolean (e.g., a number). For correct TypeScript usage this is a non-issue, but a JS caller bypassing types could see IMAGE_LOAD_ERROR on Android while iOS silently coerces.

♻️ Optional: add type-safe fallback
 private fun readBooleanOption(options: ReadableMap, key: String, defaultValue: Boolean): Boolean {
   return if (options.hasKey(key) && !options.isNull(key)) {
-    options.getBoolean(key)
+    if (options.getType(key) == ReadableType.Boolean) {
+      options.getBoolean(key)
+    } else {
+      defaultValue
+    }
   } else {
     defaultValue
   }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt` around
lines 123 - 129, The readBooleanOption helper in ImageCodeScannerModule.kt
should mirror the iOS boolOption behavior by tolerating non-boolean bridge
values instead of calling getBoolean directly. Update readBooleanOption to
inspect the value from the ReadableMap and, when it is not a Boolean, fall back
to a NSNumber-style boolean coercion equivalent for Android while preserving the
defaultValue when the key is missing or null. Keep the change localized to
readBooleanOption so callers continue using the same API without triggering
IMAGE_LOAD_ERROR on coerced inputs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt`:
- Around line 123-129: The readBooleanOption helper in ImageCodeScannerModule.kt
should mirror the iOS boolOption behavior by tolerating non-boolean bridge
values instead of calling getBoolean directly. Update readBooleanOption to
inspect the value from the ReadableMap and, when it is not a Boolean, fall back
to a NSNumber-style boolean coercion equivalent for Android while preserving the
defaultValue when the key is missing or null. Keep the change localized to
readBooleanOption so callers continue using the same API without triggering
IMAGE_LOAD_ERROR on coerced inputs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ddf493ad-6b82-4327-8910-d100956d4cb0

📥 Commits

Reviewing files that changed from the base of the PR and between 2bb0c07 and 64eae2f.

📒 Files selected for processing (12)
  • COMPATIBILITY.md
  • README.md
  • android/gradle.properties
  • android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt
  • eslint.config.mjs
  • example/package.json
  • example/tsconfig.json
  • ios/ImageCodeScanner.swift
  • package.json
  • scripts/validate-package.js
  • src/__tests__/index.test.tsx
  • src/index.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
package.json (1)

66-67: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Align version pinning for React Native tooling packages.

@react-native/babel-preset is pinned at 0.79.2 (no caret) while @react-native/eslint-config uses ^0.79.2 (with caret). Both are React Native 0.79.2 tooling packages — the caret on eslint-config could resolve to a newer version, causing drift from the pinned react-native and babel-preset versions. Consider using a consistent strategy (either both pinned or both with caret) to avoid mismatched tooling behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` around lines 66 - 67, The React Native tooling dependencies use
inconsistent version pinning, with `@react-native/babel-preset` pinned exactly and
`@react-native/eslint-config` using a caret. Update the dependency declarations in
package.json to follow one consistent strategy for both packages, matching the
version style already used for the other React Native tooling entries so they
stay aligned with react-native and babel-preset.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@package.json`:
- Around line 66-67: The React Native tooling dependencies use inconsistent
version pinning, with `@react-native/babel-preset` pinned exactly and
`@react-native/eslint-config` using a caret. Update the dependency declarations in
package.json to follow one consistent strategy for both packages, matching the
version style already used for the other React Native tooling entries so they
stay aligned with react-native and babel-preset.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a7016315-08b4-415e-94dc-a9ac0de3acd6

📥 Commits

Reviewing files that changed from the base of the PR and between 64eae2f and d12448d.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt
  • ios/ImageCodeScanner.swift
  • package.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • ios/ImageCodeScanner.swift
  • android/src/main/java/com/imagecodescanner/ImageCodeScannerModule.kt

@anngth anngth closed this Jul 10, 2026
@anngth
anngth deleted the codex/scanner-preprocessing-options branch July 10, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant