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

Function processImage

libs/image_toolbox/src/image_toolbox/ImageToolbox.cpp:24–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23template<typename R>
24static Valdi::Result<R> processImage(const Valdi::StringBox& imageFilePath,
25 ProcessImageFn<R>&& defaultHandler,
26 ProcessImageFn<R>&& svgHandler) {
27 Valdi::Path path(imageFilePath.toStringView());
28 auto loadResult = Valdi::DiskUtils::load(path);
29 if (!loadResult) {
30 return loadResult.moveError();
31 }
32
33 auto fileBytes = loadResult.moveValue();
34
35 if (path.getFileExtension() == "svg") {
36 return svgHandler(fileBytes);
37 } else {
38 return defaultHandler(fileBytes);
39 }
40}
41
42static Valdi::Result<Ref<Image>> loadImage(const Valdi::StringBox& imageFilePath,
43 const std::optional<int>& widthHint,

Callers

nothing calls this directly

Calls 3

loadFunction · 0.85
getFileExtensionMethod · 0.80
toStringViewMethod · 0.45

Tested by

no test coverage detected