Feature/237 raw image import - #58
Conversation
Image formats impose different data type and value-range constraints, while the existing export path offered no shared way to normalize data, handle non-finite values, or prevent unsafe conversions. Add an opt-in preparation backend that produces format-compatible image data while preserving the exact legacy behavior when no export parameters are provided. * [NEW] : Add ImageExportParam with normalization, range handling, target data type, and non-finite value policies * [NEW] : Add format-aware preparation with supported data type validation and overflow-safe conversion * [CHG] : Extend write_image with optional export parameters while keeping the original delegation path unchanged for param=None * [NEW] : Export the image preparation API through sigima.io, sigima.io.image, and sigima.params * [NEW] : Add focused tests for legacy behavior, source preservation, normalization, non-finite values, conversions, and format constraints * [NEW] : Add French translations for the image export parameters
Raw camera files require explicit binary layout information that ordinary image formats infer from their headers. * [NEW] : Add streaming RAW decoding with dimensions, framing, byte order and cancellation support * [CHG] : Route optional import parameters through the image registry while preserving legacy handlers * [NEW] : Export RAW parameters and cover registry compatibility, validation and translations
Define per-format capabilities and strict writer validation for all built-in image exports. Propagate Pillow, tifffile, text, and MAT options through a shared preparation path, provide exact in-memory previews, preserve coordinated text metadata, and cover the behavior with focused tests and French translations.
…-raw-image-import # Conflicts: # sigima/io/__init__.py # sigima/io/image/__init__.py # sigima/io/image/base.py # sigima/locale/fr/LC_MESSAGES/sigima.po
The coordinated text writer imported the Sigima package root only to read its version, creating a cycle while the root loaded the I/O registry. Package metadata now lives in a dependency-free module and remains re-exported by Sigima. * [FIX] : Centralize package metadata in sigima._metadata * [FIX] : Read the version without importing the package root * [CHG] : Point setuptools version metadata to the new module
|
@ThomasMalletCodra The remaining lint issues are fixed in eda56ab. The VS Code Ruff and Pylint tasks pass, and all required CI checks are green. |
There was a problem hiding this comment.
🟡 Changes recommended
There are confirmed runtime issues in the new text export options path (complex dtype handling) and an avoidable large-memory copy in the export write path.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR extends Sigima’s headless I/O layer with (1) parameterized RAW image import and (2) format-aware image export preparation (normalization, dtype conversion, backend-specific writer options), while preserving legacy registry/read/write behavior where possible.
Changes:
- Added a dedicated RAW image reader (
RawImageFormat) with aRawImageImportParamdataset and comprehensive tests (dtype/endianness, layout validation, cancellation/progress). - Introduced an image export capability model +
ImageExportParamand wired export-option-aware writing throughwrite_imageand image formats, with extensive test coverage. - Updated registry/filter behavior and public exports (
sigima.io,sigima.params) and centralized package metadata intosigima._metadata.
File summaries
| File | Description |
|---|---|
| sigima/tests/io/raw_image_unit_test.py | Adds unit tests for RAW import parameters, layout validation, progress/cancel behavior, and public exports. |
| sigima/tests/io/ioregistry_unit_test.py | Updates registry tests for new filter grouping behavior and legacy reader signature compatibility. |
| sigima/tests/io/image_export_unit_test.py | Adds extensive tests for export normalization, dtype conversion, option validation/translation, and preview round-trips. |
| sigima/tests/io/coordinated_text_format_unit_test.py | Adds coverage for delimiter/precision options when exporting coordinated (non-uniform) text images. |
| sigima/params.py | Re-exports new I/O parameter datasets and updates parameter documentation listings. |
| sigima/locale/fr/LC_MESSAGES/sigima.po | Adds French translations for new export/import parameter UI strings. |
| sigima/io/image/raw.py | Implements parameterized RAW image import format + parameter dataset. |
| sigima/io/image/formats.py | Extends image formats to accept optional read params, adds export-option-aware writing, improves coordinated text writer, and switches version source. |
| sigima/io/image/export.py | Adds export capabilities model, option validation, safe conversion pipeline, and preview encoding/decoding helpers. |
| sigima/io/image/base.py | Extends image registry to accept optional read params and customizes save-filter generation; adds write_with_options. |
| sigima/io/image/init.py | Exposes new export/raw APIs from the image I/O package. |
| sigima/io/convenience.py | Extends convenience read APIs with optional read params; adds format-aware export path to write_image. |
| sigima/io/init.py | Re-exports new image export/import API surface at the top-level I/O module. |
| sigima/_metadata.py | Introduces centralized package metadata (version and URLs). |
| sigima/init.py | Imports and re-exports metadata symbols from sigima._metadata. |
| pyproject.toml | Points dynamic version resolution to sigima._metadata.__version__. |
Review details
- Files reviewed: 16/16 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if np.issubdtype(obj.data.dtype, np.integer): | ||
| fmt = "%d" | ||
| elif np.issubdtype(obj.data.dtype, np.floating) or np.issubdtype( | ||
| obj.data.dtype, np.complexfloating | ||
| ): | ||
| fmt = f"%.{values['precision']}e" | ||
| else: | ||
| raise NotImplementedError( | ||
| f"Writing data of type {obj.data.dtype} to text file is not supported." | ||
| ) | ||
| np.savetxt(filename, obj.data, fmt=fmt, delimiter=delimiter) |
| exported_image = copy.deepcopy(image) | ||
| exported_image.data = prepare_image_for_export(image.data, filename, param) |
No description provided.