Figma Support Forum

SVG export of image layers still very complex

  1. Describe the problem your experiencing and how your idea helps solve this
    I have read this blog by Figma where in they have improved export of SVG files and it’s a great step.
    With Figma’s new SVG Exports, less = more

However, the generated code for image layers is still very complex. Instead of just exporting an <image> tag, it instead creates a pattern definition which has xlink:href property as an <image> tag which is defined elsewhere, then this pattern definition is used a fill of a rectangle shape. This seems a very convoluted way of doing this.

  1. Add as much context as possible (screenshots, Figma files, mockups, etc.)
    For an example, say this simple design with an image inside a frame

The SVG code that gets generated for this is

<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="100" height="100" fill="white"/>
<rect x="25" y="25" width="50" height="50" fill="url(#pattern0)"/>
<defs>
<pattern id="pattern0" patternContentUnits="objectBoundingBox" width="1" height="1">
<use xlink:href="#image0" transform="scale(0.02)"/>
</pattern>
<image id="image0" width="50" height="50" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAQAUlEQVRoQ+2a2Ytl13XGf3uf8U413Bq71dUtdcuyuiVbciIiW1KCPJHgWM5gbLCxICQYAoaAIQSSl4SQp7zmJe8mEPIoyENkSESMFIzjCVseJJdUPXd1V9WtO55xnx3WOlUt5w8wCNP1cqd9917rW99a61v7lgE8vwZ/5oEj77MoPojI+ywgPIjIg4j8ihAwv/H0Ez60AVFosQZ845VvSRiQVzWRNfSSiMhCYgzDKNDnsmazG7PciWgaT+U8o0VFXjU02pka0iCkcg338opRWTOpaxrvqZpGvx9bSyc0ONdQNp6idjjvaYDKOZzYYjwWQ1k7Pcda2FkdKBy5rHcNYWAxn/id3/LWWiJrMcbQNLLNe3/WGiIbsJpELIUBm52IlcSwksb0QsuwG+OahjgKKWrD7v4EC2pEFIihAa6BedPw7iRnf1GyqEvwntB4luOQ3DmyusZgcAiQ8lmA8w2TvORonhMHhqUkpKhqlropzqPOzcuKOAgwn/vUx7yxoX4gKA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1DbSloDgWtFHVStbwR5/7XWbzMa9+842WbqrnWgNPRaXeN+sNuteElmRvBWk7Hug6+Uzek4lQqHfiRCuRLGZ5pXVEkRBR18qmk/InG3ut8eLQKdJayUQBB/J+20/EAb2DlUhFkRYOocrX/vxPeOfqLq+++jqhrP/lvSVRFfU2MqfAtV2+lTynzrQRbKVSe9nfrjlF1wyWOnobf7pAZbpT39TTVpqcGvDeYWK8rJNEbCMikWm5rHs1Ii5rvvpnX+Ht3V1ee+1/2mFMHZayLr3DqViUSiZaQyJxaljrRBuZFuCWHfI9fW3lexKXll6m109UNIoRwlMxSFAWaunPDVGk7yu1VLm3tDnlsDgiX9AbSblcFimvezuqSn6/aH/XEBGq9AvaMnzfYVHNShe5eqpP6NcWGTG2rnSOuC9KTxlwP3on1DdpJ2odMba9TDgdgGjH2dMfbWRNm6wtelL35bnSS5O3HT1bbrbqVRCTNfr7SdyOwVp7tMf+Ulqf5J98p03SNu9OgVGWqMJu80OAks//v70P/vPhhM7vk4cHP0+/TwJx34wHEXkQkV8RAr821Po/AEZDA1JWsG8AAAAASUVORK5CYII="/>
</defs>
</svg>

Instead of this complex code, it could easily have been a single <image> tag without the need of any <rect>, <defs>, <use> and <pattern> tags

  1. Ask questions to bring the community into the conversation
    (e.g. Does anyone else experience this? Is anyone using a plugin or workaround to help solve this?, etc.
    Does Figma have any plan to simplify SVG for image layers?
    Or, is there some other external tool which can help me simplify SVG generated here. I have used SVGO but it doesn’t simplify it further.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.