Expose PNG metadata in pano cli

This commit is contained in:
2026-06-01 09:01:21 +02:00
parent c62bc4d744
commit f6d3de8cbf
5 changed files with 41 additions and 4 deletions

View File

@@ -89,6 +89,8 @@ Known local toolchain state:
including foundation event/logging/task queue coverage, PNG metadata, PPI including foundation event/logging/task queue coverage, PNG metadata, PPI
header, settings document, paint brush/stroke coverage, UI color parsing, and header, settings document, paint brush/stroke coverage, UI color parsing, and
layout XML parse coverage. 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 - `panopainter_validate_shaders` validates the current combined GLSL shader
files for one vertex stage marker, one fragment stage marker, valid marker files for one vertex stage marker, one fragment stage marker, valid marker
order, and existing relative includes. order, and existing relative includes.

View File

@@ -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 the paint blend reference. `pp_ui_core` has started with XML-layout-facing
length parsing, color parsing, tinyxml-backed layout XML parsing, and invalid length parsing, color parsing, tinyxml-backed layout XML parsing, and invalid
input tests. input tests.
`pano_cli parse-layout` now exercises that path. Continue expanding document `pano_cli inspect-image` exposes PNG IHDR metadata as JSON, and
behavior toward legacy Canvas parity and then port OpenGL classes behind the `pano_cli parse-layout` exercises the XML layout path. Continue expanding
renderer boundary. document behavior toward legacy Canvas parity and then port OpenGL classes
behind the renderer boundary.
Implementation tasks: Implementation tasks:
@@ -568,6 +569,8 @@ Results:
- `pano_cli_create_document_smoke` passed. - `pano_cli_create_document_smoke` passed.
- `pano_cli_inspect_image_rejects_unsupported` passed as an expected failure - `pano_cli_inspect_image_rejects_unsupported` passed as an expected failure
test. test.
- `pano_cli_inspect_png_metadata_smoke` passed and reports PNG metadata JSON
for the tiny IHDR fixture.
- `pano_cli_parse_layout_smoke` passed. - `pano_cli_parse_layout_smoke` passed.
- `panopainter_validate_shaders` passed, validating 25 shader programs and 7 - `panopainter_validate_shaders` passed, validating 25 shader programs and 7
shader includes for stage markers and include graph integrity. shader includes for stage markers and include graph integrity.

View File

@@ -208,6 +208,12 @@ if(TARGET pano_cli)
LABELS "assets;integration;desktop-fast" LABELS "assets;integration;desktop-fast"
WILL_FAIL TRUE) 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 add_test(NAME pano_cli_parse_layout_smoke
COMMAND pano_cli parse-layout --path "${CMAKE_CURRENT_SOURCE_DIR}/data/layouts/simple-layout.xml") COMMAND pano_cli parse-layout --path "${CMAKE_CURRENT_SOURCE_DIR}/data/layouts/simple-layout.xml")
set_tests_properties(pano_cli_parse_layout_smoke PROPERTIES set_tests_properties(pano_cli_parse_layout_smoke PROPERTIES

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 B

View File

@@ -1,4 +1,5 @@
#include "assets/image_format.h" #include "assets/image_format.h"
#include "assets/image_metadata.h"
#include "assets/ppi_header.h" #include "assets/ppi_header.h"
#include "document/document.h" #include "document/document.h"
#include "foundation/parse.h" #include "foundation/parse.h"
@@ -9,6 +10,7 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
#include <span>
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <vector> #include <vector>
@@ -166,9 +168,33 @@ int inspect_image(int argc, char** argv)
return 2; return 2;
} }
pp::foundation::Result<pp::assets::ImageMetadata> metadata =
pp::foundation::Result<pp::assets::ImageMetadata>::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<const std::byte>(data, chars.size()));
if (!metadata) {
print_error("inspect-image", metadata.status().message);
return 2;
}
}
std::cout << "{\"ok\":true,\"command\":\"inspect-image\",\"format\":\"" std::cout << "{\"ok\":true,\"command\":\"inspect-image\",\"format\":\""
<< pp::assets::image_format_name(format.value()) << 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<int>(metadata.value().bit_depth)
<< ",\"components\":" << static_cast<int>(metadata.value().components)
<< ",\"colorType\":\"" << pp::assets::image_color_type_name(metadata.value().color_type)
<< "\"}";
} else {
std::cout << ",\"metadata\":null";
}
std::cout << "}\n";
return 0; return 0;
} }