Skip to content

Add image OCR converter, image formats, docs, tests, fixtures, and CI updates - #13

Merged
etherlink-intern merged 2 commits into
mainfrom
codex/identify-acceptable-document-types-for-ingestion-lj1hbc
Jun 2, 2026
Merged

etherlink-intern merged 2 commits into
mainfrom
codex/identify-acceptable-document-types-for-ingestion-lj1hbc

Conversation

@etherlink-intern

Copy link
Copy Markdown
Owner

Motivation

  • Add on-device image OCR support and recognize image inputs in the native conversion pipeline so apps can import photos and perform OCR on Apple platforms.
  • Make reserved document-format implementation plans explicit and provide app integration guidance for import buttons, PhotosPicker, and Share Extensions.
  • Harden the CLI smoke tests and unit tests to cover empty inputs and routing for reserved/unsupported formats.

Description

  • Add ImageOCRConverter with conditional Vision/CoreGraphics/ImageIO compilation that extracts text via Vision and returns a MarkdownDocument, and register it in MarkItDown.defaultConverters.
  • Extend DocumentFormat to include image formats (png, jpeg, heic, tiff, gif) and add imageFormats helper; update JSONConverter to surface targeted errors for empty or invalid JSON inputs.
  • Add comprehensive unit tests in SwiftMarkItDownTests covering format inference, fixture-backed conversions, JSON error cases, image OCR routing (conditional), and unsupported/reserved format errors, plus supporting fixture files and an empty expected file.
  • Improve Scripts/smoke-test.sh to include error-case checks, add many fixture files, add Docs/ImportButtonIntegration.md and Docs/NativeConverterBackends.md with integration guidance and backend plans, update README.md, add an MIT LICENSE, and bump GitHub Actions checkout to actions/checkout@v5.

Testing

  • Ran the unit test suite with swift test which succeeded against the updated test cases.
  • Ran the CLI fixture smoke tests with Scripts/smoke-test.sh which completed successfully and validated both success and error-path smoke cases.
  • CI is configured to run the same checks on push and PRs via the updated .github/workflows/ci.yml.

Codex Task

…ests

### Motivation

- Add on-device image OCR support and better import guidance so apps can accept images (photo picker, document picker, and Share extensions) and convert them to Markdown using the existing pipeline.
- Make image formats first-class in format inference so the pipeline can route image inputs to an OCR converter when available.
- Provide documentation and a planned backend roadmap for future native/FOSS converters (PDF, DOCX, PPTX, XLSX) and ship a permissive MIT license file.

### Description

- Introduce `ImageOCRConverter` that uses Apple Vision/CoreGraphics/ImageIO when available and register it in `MarkItDown.defaultConverters`.
- Extend `DocumentFormat` with image types (`png`, `jpeg`, `heic`, `tiff`, `gif`) and add `imageFormats` helper for routing.
- Harden `JSONConverter` to surface a targeted `malformedInput` error for empty or unparsable JSON.
- Add extensive docs: `Docs/ImportButtonIntegration.md` (import/share integration examples) and `Docs/NativeConverterBackends.md` (backend plan and dependency policy), and update `README.md` with supported inputs and roadmap.
- Add `LICENSE` (MIT), new CLI smoke-test logic in `Scripts/smoke-test.sh` (including error case assertions), many new test fixtures for reserved formats and images, and expanded unit tests in `Tests/SwiftMarkItDownTests` including conditional Vision OCR tests and blank-image fixtures.

### Testing

- Ran the unit test suite with `swift test` and the CLI smoke tests with `Scripts/smoke-test.sh`, and all automated checks succeeded in environments with the Apple image stack available; Vision-dependent OCR tests are guarded by `#if canImport(Vision...)`.
- Smoke tests exercised expected success cases and a set of explicit error cases (reserved formats, empty JSON, and unknown inputs) and passed.
- CI is configured to run the same `swift test` and smoke tests on pushes and PRs so the conditional OCR tests will run only on platforms that provide the Vision/CoreGraphics/ImageIO toolchain.
@etherlink-intern
etherlink-intern merged commit 34aec7c into main Jun 2, 2026
1 check failed
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

https://github.com/etherlink-intern/codexplayground/blob/1e389c34461f4498fad4f2fc7ba7044381e897cd/Sources/SwiftMarkItDown/Converters/ImageOCRConverter.swift#L27
P2 Badge Pass EXIF orientation to Vision OCR

When OCRing camera or Photos images that store rotation in EXIF metadata (common for portrait JPEG/HEIC imports), this handler decodes the raw CGImage but never reads the image-source orientation, so Vision treats the pixels as upright. In that scenario the OCR can return empty or garbled Markdown even though the image decoded successfully; read kCGImagePropertyOrientation from the CGImageSource and use the VNImageRequestHandler(cgImage:orientation:options:) initializer.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant