Skip to content

docs: Update documentation - #388

Closed
Krasner wants to merge 17 commits into
Ryan-Millard:devfrom
Krasner:fix/docs
Closed

docs: Update documentation#388
Krasner wants to merge 17 commits into
Ryan-Millard:devfrom
Krasner:fix/docs

Conversation

@Krasner

@Krasner Krasner commented May 20, 2026

Copy link
Copy Markdown
Collaborator

What was changed & why

Generate updated documentation using codex.
Specifically ollama launch codex with qwen3.6
https://docs.ollama.com/integrations/codex

Fixes: #372

Changes

Testing & Verification

Additional Resources

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Comprehensive documentation overhaul for the Img2Num library spanning user guides, API references across four language bindings (JavaScript/WASM, C++, C, Python), and operational guidance; paired with Python binding docstring enhancements and minor C binding refactoring.

Changes

User-Facing Documentation Foundation

Layer / File(s) Summary
Landing Page, Core Concepts, Installation, and Getting Started
docs/docs/index.md, docs/docs/concepts.md, docs/docs/installation.md, docs/docs/getting-started.md
Updated homepage with API bindings status table; added new Core Concepts page explaining color spaces (CIE LAB vs sRGB), bilateral filtering, k-means clustering, and contour simplification; fully populated Installation guide with platform-specific instructions for JavaScript, C++, C, Python, and WASM; introduced Getting Started tutorial with prerequisites, step-by-step conversion example, pipeline flowchart, and concept links.
Performance and Troubleshooting Guidance
docs/docs/performance.md, docs/docs/troubleshooting.md
Added performance optimization guide covering WASM Web Worker execution, batch processing with Promise.all, parameter tuning, image downscaling, worker reuse, and Node.js process pooling; plus comprehensive troubleshooting documentation addressing WASM loading failures, image quality issues, K-means performance bottlenecks, memory constraints, and color space configuration.

API Reference Documentation for All Bindings

Layer / File(s) Summary
Shared API Reference and Pipeline Overview
docs/docs/api-reference.md
Central API reference documenting shared core concepts (bilateral filtering, k-means clustering, contour tracing, B-spline simplification) and common parameters across all bindings (sigma_spatial, sigma_range, num_colors/k, max_iter, min_area, color_space); includes Mermaid pipeline flow diagram visualizing raster → bilateral filter → clustering → contour detection → SVG progression.
C++ API Reference and Documentation
docs/docs/cpp/api-reference.md, docs/docs/cpp/docs/index.md
Replaced Doxygen iframe proxy with fully inlined C++ API reference documenting image_to_svg, gaussian_blur_fft, invert_image, threshold_image, black_threshold_image, kmeans, bilateral_filter, and labels_to_svg with function signatures and parameter tables; rewritten docs/index.md with CMake installation, quick example, pipeline function overview table, and color space constants.
C API Reference and Documentation
docs/docs/c/api-reference.md, docs/docs/c/docs/index.md
Converted from Doxygen iframe proxy to static C API reference with img2num_ImageToSvgConfig struct definition, default initializer, and documented C functions; added installation steps (build C++ library, copy header and shared library), quick example program, and memory management guidance for free() ownership of returned strings.
JavaScript/WASM API Reference and Documentation
docs/docs/js/api-reference.md, docs/docs/js/docs/index.md
Documented async WASM-backed JavaScript APIs (imageToSvg, bilateralFilter, kmeans, findContours, imageToUint8ClampedArray, callWasm, initWasmWorker) with parameter tables and usage snippets; rewrote docs/index.md with async architecture explanation, WASM memory handling workflow steps, worker lazy-initialization lifecycle, and error-handling patterns.
Python API Reference and Getting Started Documentation
docs/docs/python/api-reference.md, docs/docs/python/index.md
Documented Python NumPy-based interfaces for image_to_svg, bilateral_filter, kmeans, and findContours with parameter and return type specifications; added getting started page with Python ≥3.7 and NumPy requirements, pip installation, basic usage example, and ImageToSvgConfig customization patterns.

Python Binding Implementation and Internal Documentation

Layer / File(s) Summary
PyBind11 Function and Configuration Documentation
bindings/py/src/img2num_pybind.cpp
Expanded module-level and per-function documentation: replaced single-line docstrings with multi-line RST docstrings for gaussian_blur_fft, invert_image, threshold_image variants, bilateral_filter, kmeans, labels_to_svg, and image_to_svg; augmented ImageToSvgConfig and nested BilateralFilterConfig and KMeansConfig classes with detailed RST field documentation; simplified labels_to_svg return path to direct pybind11::str(std::move(svg)).
PyBind11 K-means Array Handling Refinement
bindings/py/src/img2num_pybind.cpp
Kmeans binding rewritten to explicitly declare output buffers using pybind11::array_t with typed pointer casting for clustered data and label map (including explicit label shape); C++ call now consumes typed pointers derived from these arrays while preserving tuple (clustered_data, labels) return semantics.
Python Doxygen Configuration and Home Page Documentation
bindings/py/Doxyfile.internal, bindings/py/doxygen/home_page.dox
Added new Doxyfile.internal for Python bindings documentation generation with recursive parsing and private/static member extraction; populated home_page.dox with project overview describing pybind11 architecture, NumPy buffer operations, key features, CMake build instructions, Python usage example, and Doxygen defgroup sections for image processing functions and configuration classes.
Python Binding Internal Documentation and Doxygen Proxy
docs/docs/internal/bindings/py/index.md, docs/docs/internal/bindings/py/api-reference.md
Created internal documentation describing pybind11-based Python bindings, enumerated exposed functions, CMake build workflow, and representative Python processing example (Gaussian blur → invert → threshold → SVG); added Doxygen HTML proxy page providing fullscreen iframe embed of generated Python API reference.

Build System, C Binding Refactoring, and Navigation Updates

Layer / File(s) Summary
Doxygen Build Script and JavaScript Release Flag
docs/scripts/doxygen.js, bindings/js/doxygen/home_page.dox
Extended doxygen.js with PY_BINDINGS_DIR constant and new DOXYFILES entry to generate Python bindings Doxygen documentation under static/docs/internal/bindings/py/api; updated JavaScript/WASM build to explicitly set -DCMAKE_BUILD_TYPE=Release in emcmake command.
C Binding Header and Implementation Refactoring
bindings/c/include/cimg2num.h, bindings/c/src/cimg2num.cpp
Minor C binding updates: Doxygen documentation comment adjustment in header; to_cpp and to_c struct conversions reformatted to compact designated-initializer style; img2num_image_to_svg lambda whitespace adjustments—all without functional changes.
Internal Documentation Navigation and Contributing Guide Updates
docs/docs/internal/index.md, docs/docs/js/index.md, docs/docs/contributing/index.md
Converted internal documentation hub and contributing guide navigation links from relative paths (e.g., ./docs/) to absolute site-relative paths (e.g., /docs/next/internal/...) for improved consistency; similarly updated JavaScript binding index resource links to new absolute paths.
Core Header Adjustment and README Update
core/include/img2num.h, README.md
Minor non-functional adjustment to core header around ImageToSvgConfig boundary; added Python documentation link to README "Essential links → Docs" section.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Ryan-Millard/Img2Num#307: Directly extends Python binding work introduced in PR #307; this PR adds expanded pybind11 docstrings and refines kmeans/labels_to_svg implementation for better Python binding documentation.
  • Ryan-Millard/Img2Num#335: Builds on the unified image_to_svg/ImageToSvgConfig API surface introduced in PR #335; refines documentation and formatting of the C/Python bindings configuration code.
  • Ryan-Millard/Img2Num#263: Directly extends C binding implementation from PR #263; this PR refactors C binding struct conversions and SVG string allocation patterns introduced in that PR.

Suggested reviewers

  • Ryan-Millard

Poem

🐰 The docs now shine with prose so bright,
Each binding explained from Python to C,
Performance tips guide users right,
While Doxygen scripts orchestrate free—
A hop through guides makes all clear!


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 warning, 1 inconclusive)

Check name Status Explanation Resolution
No Ai Slop Pr Description ❌ Error PR description is generic: "Regenerates/updates docs using Codex" lacks specific details. Required template sections (Changes, Testing, Additional Resources) are empty. Specify what docs were added (API refs for JS/C++/C/Python, installation, concepts, getting-started) and why (complete documentation site for multi-language bindings).
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'docs: Update documentation' is vague and generic, failing to describe the specific changes made in this large documentation regeneration PR. Make the title more specific and descriptive. For example: 'docs: Regenerate documentation with expanded API references, guides, and configuration examples' or 'docs: Add comprehensive documentation for all language bindings and core concepts'.
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description adequately relates to the changeset; it explains the use of Codex to regenerate documentation and provides context for understanding the changes made.
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.
No Strangely-Named Root Markdown Files ✅ Passed No unconventional markdown files added at repository root; all documentation changes are properly placed in docs/docs/ subdirectories or acceptable root files (README.md).
Coderabbit Config Needs Update ✅ Passed PR introduces only documentation and code changes in already-covered languages (C/C++, JavaScript, Markdown, Doxygen). No new linter configs, CI files, or uncovered file extensions present.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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 and usage tips.

@github-actions github-actions Bot added c/c++ Changes to C or C++ files core documentation labels May 20, 2026
@Krasner

Krasner commented May 20, 2026

Copy link
Copy Markdown
Collaborator Author

@Ryan-Millard here I worked with codex to generate and update documentation. It actually looks pretty good but a few mistakes. Feel free to review and I will iteratively address issues

@coderabbitai coderabbitai Bot added js/ts python changes to python bindings or python code labels May 20, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 13

🤖 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.

Inline comments:
In `@docs/docs/api-reference.md`:
- Around line 40-54: The fenced ASCII pipeline block (the triple-backtick block
containing the diagram with nodes like "[Raster Image]", "[ Bilateral Filter]",
"[ K-Means Clustering]", "[ Contour Detection]", and "[ SVG Output]") is missing
a language identifier; update the opening fence from ``` to ```text so the code
fence has the `text` language identifier to satisfy MD040.

In `@docs/docs/c/docs/index.md`:
- Around line 11-23: The ordered list in the documentation uses mixed numbering
(the second item is "2.") and violates markdownlint MD029; update the ordered
list so every item uses the continued "1." style (i.e., change the "2. Copy the
header and shared library:" item to "1.") so both list entries ("Build the C++
library:" and "Copy the header and shared library:") use the normalized "1."
prefix.

In `@docs/docs/concepts.md`:
- Around line 27-30: The fenced code block containing the lines with "result =
weighted_average(input_pixels)" and the weight formula is missing a language
identifier; update the opening fence from ``` to ```text so the block has an
explicit language tag (e.g., change the fence that precedes the weighted_average
example to use ```text) to satisfy the MD040 rule.

In `@docs/docs/cpp/docs/index.md`:
- Around line 7-19: The ordered list numbering in the markdown uses mixed
prefixes (first item "1.", second item "2.") which triggers MD029; normalize the
list by using consistent "1." prefixes for each ordered item—update the list
entries "Build the library:" and "Link against `img2num`:" so both lines start
with "1." to satisfy markdownlint.

In `@docs/docs/installation.md`:
- Around line 29-38: The fenced code block inside the tip admonition (the :::tip
block that contains the import script with imageToUint8ClampedArray,
bilateralFilter, kmeans, findContours) must have a blank line before and after
the ``` fenced block to satisfy MD031; edit the tip block to insert an empty
line immediately above the opening ``` and immediately below the closing ```,
preserving the existing content and fence markers.
- Around line 63-65: Add a language identifier to the fenced code block that
currently contains "bindings/c/include/cimg2num.h" (e.g., change the opening
fence from ``` to ```text or ```bash) so the Markdown linter rule MD040 is
satisfied; locate the fenced block that exactly contains that path and update
the opening backticks to include the chosen language token.

In `@docs/docs/js/api-reference.md`:
- Around line 51-53: The documentation for imageToUint8ClampedArray currently
conflicts between a tuple and an object return shape; pick one canonical shape
(prefer the object form { pixels: Uint8ClampedArray, width: number, height:
number } or the tuple [pixels, width, height]) and update both occurrences to
match; ensure the signature text and the "Returns:" line both describe the same
return type and reference the function name imageToUint8ClampedArray so readers
and any generated API docs are consistent.
- Line 9: The docs state "All functions are exported from the img2num package"
and claim they are async, but several function return examples are written as
plain objects; update those return type examples to Promise-wrapped types (e.g.,
change FooResponse to Promise<FooResponse>) wherever a function's doc/example
currently shows a plain object return so the API page consistently reflects
async behavior for all exported functions from img2num; locate the return
sections for each exported function in this file and change their documented
return signatures/examples to Promise<...> to match the actual async functions.

In `@docs/docs/js/docs/index.md`:
- Around line 7-29: The code fence containing the ASCII architecture diagram is
missing a language tag; change the opening fence from ``` to ```text so the
block is treated as plain text (e.g., update the diagram block that lists
safeWasmWrappers.js, wasmClient.js, wasmWorker.js, and img2num_core.wasm to
start with ```text).

In `@docs/docs/performance.md`:
- Line 38: The code destructures a non-existent pixels property from
ctx.getImageData; change the destructuring to use the actual ImageData property
name `data` instead of `pixels` (e.g., replace `const { pixels, width, height }
= ctx.getImageData(…)` with `const { data, width, height } =
ctx.getImageData(…)`) so subsequent code references the correct buffer returned
by getImageData().

In `@docs/docs/python/api-reference.md`:
- Around line 9-11: The docs contradict whether width/height are injected from
NumPy arrays or required keyword parameters; pick one contract and make all
signatures, parameter tables, and examples consistent: either (A) document that
img2num functions (e.g., image_to_svg) accept a NumPy array and automatically
derive width/height (remove width,height from the function signatures and mark
them as derived in the parameter descriptions and examples), or (B) document
that width and height are explicit required keyword-only args (keep them in the
signatures and update the top-level statement to stop claiming automatic
injection); apply the chosen approach to image_to_svg and the other listed
function docs so signatures, parameter descriptions, and examples match.
- Line 60: The docs use the removed alias NDArray[np.int]; update both
occurrences (the Returns tuple shown as NDArray[np.uint8], NDArray[np.int] and
the other occurrence) to a supported explicit integer type—replace
NDArray[np.int] with NDArray[np.int_] (or NDArray[np.int64]/NDArray[np.int32] if
you need fixed width) so the documentation uses a valid NumPy type instead of
the deprecated np.int.

In `@docs/docs/troubleshooting.md`:
- Line 32: The sentence about tuning sigma_spatial is self-contradictory; update
the text to be directional by symptom: state that if the result is
over-smoothed, decrease sigma_spatial, and if the result is too noisy or
contains speckle artifacts, increase sigma_spatial. Edit the sentence
referencing `sigma_spatial` so it clearly maps each symptom to the proper action
(e.g., "If the image is over-smoothed, decrease `sigma_spatial`; if the image is
too noisy, increase `sigma_spatial`.").
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9b1b7aa9-6846-4f80-a308-e36d5784f6c4

📥 Commits

Reviewing files that changed from the base of the PR and between 8839ccd and 4f47ccb.

📒 Files selected for processing (16)
  • core/include/img2num.h
  • docs/docs/api-reference.md
  • docs/docs/c/api-reference.md
  • docs/docs/c/docs/index.md
  • docs/docs/concepts.md
  • docs/docs/cpp/api-reference.md
  • docs/docs/cpp/docs/index.md
  • docs/docs/getting-started.md
  • docs/docs/index.md
  • docs/docs/installation.md
  • docs/docs/js/api-reference.md
  • docs/docs/js/docs/index.md
  • docs/docs/performance.md
  • docs/docs/python/api-reference.md
  • docs/docs/python/index.md
  • docs/docs/troubleshooting.md
💤 Files with no reviewable changes (1)
  • core/include/img2num.h
📜 Review details
⏰ Context from checks skipped due to timeout of 120000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build C/C++ / Build C & C++
  • GitHub Check: Build C/C++ / Build Python
  • GitHub Check: Build Documentation Site / Build Docusaurus Site
  • GitHub Check: Build C/C++ / Build WASM (bindings/js)
  • GitHub Check: Lint & Validate Code
🧰 Additional context used
📓 Path-based instructions (2)
**/*.md

📄 CodeRabbit inference engine (.editorconfig)

**/*.md: Do not trim trailing whitespace in Markdown files
Use 2-space indentation for Markdown files
Do not enforce maximum line length for Markdown files

Files:

  • docs/docs/python/index.md
  • docs/docs/troubleshooting.md
  • docs/docs/installation.md
  • docs/docs/index.md
  • docs/docs/getting-started.md
  • docs/docs/api-reference.md
  • docs/docs/python/api-reference.md
  • docs/docs/js/docs/index.md
  • docs/docs/js/api-reference.md
  • docs/docs/concepts.md
  • docs/docs/cpp/docs/index.md
  • docs/docs/c/docs/index.md
  • docs/docs/performance.md
  • docs/docs/cpp/api-reference.md
  • docs/docs/c/api-reference.md
docs/docs/**

⚙️ CodeRabbit configuration file

docs/docs/**: All documentation must follow Docusaurus conventions (docs/docs/ folder structure).
Do NOT suggest creating strangely-named markdown files at the repository root
(e.g. COMPREHENSIVE_TEST_REPORT.md, DELIVERABLES.md, SUMMARY.md).
New docs belong either as a dedicated Docusaurus category or integrated into an
existing category such as project-scripts. Verify valid frontmatter
(title, sidebar_label, etc.) and correct sidebar wiring.

Files:

  • docs/docs/python/index.md
  • docs/docs/troubleshooting.md
  • docs/docs/installation.md
  • docs/docs/index.md
  • docs/docs/getting-started.md
  • docs/docs/api-reference.md
  • docs/docs/python/api-reference.md
  • docs/docs/js/docs/index.md
  • docs/docs/js/api-reference.md
  • docs/docs/concepts.md
  • docs/docs/cpp/docs/index.md
  • docs/docs/c/docs/index.md
  • docs/docs/performance.md
  • docs/docs/cpp/api-reference.md
  • docs/docs/c/api-reference.md
🧠 Learnings (2)
📚 Learning: 2026-01-04T15:34:04.654Z
Learnt from: Ryan-Millard
Repo: Ryan-Millard/Img2Num PR: 146
File: docs/docs/reference/react/components/ThemeSwitch/tests.md:123-124
Timestamp: 2026-01-04T15:34:04.654Z
Learning: In Docusaurus documentation, relative directory links (e.g., ../ or ../../../hooks/useTheme) resolve to index.md within the target directory. Do not require or force linking to index.md explicitly; such relative links remain valid and should not be changed when reviewing docs under the docs directory.

Applied to files:

  • docs/docs/python/index.md
  • docs/docs/troubleshooting.md
  • docs/docs/installation.md
  • docs/docs/index.md
  • docs/docs/getting-started.md
  • docs/docs/api-reference.md
  • docs/docs/python/api-reference.md
  • docs/docs/js/docs/index.md
  • docs/docs/js/api-reference.md
  • docs/docs/concepts.md
  • docs/docs/cpp/docs/index.md
  • docs/docs/c/docs/index.md
  • docs/docs/performance.md
  • docs/docs/cpp/api-reference.md
  • docs/docs/c/api-reference.md
📚 Learning: 2026-02-22T15:20:15.304Z
Learnt from: Ryan-Millard
Repo: Ryan-Millard/Img2Num PR: 263
File: docs/docs/internal/core/api-reference.md:13-13
Timestamp: 2026-02-22T15:20:15.304Z
Learning: In Docusaurus projects, Markdown files (*.md, *.mdx) may contain anchor tags with onClick={(e) => { e.preventDefault(); window.location.href = '...'; }} to force a full page navigation, bypassing React SPA routing for static/external paths. Treat this as intentional and do not flag it as redundant in docs contexts. Apply this guidance broadly to Markdown docs across the repository (not just the single file) and focus reviews on more impactful patterns such as accessibility, SEO, and navigation consistency.

Applied to files:

  • docs/docs/python/index.md
  • docs/docs/troubleshooting.md
  • docs/docs/installation.md
  • docs/docs/index.md
  • docs/docs/getting-started.md
  • docs/docs/api-reference.md
  • docs/docs/python/api-reference.md
  • docs/docs/js/docs/index.md
  • docs/docs/js/api-reference.md
  • docs/docs/concepts.md
  • docs/docs/cpp/docs/index.md
  • docs/docs/c/docs/index.md
  • docs/docs/performance.md
  • docs/docs/cpp/api-reference.md
  • docs/docs/c/api-reference.md
🪛 LanguageTool
docs/docs/troubleshooting.md

[style] ~48-~48: As an alternative to the over-used intensifier ‘very’, consider replacing this phrase.
Context: ...The WASM heap is fixed at compile time. Very large images may exceed it. Consider: - Down...

(EN_WEAK_ADJECTIVE)

🪛 markdownlint-cli2 (0.22.1)
docs/docs/installation.md

[warning] 37-37: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


[warning] 63-63: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

docs/docs/api-reference.md

[warning] 40-40: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

docs/docs/js/docs/index.md

[warning] 7-7: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

docs/docs/concepts.md

[warning] 27-27: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

docs/docs/cpp/docs/index.md

[warning] 14-14: Ordered list item prefix
Expected: 1; Actual: 2; Style: 1/1/1

(MD029, ol-prefix)

docs/docs/c/docs/index.md

[warning] 18-18: Ordered list item prefix
Expected: 1; Actual: 2; Style: 1/1/1

(MD029, ol-prefix)

🔇 Additional comments (4)
docs/docs/index.md (1)

9-35: LGTM!

docs/docs/getting-started.md (1)

9-87: LGTM!

docs/docs/performance.md (1)

1-37: LGTM!

Also applies to: 39-51

docs/docs/troubleshooting.md (1)

1-31: LGTM!

Also applies to: 33-56

Comment thread docs/docs/api-reference.md Outdated
Comment thread docs/docs/c/docs/index.md
Comment on lines +11 to +23
1. Build the C++ library:

```bash
cmake -B build .
cmake --build build
```

2. Copy the header and shared library:

```bash
cp bindings/c/include/cimg2num.h /your/project/dir
cp build/libimg2num.so /your/project/dir # .dylib on macOS, .dll on Windows
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Normalize ordered list numbering for markdownlint.

Line 18 uses 2. while this doc style/lint expects 1. prefixes for ordered lists (MD029).

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 18-18: Ordered list item prefix
Expected: 1; Actual: 2; Style: 1/1/1

(MD029, ol-prefix)

🤖 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 `@docs/docs/c/docs/index.md` around lines 11 - 23, The ordered list in the
documentation uses mixed numbering (the second item is "2.") and violates
markdownlint MD029; update the ordered list so every item uses the continued
"1." style (i.e., change the "2. Copy the header and shared library:" item to
"1.") so both list entries ("Build the C++ library:" and "Copy the header and
shared library:") use the normalized "1." prefix.

Comment thread docs/docs/concepts.md
Comment on lines +27 to +30
```
result = weighted_average(input_pixels)
weight = exp(-dist² / 2σ²_spatial) × exp(-Δintensity² / 2σ²_range)
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add a language identifier to the fenced code block.

The block starting at Line 27 is missing a language tag (MD040). text is sufficient here.

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 27-27: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 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 `@docs/docs/concepts.md` around lines 27 - 30, The fenced code block containing
the lines with "result = weighted_average(input_pixels)" and the weight formula
is missing a language identifier; update the opening fence from ``` to ```text
so the block has an explicit language tag (e.g., change the fence that precedes
the weighted_average example to use ```text) to satisfy the MD040 rule.

Comment on lines +7 to +19
1. Build the library:

> You don't need an issue to work on this - just mention it in your PR body.🦔
```bash
cmake -B build .
cmake --build build
```

2. Link against `img2num`:

```cmake
find_package(img2num REQUIRED)
target_link_libraries(myapp PRIVATE img2num)
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Normalize ordered list numbering for markdownlint.

Line 14 uses 2. but the configured markdownlint rule expects 1. list prefixes (MD029).

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 14-14: Ordered list item prefix
Expected: 1; Actual: 2; Style: 1/1/1

(MD029, ol-prefix)

🤖 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 `@docs/docs/cpp/docs/index.md` around lines 7 - 19, The ordered list numbering
in the markdown uses mixed prefixes (first item "1.", second item "2.") which
triggers MD029; normalize the list by using consistent "1." prefixes for each
ordered item—update the list entries "Build the library:" and "Link against
`img2num`:" so both lines start with "1." to satisfy markdownlint.

Comment thread docs/docs/installation.md
Comment thread docs/docs/js/docs/index.md Outdated
Comment thread docs/docs/performance.md
canvas.height = 720;
const ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0, 720, 720);
const { pixels, width, height } = ctx.getImageData(0, 0, 720, 720);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

What object and properties does CanvasRenderingContext2D.getImageData() return (spec/MDN), and is there a pixels property?

💡 Result:

The CanvasRenderingContext2D.getImageData method returns an ImageData object [1][2]. There is no "pixels" property on the ImageData object [3]. The ImageData object contains the following instance properties [3]: - data: A Uint8ClampedArray or Float16Array (depending on the pixel format) that contains the image data as a one-dimensional array in RGBA order [3][4]. - width: An unsigned long representing the actual width of the image data in pixels [3]. - height: An unsigned long representing the actual height of the image data in pixels [3]. - colorSpace: A string indicating the color space of the image data [3]. - pixelFormat: A string indicating the format of the image data (e.g., "rgba-unorm8" or "rgba-float16") [3]. The pixel data itself is accessed via the.data property, not a "pixels" property [3].

Citations:


🏁 Script executed:

# Check if the file exists and read its content
if [ -f "docs/docs/performance.md" ]; then
  echo "=== File exists, reading content (first 50 lines) ==="
  head -50 "docs/docs/performance.md" | cat -n
else
  echo "File not found. Searching for performance.md in docs folder:"
  find docs -name "performance.md" 2>/dev/null
fi

Repository: Ryan-Millard/Img2Num

Length of output: 1861


🏁 Script executed:

# Also check if there are other .md files in docs/docs to understand structure
echo "=== Docusaurus docs structure ==="
ls -la docs/docs/ 2>/dev/null | head -20

Repository: Ryan-Millard/Img2Num

Length of output: 1007


Use data from ImageData, not pixels.

Line 38 destructures a non-existent pixels property. getImageData() returns { data, width, height }; pixels is undefined.

Suggested doc fix
-const { pixels, width, height } = ctx.getImageData(0, 0, 720, 720);
+const { data: pixels, width, height } = ctx.getImageData(0, 0, 720, 720);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { pixels, width, height } = ctx.getImageData(0, 0, 720, 720);
const { data: pixels, width, height } = ctx.getImageData(0, 0, 720, 720);
🤖 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 `@docs/docs/performance.md` at line 38, The code destructures a non-existent
pixels property from ctx.getImageData; change the destructuring to use the
actual ImageData property name `data` instead of `pixels` (e.g., replace `const
{ pixels, width, height } = ctx.getImageData(…)` with `const { data, width,
height } = ctx.getImageData(…)`) so subsequent code references the correct
buffer returned by getImageData().

Comment on lines +9 to +11
All functions are exposed via the `img2num` Python package. They accept NumPy arrays and automatically inject `width`/`height` from the array shape.

## `image_to_svg(image, *, width, height, config=None)`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Resolve the width/height contract contradiction.

Line 9 says width/height are injected automatically, but the documented signatures make them explicit required keyword-only parameters. Please choose one contract and align signatures, parameter tables, and examples accordingly.

Also applies to: 20-23, 32-33, 47-48, 62-63

🤖 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 `@docs/docs/python/api-reference.md` around lines 9 - 11, The docs contradict
whether width/height are injected from NumPy arrays or required keyword
parameters; pick one contract and make all signatures, parameter tables, and
examples consistent: either (A) document that img2num functions (e.g.,
image_to_svg) accept a NumPy array and automatically derive width/height (remove
width,height from the function signatures and mark them as derived in the
parameter descriptions and examples), or (B) document that width and height are
explicit required keyword-only args (keep them in the signatures and update the
top-level statement to stop claiming automatic injection); apply the chosen
approach to image_to_svg and the other listed function docs so signatures,
parameter descriptions, and examples match.

| `max_iter` | `int` | — |
| `color_space` | `int` | — |

**Returns:** `(NDArray[np.uint8], NDArray[np.int])` — `(clustered_data, labels)`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Is np.int deprecated in current NumPy, and what is the recommended replacement for type annotations like NDArray[np.int]?

💡 Result:

Yes, np.int was deprecated in NumPy 1.20 and subsequently removed in NumPy 1.24 [1][2]. Attempting to use it in current versions will raise an AttributeError [3][2]. For type annotations, the recommended replacement for the deprecated np.int is to use np.int_ or an explicit fixed-precision type like np.int64 or np.int32, depending on your requirements [1][2]. When using NDArray[...], you should update your annotations to use these valid NumPy scalar types [4][5]. For example: Replace: NDArray[np.int] With: NDArray[np.int_] # For platform-dependent integer precision [1][2] OR NDArray[np.int64] # For explicit 64-bit integer precision [1][2] If your intent is simply to annotate a generic integer type and you do not require specific NumPy scalar behavior, you may also use Python's built-in int type, though NDArray typically expects a NumPy scalar type parameter for the dtype [1][2]. The np.int_ alias remains the closest equivalent to the old behavior, as it corresponds to the default system integer type [1][2].

Citations:


🏁 Script executed:

cat -n docs/docs/python/api-reference.md | sed -n '55,75p'

Repository: Ryan-Millard/Img2Num

Length of output: 655


🏁 Script executed:

fd -e txt -e cfg -e toml -e py -e lock 2>/dev/null | grep -E "(requirements|setup|pyproject|poetry)" | head -20

Repository: Ryan-Millard/Img2Num

Length of output: 145


🏁 Script executed:

cat -n pyproject.toml | head -50

Repository: Ryan-Millard/Img2Num

Length of output: 1415


🏁 Script executed:

cat packages/py/pyproject.toml

Repository: Ryan-Millard/Img2Num

Length of output: 688


Replace deprecated np.int with explicit type in documentation.

np.int was removed in NumPy 1.24. Use np.int_ for platform-dependent integer precision, or explicit np.int64/np.int32 for fixed precision in return and parameter type annotations.

Lines: 60, 70

🤖 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 `@docs/docs/python/api-reference.md` at line 60, The docs use the removed alias
NDArray[np.int]; update both occurrences (the Returns tuple shown as
NDArray[np.uint8], NDArray[np.int] and the other occurrence) to a supported
explicit integer type—replace NDArray[np.int] with NDArray[np.int_] (or
NDArray[np.int64]/NDArray[np.int32] if you need fixed width) so the
documentation uses a valid NumPy type instead of the deprecated np.int.


## Blurry or Over-Smoothed Output

Increase `sigma_spatial` or decrease it depending on the image. If it's over-smoothed, reduce it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify the tuning direction for sigma_spatial.

This sentence is self-contradictory (“increase or decrease”). Make it directional by symptom.

Suggested wording
-Increase `sigma_spatial` or decrease it depending on the image. If it's over-smoothed, reduce it.
+If output looks noisy or jagged, increase `sigma_spatial`. If output is over-smoothed or blurry, decrease `sigma_spatial`.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Increase `sigma_spatial` or decrease it depending on the image. If it's over-smoothed, reduce it.
If output looks noisy or jagged, increase `sigma_spatial`. If output is over-smoothed or blurry, decrease `sigma_spatial`.
🤖 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 `@docs/docs/troubleshooting.md` at line 32, The sentence about tuning
sigma_spatial is self-contradictory; update the text to be directional by
symptom: state that if the result is over-smoothed, decrease sigma_spatial, and
if the result is too noisy or contains speckle artifacts, increase
sigma_spatial. Edit the sentence referencing `sigma_spatial` so it clearly maps
each symptom to the proper action (e.g., "If the image is over-smoothed,
decrease `sigma_spatial`; if the image is too noisy, increase
`sigma_spatial`.").

@Ryan-Millard

Copy link
Copy Markdown
Owner

Hi @Krasner. I don't have time to debug this right now, but it's possible that the version of Docusaurus we're using isn't compatible with the syntax you're using.

I think it was v3.10 that broke the old syntax.

@Krasner

Krasner commented May 21, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @Krasner. I don't have time to debug this right now, but it's possible that the version of Docusaurus we're using isn't compatible with the syntax you're using.

I think it was v3.10 that broke the old syntax.

No worries. There are some doxygen files missing as well. This is a good experiment working with llm tools to see how well they can understand code and instructions. So far it's very slow.... (but free and local)

@Ryan-Millard

Copy link
Copy Markdown
Owner

Hi @Krasner. I don't have time to debug this right now, but it's possible that the version of Docusaurus we're using isn't compatible with the syntax you're using.

I think it was v3.10 that broke the old syntax.

No worries. There are some doxygen files missing as well. This is a good experiment working with llm tools to see how well they can understand code and instructions. So far it's very slow.... (but free and local)

CodeRabbit can do it quite well since it has our repository's context, but you have to tell it which files and so on. At the end of the day, though, AI still needs human intervention because it isn't amazing.

@Krasner
Krasner marked this pull request as ready for review May 24, 2026 14:05
@Krasner Krasner changed the title chore (docs): Update documentation docs: Update documentation May 24, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🤖 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.

Inline comments:
In `@bindings/c/src/cimg2num.cpp`:
- Around line 11-15: The return uses C++20 designated-initializer syntax which
breaks C++17 builds; update the construction of img2num::ImageToSvgConfig in the
to_cpp/to_c conversion functions to use C++17-compatible aggregate
initialization or explicit member assignment instead of `.member{...}` syntax —
e.g. replace `return {.bilateral_filter{...}, .kmeans{...}, .min_cluster_area,
.color_space}` with a plain braced aggregate `return {{...}, {...}, ..., ...}`
or build a local ImageToSvgConfig and assign bilateral_filter, kmeans,
min_cluster_area, color_space members before returning.

In `@bindings/py/doxygen/home_page.dox`:
- Line 70: Update the example call to bilateral_filter in home_page.dox to
include the required color_space argument used by the binding; locate the usage
of _img2num.bilateral_filter in the doc and add the color_space parameter
(matching the expected type/value used by the binding in img2num_pybind.cpp for
bilateral_filter) so the example signature matches the actual function
(including color_space, sigma_spatial, sigma_range).
- Line 67: The example call to _img2num.kmeans is missing the required
color_space parameter; update the usage to pass the appropriate color space
(e.g., "rgb" or the expected enum/string) as the color_space argument when
calling _img2num.kmeans so it matches the binding signature defined in
img2num_pybind.cpp and prevents the runtime error.

In `@bindings/py/src/img2num_pybind.cpp`:
- Around line 200-201: Replace the C-style casts on the pybind11::array_t
construction for out_labels and use C++ style casts: change {(ssize_t)height,
(ssize_t)width} to use static_cast<ssize_t>(height) and
static_cast<ssize_t>(width) so the pybind11::array_t<int32_t,
pybind11::array::c_style> out_labels initialization follows the project’s Google
C++ style and matches the static_cast usage in the surrounding code.

In `@docs/docs/contributing/index.md`:
- Line 13: Replace the hardcoded .md file URL in the "Code of Conduct" link in
docs/docs/contributing/index.md (the link text "Code of Conduct" currently
pointing to /docs/contributing/code-of-conduct.md) with the Docusaurus doc route
(remove the .md extension), e.g. /docs/contributing/code-of-conduct or
/docs/contributing/code-of-conduct/ so the site router resolves it correctly;
update the link target and confirm the referenced document has valid frontmatter
and is wired into the sidebar.

In `@docs/docs/index.md`:
- Around line 29-34: The table in docs/docs/index.md contains broken links for
the API references (the link text tokens like [JS API Reference], [C++ API
Reference], [C API Reference], [Python API Reference]) that currently point to
paths such as /docs/next/js/js-api-reference, /docs/next/cpp/cpp-api-reference,
etc.; update each anchor to the canonical Docusaurus routes: change the JS link
to /docs/next/js/api-reference, C++ to /docs/next/cpp/api-reference, C to
/docs/next/c/api-reference, and Python to /docs/next/python/api-reference so the
table points to the correct docs locations.

In `@docs/docs/internal/bindings/py/index.md`:
- Around line 50-73: The docs example shows a high-level API (from img2num
import gaussian_blur_fft, invert_image, threshold_image, image_to_svg) but the
actual bindings in img2num_pybind.cpp expose low-level functions that require
explicit width and height (e.g., _img2num.gaussian_blur_fft(image, width,
height, sigma)), causing a mismatch; update the example to call the real binding
signatures (use _img2num.* functions and pass width and height to
gaussian_blur_fft, invert_image, threshold_image, image_to_svg) or explicitly
state this snippet is for a higher-level wrapper and link to that wrapper
implementation, mentioning the binding file _img2num and img2num_pybind.cpp so
maintainers can reconcile the two.

In `@docs/docs/js/index.md`:
- Line 127: Update the broken API link in docs/docs/js/index.md so it points to
the actual page route for the JavaScript API reference (either the site root
route /docs/js/api-reference/ or the relative path ./api-reference.md depending
on your Docusaurus routing), replacing the incorrect target
/docs/next/js/js-api-reference/; verify the target matches the doc file
docs/docs/js/api-reference.md and that the frontmatter/sidebar config exposes
the route so the link resolves correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c596e4da-ff60-481b-9e8b-3a987bb94175

📥 Commits

Reviewing files that changed from the base of the PR and between 4f47ccb and 6bc77fd.

📒 Files selected for processing (25)
  • README.md
  • bindings/c/include/cimg2num.h
  • bindings/c/src/cimg2num.cpp
  • bindings/js/doxygen/home_page.dox
  • bindings/py/Doxyfile.internal
  • bindings/py/doxygen/home_page.dox
  • bindings/py/src/img2num_pybind.cpp
  • docs/docs/api-reference.md
  • docs/docs/concepts.md
  • docs/docs/contributing/index.md
  • docs/docs/cpp/api-reference.md
  • docs/docs/cpp/docs/index.md
  • docs/docs/getting-started.md
  • docs/docs/index.md
  • docs/docs/installation.md
  • docs/docs/internal/bindings/py/api-reference.md
  • docs/docs/internal/bindings/py/index.md
  • docs/docs/internal/index.md
  • docs/docs/js/api-reference.md
  • docs/docs/js/docs/index.md
  • docs/docs/js/index.md
  • docs/docs/performance.md
  • docs/docs/python/api-reference.md
  • docs/docs/python/index.md
  • docs/scripts/doxygen.js
💤 Files with no reviewable changes (1)
  • bindings/c/include/cimg2num.h
📜 Review details
🧰 Additional context used
📓 Path-based instructions (8)
**/*.md

📄 CodeRabbit inference engine (.editorconfig)

**/*.md: Do not trim trailing whitespace in Markdown files
Use 2-space indentation for Markdown files
Do not enforce maximum line length for Markdown files

Files:

  • docs/docs/contributing/index.md
  • docs/docs/js/docs/index.md
  • docs/docs/internal/bindings/py/index.md
  • README.md
  • docs/docs/python/index.md
  • docs/docs/js/api-reference.md
  • docs/docs/internal/bindings/py/api-reference.md
  • docs/docs/python/api-reference.md
  • docs/docs/installation.md
  • docs/docs/internal/index.md
  • docs/docs/js/index.md
  • docs/docs/getting-started.md
  • docs/docs/concepts.md
  • docs/docs/api-reference.md
  • docs/docs/cpp/docs/index.md
  • docs/docs/index.md
  • docs/docs/performance.md
  • docs/docs/cpp/api-reference.md
docs/docs/**

⚙️ CodeRabbit configuration file

docs/docs/**: All documentation must follow Docusaurus conventions (docs/docs/ folder structure).
Do NOT suggest creating strangely-named markdown files at the repository root
(e.g. COMPREHENSIVE_TEST_REPORT.md, DELIVERABLES.md, SUMMARY.md).
New docs belong either as a dedicated Docusaurus category or integrated into an
existing category such as project-scripts. Verify valid frontmatter
(title, sidebar_label, etc.) and correct sidebar wiring.

Files:

  • docs/docs/contributing/index.md
  • docs/docs/js/docs/index.md
  • docs/docs/internal/bindings/py/index.md
  • docs/docs/python/index.md
  • docs/docs/js/api-reference.md
  • docs/docs/internal/bindings/py/api-reference.md
  • docs/docs/python/api-reference.md
  • docs/docs/installation.md
  • docs/docs/internal/index.md
  • docs/docs/js/index.md
  • docs/docs/getting-started.md
  • docs/docs/concepts.md
  • docs/docs/api-reference.md
  • docs/docs/cpp/docs/index.md
  • docs/docs/index.md
  • docs/docs/performance.md
  • docs/docs/cpp/api-reference.md
bindings/**

⚙️ CodeRabbit configuration file

bindings/**: Language bindings for the Img2Num library. Ensure the public API surface matches
the core C/C++ headers and that error propagation is handled correctly for each
binding language. Also ensure the relevant docstrings are present to enable
auto-generation of documentation.

Files:

  • bindings/py/Doxyfile.internal
  • bindings/py/doxygen/home_page.dox
  • bindings/js/doxygen/home_page.dox
  • bindings/c/src/cimg2num.cpp
  • bindings/py/src/img2num_pybind.cpp
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.editorconfig)

**/*.{js,ts,jsx,tsx}: Use 2-space indentation for JavaScript and TypeScript files
Maintain 200 character maximum line length for JavaScript/TypeScript files

Files:

  • docs/scripts/doxygen.js
docs/**/*.{js,jsx,ts,tsx,mdx}

⚙️ CodeRabbit configuration file

docs/**/*.{js,jsx,ts,tsx,mdx}: This is the Docusaurus site source. Check for MDX compatibility, correct
plugin usage, and valid imports. Review docusaurus.config.js changes carefully
for broken routing or plugin config regressions.

Files:

  • docs/scripts/doxygen.js
**/*.{c,cc,cpp,cxx,h,hpp,hxx}

📄 CodeRabbit inference engine (.clang-format)

**/*.{c,cc,cpp,cxx,h,hpp,hxx}: Follow Google style guide for C/C++ code formatting
Use 4 spaces for indentation
Maintain a column limit of 100 characters per line
Do not allow short functions on a single line

Files:

  • bindings/c/src/cimg2num.cpp
  • bindings/py/src/img2num_pybind.cpp
**/*.{hpp,cpp,c,h}

📄 CodeRabbit inference engine (.editorconfig)

**/*.{hpp,cpp,c,h}: Use 4-space indentation for C/C++ files
Maintain 120 character maximum line length for C/C++ files

Files:

  • bindings/c/src/cimg2num.cpp
  • bindings/py/src/img2num_pybind.cpp
**/*.{cpp,c,h,hpp}

⚙️ CodeRabbit configuration file

**/*.{cpp,c,h,hpp}: - For any C/C++ code outside core/ (e.g. bindings, example-apps), apply the same
memory-safety and style standards as the core. Formatting via ./img2num format-cpp.

  • Doxygen docstrings are required.

Files:

  • bindings/c/src/cimg2num.cpp
  • bindings/py/src/img2num_pybind.cpp
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
Repo: Ryan-Millard/Img2Num

Timestamp: 2026-05-24T14:06:11.424Z
Learning: Use descriptive titles when reporting issues
Learnt from: CR
Repo: Ryan-Millard/Img2Num

Timestamp: 2026-05-24T14:06:11.424Z
Learning: Include steps to reproduce, expected behavior, and actual behavior when reporting bugs
Learnt from: CR
Repo: Ryan-Millard/Img2Num

Timestamp: 2026-05-24T14:06:11.424Z
Learning: Attach screenshots or logs to issue reports when applicable
Learnt from: CR
Repo: Ryan-Millard/Img2Num

Timestamp: 2026-05-24T14:06:11.424Z
Learning: Specify environment details (OS, Node.js version, browser) when reporting issues
Learnt from: CR
Repo: Ryan-Millard/Img2Num

Timestamp: 2026-05-24T14:06:11.424Z
Learning: Review and adhere to the Code of Conduct to foster an open and welcoming environment
📚 Learning: 2026-01-04T15:34:04.654Z
Learnt from: Ryan-Millard
Repo: Ryan-Millard/Img2Num PR: 146
File: docs/docs/reference/react/components/ThemeSwitch/tests.md:123-124
Timestamp: 2026-01-04T15:34:04.654Z
Learning: In Docusaurus documentation, relative directory links (e.g., ../ or ../../../hooks/useTheme) resolve to index.md within the target directory. Do not require or force linking to index.md explicitly; such relative links remain valid and should not be changed when reviewing docs under the docs directory.

Applied to files:

  • docs/docs/contributing/index.md
  • docs/docs/js/docs/index.md
  • docs/docs/internal/bindings/py/index.md
  • docs/docs/python/index.md
  • docs/docs/js/api-reference.md
  • docs/docs/internal/bindings/py/api-reference.md
  • docs/docs/python/api-reference.md
  • docs/docs/installation.md
  • docs/docs/internal/index.md
  • docs/docs/js/index.md
  • docs/docs/getting-started.md
  • docs/docs/concepts.md
  • docs/docs/api-reference.md
  • docs/docs/cpp/docs/index.md
  • docs/docs/index.md
  • docs/docs/performance.md
  • docs/docs/cpp/api-reference.md
📚 Learning: 2026-02-22T15:20:15.304Z
Learnt from: Ryan-Millard
Repo: Ryan-Millard/Img2Num PR: 263
File: docs/docs/internal/core/api-reference.md:13-13
Timestamp: 2026-02-22T15:20:15.304Z
Learning: In Docusaurus projects, Markdown files (*.md, *.mdx) may contain anchor tags with onClick={(e) => { e.preventDefault(); window.location.href = '...'; }} to force a full page navigation, bypassing React SPA routing for static/external paths. Treat this as intentional and do not flag it as redundant in docs contexts. Apply this guidance broadly to Markdown docs across the repository (not just the single file) and focus reviews on more impactful patterns such as accessibility, SEO, and navigation consistency.

Applied to files:

  • docs/docs/contributing/index.md
  • docs/docs/js/docs/index.md
  • docs/docs/internal/bindings/py/index.md
  • README.md
  • docs/docs/python/index.md
  • docs/docs/js/api-reference.md
  • docs/docs/internal/bindings/py/api-reference.md
  • docs/docs/python/api-reference.md
  • docs/docs/installation.md
  • docs/docs/internal/index.md
  • docs/docs/js/index.md
  • docs/docs/getting-started.md
  • docs/docs/concepts.md
  • docs/docs/api-reference.md
  • docs/docs/cpp/docs/index.md
  • docs/docs/index.md
  • docs/docs/performance.md
  • docs/docs/cpp/api-reference.md
📚 Learning: 2025-12-31T17:46:54.476Z
Learnt from: fransafu
Repo: Ryan-Millard/Img2Num PR: 176
File: src/wasm/modules/image/src/bilateral_filter.cpp:98-101
Timestamp: 2025-12-31T17:46:54.476Z
Learning: In bilateral_filter.cpp (src/wasm/modules/image/src/bilateral_filter.cpp), rely on the fact that the center pixel contributes a weight of exactly 1.0 to both spatial and range components (exp(0) = 1) so the normalization sum cannot be zero. This implies you do not need explicit guards against division by zero for normalization in this implementation.

Applied to files:

  • bindings/c/src/cimg2num.cpp
  • bindings/py/src/img2num_pybind.cpp
📚 Learning: 2026-01-06T04:56:57.269Z
Learnt from: Ryan-Millard
Repo: Ryan-Millard/Img2Num PR: 191
File: src/wasm/modules/image/src/kmeans.cpp:128-134
Timestamp: 2026-01-06T04:56:57.269Z
Learning: In C++ sources compiled for WASM with Emscripten/Clang, designated initializers (e.g., RGBXY{.r = ..., .g = ...}) are allowed as a C++17 extension. When reviewing code that relies on designated initializers, verify that the target toolchain enables CXX_STANDARD 17 or higher and that the build system (CMake/emsdk) uses Emscripten with a compatible clang. If not, avoid such initializers or provide portable alternatives.

Applied to files:

  • bindings/c/src/cimg2num.cpp
  • bindings/py/src/img2num_pybind.cpp
📚 Learning: 2026-01-06T21:06:24.476Z
Learnt from: Ryan-Millard
Repo: Ryan-Millard/Img2Num PR: 191
File: src/wasm/modules/image/src/cielab.cpp:43-57
Timestamp: 2026-01-06T21:06:24.476Z
Learning: In the Img2Num project, prefer recommending and using the provided docker/script wrappers (e.g., ./img2num format-wasm, ./img2num clean-wasm) instead of invoking local tools directly (e.g., clang-format -i). This reduces dependency requirements for users and ensures consistent tooling across environments. Apply this guidance to C++ source files under the project when reviewing changes.

Applied to files:

  • bindings/c/src/cimg2num.cpp
  • bindings/py/src/img2num_pybind.cpp
📚 Learning: 2026-01-19T00:02:34.957Z
Learnt from: Ryan-Millard
Repo: Ryan-Millard/Img2Num PR: 234
File: src/wasm/modules/image/src/kmeans.cpp:79-81
Timestamp: 2026-01-19T00:02:34.957Z
Learning: In C++ multithreading contexts, prefer unsigned types for thread-count-like parameters (e.g., n_threads) to prevent negative values. Validate that the value is at least 1 before any division to avoid divide-by-zero at runtime. At the start of functions handling such values, create a safe count like: const unsigned int thread_count{std::max(1u, n_threads)}; This ensures non-negative, non-zero usage for divisions and related arithmetic. Apply this pattern to similar parameters across C++ modules, not just the specific file.

Applied to files:

  • bindings/c/src/cimg2num.cpp
  • bindings/py/src/img2num_pybind.cpp
📚 Learning: 2026-02-25T21:24:19.036Z
Learnt from: Ryan-Millard
Repo: Ryan-Millard/Img2Num PR: 272
File: core/src/internal/bilateral_filter_gpu.cpp:171-185
Timestamp: 2026-02-25T21:24:19.036Z
Learning: Adopt brace initialization (e.g., Type var{}) over copy initialization (e.g., Type var = {}) for zero-initialization in C++ across the repository. This should apply to variables, arrays, and structs in most C++ files (e.g., core/src/internal/bilateral_filter_gpu.cpp). It improves safety by avoiding narrowing conversions and makes initialization intent explicit.

Applied to files:

  • bindings/c/src/cimg2num.cpp
  • bindings/py/src/img2num_pybind.cpp
📚 Learning: 2026-04-27T15:40:33.329Z
Learnt from: Ryan-Millard
Repo: Ryan-Millard/Img2Num PR: 333
File: bindings/c/src/cimg2num.cpp:0-0
Timestamp: 2026-04-27T15:40:33.329Z
Learning: In the Ryan-Millard/Img2Num C bindings (e.g., `bindings/c/src/cimg2num.cpp`) that expose `extern "C"` functions, do not allow C++ exceptions (including `std::bad_alloc` and exceptions thrown from lambdas used internally) to propagate out of these C binding functions. Use the C-API failure idiom instead: catch exceptions internally as needed, clear/record error state via the existing error mechanism, and return `nullptr` (or the documented sentinel return value) on failure so the C caller can detect errors by checking the return value.

Applied to files:

  • bindings/c/src/cimg2num.cpp
🪛 Cppcheck (2.20.0)
bindings/py/src/img2num_pybind.cpp

[style] 11-11: The function 'PYBIND11_MODULE' is never used.

(unusedFunction)

🔇 Additional comments (21)
docs/docs/concepts.md (1)

15-16: LGTM!

Also applies to: 18-18, 39-39

docs/docs/installation.md (1)

34-34: LGTM!

Also applies to: 37-37

docs/docs/getting-started.md (1)

85-87: LGTM!

docs/docs/performance.md (1)

16-16: LGTM!

Also applies to: 21-27

docs/docs/js/api-reference.md (2)

9-9: Align return types with the async contract on this page.

The page says all exported functions are async, but multiple sections still document plain object return types instead of Promise-wrapped returns.

Also applies to: 24-24, 41-41, 47-47


51-53: Use one canonical return shape for imageToUint8ClampedArray.

This section still mixes tuple and object return formats; keep one representation consistently in both the description and Returns line.

docs/docs/python/api-reference.md (2)

9-11: Resolve the width/height contract inconsistency across signatures, tables, and examples.

The page still states automatic shape-derived dimensions while documenting/using explicit keyword-only width and height. Pick one contract and apply it consistently.

Also applies to: 20-23, 29-29, 32-33, 47-48, 62-63


60-60: Replace deprecated NumPy np.int in the documented type hints.

np.int is deprecated/removed in modern NumPy; use np.int_ or a fixed-width type.

Is `np.int` removed in NumPy 1.24+, and what is the recommended replacement for annotations like `NDArray[np.int]`?

Also applies to: 70-70

bindings/py/src/img2num_pybind.cpp (5)

9-9: LGTM!


12-25: LGTM!


43-61: LGTM!

Also applies to: 73-89, 102-120, 134-152, 168-190, 210-232, 248-268, 271-308, 366-384


244-244: LGTM!


357-358: LGTM!

bindings/py/Doxyfile.internal (1)

1-14: LGTM!

bindings/py/doxygen/home_page.dox (1)

1-49: LGTM!

Also applies to: 75-95

docs/docs/internal/bindings/py/index.md (1)

1-49: LGTM!

Also applies to: 74-78

docs/docs/internal/bindings/py/api-reference.md (1)

1-23: LGTM!

docs/scripts/doxygen.js (1)

14-14: LGTM!

Also applies to: 32-36

bindings/js/doxygen/home_page.dox (1)

26-26: LGTM!

docs/docs/internal/index.md (1)

32-35: LGTM!

Also applies to: 37-37

README.md (1)

43-43: LGTM!

Comment thread bindings/c/src/cimg2num.cpp Outdated
Comment on lines +11 to +15
return {.bilateral_filter{.sigma_spatial = c.bilateral_filter.sigma_spatial,
.sigma_range = c.bilateral_filter.sigma_range},
.kmeans{.k = c.kmeans.k, .max_iter = c.kmeans.max_iter},
.min_cluster_area = c.min_cluster_area,
.color_space = c.color_space};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify C++ standard/toolchain config and scan for this initializer pattern.
rg -n "CMAKE_CXX_STANDARD|set\\(CMAKE_CXX_STANDARD" CMakeLists.txt **/CMakeLists.txt
rg -nP '\.\w+\s*\{' bindings/c/src/cimg2num.cpp

Repository: Ryan-Millard/Img2Num

Length of output: 586


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Check for any C++ standard overrides beyond the first matches.
rg -n "CMAKE_CXX_STANDARD|CMAKE_CXX_FLAGS|std=c\\+\\+|gnu\\+\\+|CXX_STANDARD|target_compile_features|set\\(CXX_STANDARD" \
  **/CMakeLists.txt **/*.cmake CMakeLists.txt || true

# 2) See whether this (non-`=`) nested designated-initializer pattern appears elsewhere.
rg -nP '\.\w+\s*\{[^}]*\.' bindings/c/src/cimg2num.cpp || true
rg -nP '\.\w+\s*\{' bindings/c/src/cimg2num.cpp || true

# 3) Confirm there are only these two specific return statements (context).
rg -n "return \\{\\." -n bindings/c/src/cimg2num.cpp && sed -n '1,140p' bindings/c/src/cimg2num.cpp || true

Repository: Ryan-Millard/Img2Num

Length of output: 5350


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Find other occurrences of ".name { ... }" style aggregates in C++.
# Use narrower regex to avoid too many brace-init false positives.
rg -nP '\.\w+\s*\{' . || true

# 2) Look for any -std= or CXXFLAGS/EM_FLAGS overrides that could bump the standard.
rg -n "(-std=c\\+\\+\\d+|CXXFLAGS|EMSDK|EMSCRIPTEN|EM_CXXFLAGS|EM_FLAGS|EM_LDFLAGS)" . || true

# 3) If the repo has JS/WASM build tooling, search for C++ standard settings there too.
rg -n "c\\+\\+\\d+|CXX_STANDARD|CMAKE_CXX_STANDARD|-std=" . || true

Repository: Ryan-Millard/Img2Num

Length of output: 24179


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for C++20-style designated initializers with '=' inside brace-init-lists.
# Limit to C/C++ sources to avoid noise.
rg -nP '\{\s*\.\w+\s*=\s*' --glob '*.{c,cc,cpp,cxx,h,hpp,hxx}' . || true

Repository: Ryan-Millard/Img2Num

Length of output: 502


🌐 Web query:

C++ designated initializer syntax without '=' .member{...} is it valid and which compilers/standards support it?

💡 Result:

Yes, the designated initializer syntax using braces without an equals sign, such as.member{value}, is valid in C++20 and later standards [1][2]. In C++20, designated initializers were introduced for aggregate initialization [1][3]. The syntax allows for both the assignment-style (.member = value) and the brace-initialization-style (.member{value}) [2]. Key points regarding this syntax: - Standard Support: This is a standard feature of C++20 and subsequent versions [1][2]. - Aggregate Initialization: It is strictly limited to aggregate types [1][2]. - Syntax Flexibility: You can use either.member = value or.member{value} [2]. These can also be mixed within the same initializer list if desired [2]. - Compiler Support: Modern compilers that support the C++20 standard (such as GCC, Clang, and MSVC) support this syntax when the appropriate standard flag (e.g., -std=c++20) is enabled [2][3]. Note that this differs from the C programming language, which requires the equals sign (.member = value) and does not support the brace-only syntax for designated initializers [1][4]. Additionally, C++ designated initializers have stricter requirements than C, such as requiring members to be initialized in their declaration order [1][2].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "CMAKE_CXX_STANDARD\s*20|CMAKE_CXX_STANDARD\s*2[0-9]|CXX_STANDARD\s*20|target_compile_options\\(|CMAKE_CXX_FLAGS.*-std=|CXXFLAGS.*-std=|-std=c\\+\\+20|-std=gnu\\+\\+20|c\\+\\+20|EM.*CXXFLAGS|EM_FLAGS" . --glob '*.{cmake,CMakeLists.txt,sh,txt,md,js,ts,py,c,h,cc,cpp,cxx,hpp,hxx}'

Repository: Ryan-Millard/Img2Num

Length of output: 1279


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "struct\\s+ImageToSvgConfig|ImageToSvgConfig\\b" core/include bindings/c/include bindings/c/src bindings/c/CMakeLists.txt --glob '*.{h,hpp,cpp,c,cc}'

Repository: Ryan-Millard/Img2Num

Length of output: 1202


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Print the C++ struct definition for ImageToSvgConfig
nl -ba core/include/img2num.h | sed -n '1,140p'

Repository: Ryan-Millard/Img2Num

Length of output: 107


🏁 Script executed:

#!/bin/bash
set -euo pipefail

cat -n core/include/img2num.h | sed -n '1,160p'

Repository: Ryan-Millard/Img2Num

Length of output: 3868


Fix C++17 build break in bindings/c/src/cimg2num.cpp

return {.member{...}, ...} uses C++20 designated-initializer syntax (.field = ... / brace form), but this repo forces CMAKE_CXX_STANDARD 17, so it can fail to compile on C++17 toolchains. Replace with C++17-compatible aggregate initialization (or explicit assignments) for img2num::ImageToSvgConfig.

Proposed fix
// to_cpp(...)
return {{c.bilateral_filter.sigma_spatial, c.bilateral_filter.sigma_range},
        {c.kmeans.k, c.kmeans.max_iter},
        c.min_cluster_area,
        c.color_space};

// to_c(...)
return {{cpp.bilateral_filter.sigma_spatial, cpp.bilateral_filter.sigma_range},
        {cpp.kmeans.k, cpp.kmeans.max_iter},
        cpp.min_cluster_area,
        cpp.color_space};
🤖 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 `@bindings/c/src/cimg2num.cpp` around lines 11 - 15, The return uses C++20
designated-initializer syntax which breaks C++17 builds; update the construction
of img2num::ImageToSvgConfig in the to_cpp/to_c conversion functions to use
C++17-compatible aggregate initialization or explicit member assignment instead
of `.member{...}` syntax — e.g. replace `return {.bilateral_filter{...},
.kmeans{...}, .min_cluster_area, .color_space}` with a plain braced aggregate
`return {{...}, {...}, ..., ...}` or build a local ImageToSvgConfig and assign
bilateral_filter, kmeans, min_cluster_area, color_space members before
returning.

Comment thread bindings/py/doxygen/home_page.dox
Comment thread bindings/py/doxygen/home_page.dox
Comment on lines +200 to +201
pybind11::array_t<int32_t, pybind11::array::c_style> out_labels(
{(ssize_t)height, (ssize_t)width});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Use static_cast instead of C-style casts.

Lines 200-201 use C-style casts (ssize_t) while lines 203-206 correctly use static_cast<>. For consistency with C++ best practices and the Google style guide, use static_cast<ssize_t>() here as well.

♻️ Proposed fix
-pybind11::array_t<int32_t, pybind11::array::c_style> out_labels(
-    {(ssize_t)height, (ssize_t)width});
+pybind11::array_t<int32_t, pybind11::array::c_style> out_labels({
+    static_cast<ssize_t>(height), static_cast<ssize_t>(width)});

As per coding guidelines, follow Google style guide for C/C++ code formatting.

🤖 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 `@bindings/py/src/img2num_pybind.cpp` around lines 200 - 201, Replace the
C-style casts on the pybind11::array_t construction for out_labels and use C++
style casts: change {(ssize_t)height, (ssize_t)width} to use
static_cast<ssize_t>(height) and static_cast<ssize_t>(width) so the
pybind11::array_t<int32_t, pybind11::array::c_style> out_labels initialization
follows the project’s Google C++ style and matches the static_cast usage in the
surrounding code.

## Code of Conduct

Please review and adhere to our [Code of Conduct](./code-of-conduct.md) to help foster an open and welcoming environment.
Please review and adhere to our [Code of Conduct](/docs/contributing/code-of-conduct.md) to help foster an open and welcoming environment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use a docs route instead of a .md URL for Code of Conduct.

This link likely bypasses Docusaurus routing and can 404 in site navigation. Point it to the docs route path instead.

Proposed fix
-Please review and adhere to our [Code of Conduct](/docs/contributing/code-of-conduct.md) to help foster an open and welcoming environment.
+Please review and adhere to our [Code of Conduct](/docs/next/contributing/code-of-conduct) to help foster an open and welcoming environment.

As per coding guidelines: "docs/docs/**: All documentation must follow Docusaurus conventions ... Verify valid frontmatter ... and correct sidebar wiring."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Please review and adhere to our [Code of Conduct](/docs/contributing/code-of-conduct.md) to help foster an open and welcoming environment.
Please review and adhere to our [Code of Conduct](/docs/next/contributing/code-of-conduct) to help foster an open and welcoming environment.
🤖 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 `@docs/docs/contributing/index.md` at line 13, Replace the hardcoded .md file
URL in the "Code of Conduct" link in docs/docs/contributing/index.md (the link
text "Code of Conduct" currently pointing to
/docs/contributing/code-of-conduct.md) with the Docusaurus doc route (remove the
.md extension), e.g. /docs/contributing/code-of-conduct or
/docs/contributing/code-of-conduct/ so the site router resolves it correctly;
update the link target and confirm the referenced document has valid frontmatter
and is wired into the sidebar.

Comment thread docs/docs/index.md
Comment on lines +29 to +34
| Binding | Status | Docs |
| :-------------------- | :------------ | :------------------------------------------------------------- |
| **JavaScript (WASM)** | ✅ Production | [JS API Reference](/docs/next/js/js-api-reference) |
| **C++** | ✅ Production | [C++ API Reference](/docs/next/cpp/cpp-api-reference) |
| **C** | ✅ Production | [C API Reference](/docs/next/c/c-api-reference) |
| **Python** | 🟡 Early | [Python API Reference](/docs/next/python/python-api-reference) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix likely broken API binding doc routes in the table.

These paths appear inconsistent with the documented file structure and likely resolve to 404s (js-api-reference, cpp-api-reference, etc.). Please point them to the canonical docs routes (e.g., /docs/next/js/api-reference, /docs/next/cpp/api-reference, /docs/next/c/api-reference, /docs/next/python/api-reference).

As per coding guidelines, "docs/docs/**: All documentation must follow Docusaurus conventions (docs/docs/ folder structure)."

🤖 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 `@docs/docs/index.md` around lines 29 - 34, The table in docs/docs/index.md
contains broken links for the API references (the link text tokens like [JS API
Reference], [C++ API Reference], [C API Reference], [Python API Reference]) that
currently point to paths such as /docs/next/js/js-api-reference,
/docs/next/cpp/cpp-api-reference, etc.; update each anchor to the canonical
Docusaurus routes: change the JS link to /docs/next/js/api-reference, C++ to
/docs/next/cpp/api-reference, C to /docs/next/c/api-reference, and Python to
/docs/next/python/api-reference so the table points to the correct docs
locations.

Comment on lines +50 to +73
```python title="Applying basic image processing operations using the Python API"
import numpy as np
from img2num import (
gaussian_blur_fft,
invert_image,
threshold_image,
image_to_svg,
)

# Load image as uint8 numpy array (H, W, C)
image = np.zeros((256, 256, 3), dtype=np.uint8)

# Apply Gaussian blur
blurred = gaussian_blur_fft(image, sigma=1.5)

# Invert colors
inverted = invert_image(blurred)

# Threshold
thresholded = threshold_image(inverted, num_thresholds=4)

# SVG conversion
svg_str = image_to_svg(thresholded)
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Usage example doesn't match actual binding signatures.

The example shows a simplified API (from img2num import ... with functions that don't require width/height), but the actual _img2num bindings (in img2num_pybind.cpp) require explicit width and height parameters for all functions. For example:

  • Example shows: gaussian_blur_fft(image, sigma=1.5)
  • Binding requires: _img2num.gaussian_blur_fft(image, width, height, sigma=2.0)

This discrepancy will confuse developers. Either:

  1. Update the example to use the correct _img2num low-level API (matching home_page.dox lines 58-74), or
  2. If a high-level img2num wrapper exists, clarify that this example is for the wrapper and link to its implementation.
📝 Suggested fix to match actual bindings
-import numpy as np
-from img2num import (
-    gaussian_blur_fft,
-    invert_image,
-    threshold_image,
-    image_to_svg,
-)
+import numpy as np
+import _img2num

 # Load image as uint8 numpy array (H, W, C)
 image = np.zeros((256, 256, 3), dtype=np.uint8)
+width, height = image.shape[1], image.shape[0]

 # Apply Gaussian blur
-blurred = gaussian_blur_fft(image, sigma=1.5)
+blurred = _img2num.gaussian_blur_fft(image, width, height, sigma=1.5)

 # Invert colors
-inverted = invert_image(blurred)
+inverted = _img2num.invert_image(blurred, width, height)

 # Threshold
-thresholded = threshold_image(inverted, num_thresholds=4)
+thresholded = _img2num.threshold_image(inverted, width, height, num_thresholds=4)

 # SVG conversion
-svg_str = image_to_svg(thresholded)
+config = _img2num.ImageToSvgConfig()
+svg_str = _img2num.image_to_svg(thresholded, width, height, config)
🤖 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 `@docs/docs/internal/bindings/py/index.md` around lines 50 - 73, The docs
example shows a high-level API (from img2num import gaussian_blur_fft,
invert_image, threshold_image, image_to_svg) but the actual bindings in
img2num_pybind.cpp expose low-level functions that require explicit width and
height (e.g., _img2num.gaussian_blur_fft(image, width, height, sigma)), causing
a mismatch; update the example to call the real binding signatures (use
_img2num.* functions and pass width and height to gaussian_blur_fft,
invert_image, threshold_image, image_to_svg) or explicitly state this snippet is
for a higher-level wrapper and link to that wrapper implementation, mentioning
the binding file _img2num and img2num_pybind.cpp so maintainers can reconcile
the two.

Comment thread docs/docs/js/index.md
- [Documentation](./docs/)
- [API usage](./api/)
- [Documentation](/docs/next/js/docs/)
- [API usage](/docs/next/js/js-api-reference/)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix API link target to match the actual docs route.

/docs/next/js/js-api-reference/ likely does not map to the provided docs/docs/js/api-reference.md page.

Proposed fix
-- [API usage](/docs/next/js/js-api-reference/)
+- [API usage](/docs/next/js/api-reference/)

As per coding guidelines: "docs/docs/**: All documentation must follow Docusaurus conventions ... Verify valid frontmatter ... and correct sidebar wiring."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- [API usage](/docs/next/js/js-api-reference/)
- [API usage](/docs/next/js/api-reference/)
🤖 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 `@docs/docs/js/index.md` at line 127, Update the broken API link in
docs/docs/js/index.md so it points to the actual page route for the JavaScript
API reference (either the site root route /docs/js/api-reference/ or the
relative path ./api-reference.md depending on your Docusaurus routing),
replacing the incorrect target /docs/next/js/js-api-reference/; verify the
target matches the doc file docs/docs/js/api-reference.md and that the
frontmatter/sidebar config exposes the route so the link resolves correctly.

@Ryan-Millard

Copy link
Copy Markdown
Owner

@Krasner

Just to let you know, my PC is acting up, so I might not be able to work on this repository very much for like the next month or so. I'll still tey, though.

That doesn't mean that I don't appreciate the contributions you make. You consistently add value and make this place much more enjoyable.

I wanted to publish the Python package, but I'm not sure how feasible that will be on my laptop. I'll see tomorrow.

@Krasner

Krasner commented May 25, 2026

Copy link
Copy Markdown
Collaborator Author

@Krasner

Just to let you know, my PC is acting up, so I might not be able to work on this repository very much for like the next month or so. I'll still tey, though.

That doesn't mean that I don't appreciate the contributions you make. You consistently add value and make this place much more enjoyable.

I wanted to publish the Python package, but I'm not sure how feasible that will be on my laptop. I'll see tomorrow.

No worries. Take your time!

@Ryan-Millard
Ryan-Millard changed the base branch from main to dev May 27, 2026 21:50
@Ryan-Millard

Copy link
Copy Markdown
Owner

@Krasner, I have added a new branch - dev - which you should have sufficient permissions to push to. I have been meaning to create it for a while so you could have a way to consistently merge and maintain the code. Everything that goes onto main from now on should be better-tested than it has before - this will also save us from buggy releases.

Please let me know if you have any troubles with it. Also, feel free to merge this PR into that branch whenever you feel happy do so. :)

@Krasner

Krasner commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

Cool! What do you suggest the PR workflow is in general?
Does a user submit a PR to the dev branch and then you merge the dev branch to main after some testing?

@Krasner

Krasner commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

I think we still need your PR #398 to be merged for all the ci checks to take effect.

@Ryan-Millard

Ryan-Millard commented May 29, 2026

Copy link
Copy Markdown
Owner

Cool! What do you suggest the PR workflow is in general? Does a user submit a PR to the dev branch and then you merge the dev branch to main after some testing?

Yes. That is basically it. I need to update the docs for this flow, but that is precisely the plan.

flowchart TD

A[Whoever's branch] --> B[PR to dev]
B --> C[Code review and CI]
C --> D[Merge into dev]

D --> E[Integration testing on dev]
E --> F{Ready for release}

F -- No --> A

F -- Yes --> G["Merge dev into main<br />(fast-forward-only: --ff-only)"]

G --> H[Main updated]
H --> I[Release Please triggered]

I --> J[Release PR created or updated]
J --> K[Changelog and version bump]

K --> L[Git tag and GitHub release]
L --> M[Artifacts published]

M --> N[Optional sync main back to dev]
N --> D
Loading

@Ryan-Millard

Ryan-Millard commented May 29, 2026

Copy link
Copy Markdown
Owner

I think we still need your PR #398 to be merged for all the ci checks to take effect.

Yes. I wanted to set up the releases first so I could more easily debug that setup.


What is your timezone, by the way? It seems like we almost always miss each other.

Mine is GMT+2.

@Krasner

Krasner commented May 29, 2026

Copy link
Copy Markdown
Collaborator Author

I think we still need your PR #398 to be merged for all the ci checks to take effect.

Yes. I wanted to set up the releases first so I could more easily debug that setup.

What is your timezone, by the way? It seems like we almost always miss each other.

Mine is GMT+2.

GMT -4 (-5 if daylight saving) so we're 6 or 7 hours apart

@Ryan-Millard

Copy link
Copy Markdown
Owner

Hi @Krasner. What's the status with this?

@Krasner

Krasner commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @Krasner. What's the status with this?

Haven't worked on it more. But it's mostly complete. Had some trouble documenting packages/py vs bindings/py. The main issue is that packages/py creates img2num while bindings/py makes _img2num. So it's a bit strange to document. I mostly used LLMs to generate docs but they do look ok.

I know it's a major pain to review...

@Krasner

Krasner commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@Ryan-Millard because the Dockerfile has been updated to have users root and dev, the path /opt/emsdk/ is under root ownership. Building js bindings is not able to download emdawngpu port. On my local instance you should see:

ports:INFO: retrieving port: emdawnwebgpu from https://github.com/google/dawn/releases/download/v20250531.224602/emdawnwebgpu_pkg-v20250531.224602.zip
ports:INFO: unpacking port: emdawnwebgpu

but right now in the ci build you see:

PermissionError: [Errno 13] Permission denied: '/opt/emsdk/upstream/emscripten/cache/ports'

I think you need to add chown -R dev:dev /opt/emsdk/ to the Dockerfile.dev
I'll try right now...

@Krasner

Krasner commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

/docker-build c5de571

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

🐳 Docker image built successfully!

Image

ghcr.io/ryan-millard/img2num-dev:pr-388

Run it locally:

  • Bash:
    ./img2num --ghcr-img pr-388 sh
  • Powershell:
    .\img2num.ps1 --ghcr-img pr-388 sh
  • CMD:
    .\img2num.bat --ghcr-img pr-388 sh

@Krasner

Krasner commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@Ryan-Millard because the Dockerfile has been updated to have users root and dev, the path /opt/emsdk/ is under root ownership. Building js bindings is not able to download emdawngpu port. On my local instance you should see:

ports:INFO: retrieving port: emdawnwebgpu from https://github.com/google/dawn/releases/download/v20250531.224602/emdawnwebgpu_pkg-v20250531.224602.zip
ports:INFO: unpacking port: emdawnwebgpu

but right now in the ci build you see:

PermissionError: [Errno 13] Permission denied: '/opt/emsdk/upstream/emscripten/cache/ports'

I think you need to add chown -R dev:dev /opt/emsdk/ to the Dockerfile.dev I'll try right now...

Yep that is the fix!

@Ryan-Millard

Ryan-Millard commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Hi @Krasner. What's the status with this?

Haven't worked on it more. But it's mostly complete. Had some trouble documenting packages/py vs bindings/py. The main issue is that packages/py creates img2num while bindings/py makes _img2num. So it's a bit strange to document. I mostly used LLMs to generate docs but they do look ok.

I know it's a major pain to review...

We could change their names. They don't really matter in Python.

@Ryan-Millard because the Dockerfile has been updated to have users root and dev, the path /opt/emsdk/ is under root ownership. Building js bindings is not able to download emdawngpu port. On my local instance you should see:

ports:INFO: retrieving port: emdawnwebgpu from https://github.com/google/dawn/releases/download/v20250531.224602/emdawnwebgpu_pkg-v20250531.224602.zip
ports:INFO: unpacking port: emdawnwebgpu

but right now in the ci build you see:

PermissionError: [Errno 13] Permission denied: '/opt/emsdk/upstream/emscripten/cache/ports'

I think you need to add chown -R dev:dev /opt/emsdk/ to the Dockerfile.dev I'll try right now...

That would fix it, but it would also make future changes in the environment slightly more complex. I did it because it's theoretically safer, but I don't know how much safety it actually gives us - it is just a development environment after all.

Which do you think I should do?

  1. Update the container to give dev the appropriate permissions.
  2. Remove the dev user entirely and revert back to the root user like we previously had.

One thing I did notice that raised a red flag in this PR is that the LLM didn't realise that we use Doxygen. Since Doxygen doesn't integrate with Docusaurus very well (it outputs HTML, whereas Docusaurus is markdown-based), we use iframe to display it inside the Docusaurus pages (see here).

We'll just need to rectify that in this PR.

It's kind of a hack, but it was more convenient that setting up and maintaining something that does:

flowchart TD

A["Doxygen-generated XML"]
B["XML-to-markdown conversion too (e.g., doxybook2)"]
C["Markdown"]

A --> B
B --> C
Loading

The problem is that Doxygen is designed to be a standalone site and we don't use it that way.

@Krasner

Krasner commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Which do you think I should do?

  1. Update the container to give dev the appropriate permissions.
  2. Remove the dev user entirely and revert back to the root user like we previously had.

In the Dockerfile fix I did option 1 - gave USER dev ownership of the /opt/emsdk folder

@Krasner

Krasner commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

One thing I did notice that raised a red flag in this PR is that the LLM didn't realise that we use Doxygen. Since Doxygen doesn't integrate with Docusaurus very well (it outputs HTML, whereas Docusaurus is markdown-based), we use iframe to display it inside the Docusaurus pages (see here).

Actually I think it used iframe correctly. Here is the new python bindings docs when I run docusaurus locally
image

@Ryan-Millard

Copy link
Copy Markdown
Owner

One thing I did notice that raised a red flag in this PR is that the LLM didn't realise that we use Doxygen. Since Doxygen doesn't integrate with Docusaurus very well (it outputs HTML, whereas Docusaurus is markdown-based), we use iframe to display it inside the Docusaurus pages (see here).

Actually I think it used iframe correctly. Here is the new python bindings docs when I run docusaurus locally
image

Did it move it? When I briefly looked through the changes on this PR, it showed that the page that previously had it changed.

@Krasner

Krasner commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Hmm some of the links as I click thru are broken...

@Ryan-Millard

Copy link
Copy Markdown
Owner

As per @Krasner's suggestion to close this on #439 - a replacement will come soon.

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

Labels

build-system c/c++ Changes to C or C++ files core documentation js/ts python changes to python bindings or python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: document all changes introduced in #335

2 participants