diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index 600c084..ce9c976 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -89,6 +89,8 @@ Known local toolchain state: including foundation event/logging/task queue coverage, PNG metadata, PPI header, settings document, paint brush/stroke coverage, UI color parsing, and layout XML parse coverage. +- `pano_cli inspect-image` reports PNG IHDR metadata as JSON and is covered by + `pano_cli_inspect_png_metadata_smoke` with a tiny IHDR fixture. - `panopainter_validate_shaders` validates the current combined GLSL shader files for one vertex stage marker, one fragment stage marker, valid marker order, and existing relative includes. diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index eab389f..3ee93d0 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -322,9 +322,10 @@ started with deterministic CPU layer compositing over renderer extents using the paint blend reference. `pp_ui_core` has started with XML-layout-facing length parsing, color parsing, tinyxml-backed layout XML parsing, and invalid input tests. -`pano_cli parse-layout` now exercises that path. Continue expanding document -behavior toward legacy Canvas parity and then port OpenGL classes behind the -renderer boundary. +`pano_cli inspect-image` exposes PNG IHDR metadata as JSON, and +`pano_cli parse-layout` exercises the XML layout path. Continue expanding +document behavior toward legacy Canvas parity and then port OpenGL classes +behind the renderer boundary. Implementation tasks: @@ -568,6 +569,8 @@ Results: - `pano_cli_create_document_smoke` passed. - `pano_cli_inspect_image_rejects_unsupported` passed as an expected failure test. +- `pano_cli_inspect_png_metadata_smoke` passed and reports PNG metadata JSON + for the tiny IHDR fixture. - `pano_cli_parse_layout_smoke` passed. - `panopainter_validate_shaders` passed, validating 25 shader programs and 7 shader includes for stage markers and include graph integrity. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 27326e2..50b41df 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -208,6 +208,12 @@ if(TARGET pano_cli) LABELS "assets;integration;desktop-fast" WILL_FAIL TRUE) + add_test(NAME pano_cli_inspect_png_metadata_smoke + COMMAND pano_cli inspect-image --path "${CMAKE_CURRENT_SOURCE_DIR}/data/images/tiny-rgba-header.png") + set_tests_properties(pano_cli_inspect_png_metadata_smoke PROPERTIES + LABELS "assets;integration;desktop-fast" + PASS_REGULAR_EXPRESSION "\"format\":\"png\".*\"width\":320.*\"height\":240.*\"components\":4.*\"colorType\":\"rgba\"") + add_test(NAME pano_cli_parse_layout_smoke COMMAND pano_cli parse-layout --path "${CMAKE_CURRENT_SOURCE_DIR}/data/layouts/simple-layout.xml") set_tests_properties(pano_cli_parse_layout_smoke PROPERTIES diff --git a/tests/data/images/tiny-rgba-header.png b/tests/data/images/tiny-rgba-header.png new file mode 100644 index 0000000..1f2740d Binary files /dev/null and b/tests/data/images/tiny-rgba-header.png differ diff --git a/tools/pano_cli/main.cpp b/tools/pano_cli/main.cpp index d0e12c3..6d21882 100644 --- a/tools/pano_cli/main.cpp +++ b/tools/pano_cli/main.cpp @@ -1,4 +1,5 @@ #include "assets/image_format.h" +#include "assets/image_metadata.h" #include "assets/ppi_header.h" #include "document/document.h" #include "foundation/parse.h" @@ -9,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -166,9 +168,33 @@ int inspect_image(int argc, char** argv) return 2; } + pp::foundation::Result metadata = + pp::foundation::Result::failure( + pp::foundation::Status::invalid_argument("image metadata is unavailable")); + if (format.value() == pp::assets::ImageFormat::png) { + metadata = pp::assets::parse_png_metadata(std::span(data, chars.size())); + if (!metadata) { + print_error("inspect-image", metadata.status().message); + return 2; + } + } + std::cout << "{\"ok\":true,\"command\":\"inspect-image\",\"format\":\"" << pp::assets::image_format_name(format.value()) - << "\",\"bytes\":" << chars.size() << "}\n"; + << "\",\"bytes\":" << chars.size(); + + if (metadata) { + std::cout << ",\"metadata\":{\"width\":" << metadata.value().width + << ",\"height\":" << metadata.value().height + << ",\"bitDepth\":" << static_cast(metadata.value().bit_depth) + << ",\"components\":" << static_cast(metadata.value().components) + << ",\"colorType\":\"" << pp::assets::image_color_type_name(metadata.value().color_type) + << "\"}"; + } else { + std::cout << ",\"metadata\":null"; + } + + std::cout << "}\n"; return 0; }