MCPcopy Create free account
hub / github.com/acking-you/static_flow / rasterize_svg_for_embedding

Function rasterize_svg_for_embedding

crates/cli/src/utils.rs:152–171  ·  view source on GitHub ↗
(
    path: &Path,
    bytes: &[u8],
)

Source from the content-addressed store, hash-verified

150}
151
152pub fn rasterize_svg_for_embedding(
153 path: &Path,
154 bytes: &[u8],
155) -> Result<Option<RasterizedSvgForEmbedding>> {
156 if !is_svg_extension(path) && !looks_like_svg(bytes) {
157 return Ok(None);
158 }
159
160 match rasterize_svg_to_png(bytes, SVG_EMBED_MAX_SIDE) {
161 Ok(rasterized) => Ok(Some(rasterized)),
162 Err(err) => {
163 tracing::warn!(
164 "Failed to rasterize SVG for embedding (fallback to raw bytes): path={}, \
165 error={err}",
166 path.display()
167 );
168 Ok(None)
169 },
170 }
171}
172
173pub fn collect_markdown_files(dir: &Path, recursive: bool) -> Result<Vec<PathBuf>> {
174 let mut files = Vec::new();

Callers 4

reembed_svg_imagesFunction · 0.85
runFunction · 0.85
build_image_recordFunction · 0.85
build_image_recordFunction · 0.85

Calls 3

is_svg_extensionFunction · 0.85
looks_like_svgFunction · 0.85
rasterize_svg_to_pngFunction · 0.85

Tested by

no test coverage detected