fix: skip jimp processing for SVGs and prevent image-fill collapse#298
Merged
fix: skip jimp processing for SVGs and prevent image-fill collapse#298
Conversation
Two fixes: 1. SVGs are vector files that jimp can't parse. Skip dimension detection and cropping for SVG downloads — just save the file. Previously this crashed with "Could not find MIME for Buffer". 2. The SVG container collapse logic was swallowing frames that contain image fills. A carousel with 4 image-filled children would cascade- collapse into a single IMAGE-SVG node, losing all child structure. Now checks for image fills in the subtree before collapsing.
afterChildren runs bottom-up, so if a deeper descendant has image fills, its parent won't collapse and stays FRAME—which isn't SVG-eligible, naturally breaking the cascade. No need to walk the full subtree.
medyas
pushed a commit
to YassineValue/Figma-Context-MCP
that referenced
this pull request
Mar 22, 2026
- Replace sharp (native C++) with jimp (pure JS) for image processing - Add --image-dir/IMAGE_DIR config for controlling image download path - Skip jimp processing for SVGs, prevent image-fill collapse in SVG containers - Handle drive root paths in image directory security check (Windows) - Add defense-in-depth path check in downloadFigmaImage - Add filenameSuffix regex validation
compassalessandrolorenz
pushed a commit
to compassalessandrolorenz/Figma-Context-MCP-AIR
that referenced
this pull request
Mar 25, 2026
…Lips#298) * fix: skip jimp processing for SVGs and prevent image-fill collapse Two fixes: 1. SVGs are vector files that jimp can't parse. Skip dimension detection and cropping for SVG downloads — just save the file. Previously this crashed with "Could not find MIME for Buffer". 2. The SVG container collapse logic was swallowing frames that contain image fills. A carousel with 4 image-filled children would cascade- collapse into a single IMAGE-SVG node, losing all child structure. Now checks for image fills in the subtree before collapsing. * perf: check only direct children for image fills during SVG collapse afterChildren runs bottom-up, so if a deeper descendant has image fills, its parent won't collapse and stays FRAME—which isn't SVG-eligible, naturally breaking the cascade. No need to walk the full subtree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
collapseSvgContainerslogic was cascade-collapsing frames containing image fills into a singleIMAGE-SVGnode. A carousel with 4 image-filled children would lose all its structure. Now checks for image fills in the subtree before collapsing.Test plan