Expose PNG metadata in pano cli
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
BIN
tests/data/images/tiny-rgba-header.png
Normal file
BIN
tests/data/images/tiny-rgba-header.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 B |
@@ -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 <fstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
@@ -166,9 +168,33 @@ int inspect_image(int argc, char** argv)
|
||||
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\":\""
|
||||
<< 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user