Jump to content
You must now use your email address to sign in [click for more info] ×

SVG export can contain ‘superfluous’ transformed but empty groups


Recommended Posts

As discussed here: https://forum.affinity.serif.com/index.php?/topic/174593-designer-svg-export-empty-groups/

I’ve noticed that I sometimes find ‘superfluous’ groups with transform attributes in the exported SVGs.

For example, in Designer, I can create a new document, add some Artistic Text, move the text and then export the document to SVG.

When I do this I get the following SVG:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1920 1080" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
    <g transform="matrix(1,0,0,1,609.969,481.812)">
        <g transform="matrix(385.309,0,0,385.309,1175.72,428)">
        </g>
        <text x="191px" y="428px" style="font-family:'ArialMT', 'Arial', sans-serif;font-size:385.309px;">TEXT</text>
    </g>
</svg>

Note the group which contains a transform attribute but has no contents.

If I set “Flatten Transforms” ON in the export settings (Export Dialog) I get this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 1920 1080" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
    <g transform="matrix(385.309,0,0,385.309,1785.69,909.812)">
    </g>
    <text x="800.969px" y="909.812px" style="font-family:'ArialMT', 'Arial', sans-serif;font-size:385.309px;">TEXT</text>
</svg>

...which still has a strange ‘transformed but empty' group.

Unless someone can give a good explanation for why these groups are being created, I don’t think this should happen.

Link to comment
Share on other sites

Just to add the SVG still looks ok in the browser but the reason these empty groups are a problem is that SVG files should be as lean and neat as possible. The bigger your SVG file, the more empty groups you will have, so for example 20+ lines of empty groups makes the SVG file more difficult to read. Usually I will find and delete all the empty groups but then each time I edit the file, the empty groups are back and I need to do find and delete them all again.

Link to comment
Share on other sites

  • Staff

This is intentional with the SVG export - the problem is that whilst some people don't want superfluous groups, others do want them because certain pieces of software rely on the structure to be in place - therefore we keep them in, but the option to remove them using Flatten Transforms is there.

Link to comment
Share on other sites

15 hours ago, DWright said:

the problem is that whilst some people don't want superfluous groups, others do want them because certain pieces of software rely on the structure to be in place

I created this thread to bring up the fact that empty groups which contain transforms were being created whether Flatten Transforms was being used or not.

You seem to be suggesting that this is expected behaviour, and that some people find it useful.

If I’ve understood that correctly, can you explain how/why it’s useful to have these empty groups, even when Flatten Transforms is ON, please?

Or have I misunderstood what these ‘empty’ groups are?

Link to comment
Share on other sites

53 minutes ago, GarryP said:

If I’ve understood that correctly, can you explain how/why it’s useful to have these empty groups, even when Flatten Transforms is ON, please?

If I've understood correctly, they should be there when (and only when) Flatten Transforms is OFF.

16 hours ago, DWright said:

certain pieces of software rely on the structure to be in place - therefore we keep them in, but the option to remove them using Flatten Transforms is there

It's clear from the discussion in the linked thread that Flatten Transforms isn't functioning as expected.

Alfred spacer.png
Affinity Designer/Photo/Publisher 2 for Windows • Windows 10 Home/Pro
Affinity Designer/Photo/Publisher 2 for iPad • iPadOS 17.4.1 (iPad 7th gen)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.