MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getImageInfo

Function getImageInfo

libs/image_toolbox/src/image_toolbox/ImageToolbox.cpp:92–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92Valdi::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
116Valdi::Result<Valdi::BytesView> outputImageInfo(const Valdi::StringBox& imageFilePath) {
117 auto imageInfo = getImageInfo(imageFilePath);

Callers 2

outputImageInfoFunction · 0.85
imagetoolbox_get_sizeFunction · 0.85

Calls 6

getSizeFunction · 0.85
valueMethod · 0.65
widthMethod · 0.45
heightMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected