| 90 | } |
| 91 | |
| 92 | Valdi::Result<ImageInfo> getImageInfo(const Valdi::StringBox& imageFilePath) { |
| 93 | auto imageSize = processImage<std::pair<int, int>>( |
| 94 | imageFilePath, |
| 95 | [&](auto bytes) -> Valdi::Result<std::pair<int, int>> { |
| 96 | auto image = Image::make(bytes); |
| 97 | if (!image) { |
| 98 | return image.moveError(); |
| 99 | } |
| 100 | |
| 101 | return std::make_pair(image.value()->width(), image.value()->height()); |
| 102 | }, |
| 103 | [&](auto bytes) { return SVGRenderer::getSize(bytes.data(), bytes.size()); }); |
| 104 | |
| 105 | if (!imageSize) { |
| 106 | return imageSize.moveError(); |
| 107 | } |
| 108 | |
| 109 | ImageInfo info; |
| 110 | info.width = static_cast<uint32_t>(imageSize.value().first); |
| 111 | info.height = static_cast<uint32_t>(imageSize.value().second); |
| 112 | |
| 113 | return info; |
| 114 | } |
| 115 | |
| 116 | Valdi::Result<Valdi::BytesView> outputImageInfo(const Valdi::StringBox& imageFilePath) { |
| 117 | auto imageInfo = getImageInfo(imageFilePath); |