Skip to content

fix: skip jimp processing for SVGs and prevent image-fill collapse#298

Merged
GLips merged 2 commits intomainfrom
fix/svg-dimension-processing
Mar 19, 2026
Merged

fix: skip jimp processing for SVGs and prevent image-fill collapse#298
GLips merged 2 commits intomainfrom
fix/svg-dimension-processing

Conversation

@GLips
Copy link
Copy Markdown
Owner

@GLips GLips commented Mar 19, 2026

Summary

  • SVG download fix: Skip jimp dimension detection and cropping for SVG files — they're vector and jimp can't parse them. Previously crashed with "Could not find MIME for Buffer".
  • SVG collapse fix: The collapseSvgContainers logic was cascade-collapsing frames containing image fills into a single IMAGE-SVG node. A carousel with 4 image-filled children would lose all its structure. Now checks for image fills in the subtree before collapsing.

Test plan

  • Existing image processing tests pass
  • Verified SVG download succeeds (button.svg from test Figma file)
  • Verified carousel node now returns 4 child frames with image fills instead of a single IMAGE-SVG
  • PNG download with cropping still works correctly

GLips added 2 commits March 19, 2026 12:26
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.
@GLips GLips merged commit a4a4b13 into main Mar 19, 2026
1 check passed
@GLips GLips deleted the fix/svg-dimension-processing branch March 19, 2026 20:48
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant