Skip to main content
Participant
May 19, 2022
Question

Saving SVGs with clip paths adds extra groups

  • May 19, 2022
  • 1 reply
  • 3189 views

When an AI file containing a shape (test.ai) with an image fill is exported as SVG (test.svg), a SVG group is created containing the shape's path with clipped sub-groups, defined using <defs>, containing the image. All well and good, apart from the fact that the shape's path is duplicated -- once in a <defs> element for clipping, once as the actual <path> -- and I suspect there's scope for optimisation.

If the saved SVG (test.svg) is resaved (as test1.svg) the groups above are wrapped in extraneous <g> elements -- one before each nested <defs> element, resulting in three additional nested groups. If test1.svg is saved again (as test2.svg) another three group elements are added.

Ongoing saving and opening a SVG eventually results in AI warning "There are too many nested groups than allowed in Illustrator. The file may not open correctly." and the shape's image fill is lost.

1 reply

Anshul_Saini
Community Manager
Community Manager
May 23, 2022

Hi @David24526970hc9e,

 

We are sorry for the trouble. This was a known issue that came with Ai 26.2.1 while exporting SVG containing images. But I am glad to inform you that we have tried to address the issue in v26.3.1, released recently. Let us know if that works. 

 

Regards,

Anshul Saini

Participant
May 23, 2022
Hi Anshul,

Thanks for responding. Unfortunately the issue exists with AI 26.3.1,
this being the version I used in my testing. In fact I suspect the issue
predates AI 26.2.1 as we noticed image fills sometimes disappearing from
SVGs late last year -- this has now become more problematic for us,
hence my investigation as to why.


Best regards,
Dave
Participating Frequently
June 13, 2022

Thanks for clarifying, @defaulttz5ld9symjzi. I have all the required information and was able to replicate the issue with your SVG file. I saved it using "Save As," and the groups in the layer panel increased. I checked this issue is replicable in all the versions of Illustrator CC.

However, in Illustrator v20, released in 2016, SVG format was added in "export as," which addressed many issues that "Save As" had.

 

I know your workflow doesn't include "export as," but I would suggest you try that. I used "export as" on your "Test.SVG," and instead of adding extra groups, it deleted the 3 groups from it.

 

I couldn't test your original Test.Ai as "Allow Save to Creative Cloud" is disabled for this file.

I assume this file has only one group and if I save it using "export as," I will not get extra groups. But I understand "export as" might not be an option for you. So, I will be logging a bug with the Product team.

 

Thanks for your cooperation & time and for answering all my queries to understand the issue. I really appreciate it.

 

Regards,

Anshul Saini


Thank you Anshul for looking into this. Using "export as" is not an option for us, as my testing finds that amongst other things, "id" attributes are rewritten from those assigned in AI, and we use "id" for path annotatation. A quick search finds this issue, which indicates that this is a known issue.

Best regards,

Dave