svg/svgo

Remove default values like stroke-dasharray="none" stroke-opacity="1"

atom3001 opened this issue · 6 comments

Hi, I'm using SVGOMG, which is great, but can't remove wadding like default path values. Eg
stroke-dasharray="none" stroke-opacity="1"

Tip: SVGOMG hasn't been updated for a while, and won't be updated until #1943 is merged. https://omfg.svg.beauty/ is slightly more up to date, but it's best to directly use the library/CLI if you can.

Commentary on the issue: This is already done to some degree, but I wouldn't be surprised if it doesn't work in all cases. Want to share an example SVG where it should remove it but doesn't?

Thanks for the quick response @KTibow. Am running omfg via CLI now. Which does remove raster images properly, which is nice. I suppose I need to develop a plugin to add this feature but am pretty green so will be a struggle. Will paste an image with stuff I'd like to clean out. EG Defaults like:
stroke-dasharray="none" stroke-opacity="1"

Styles to attributes gets rid of the above defaults on the last path but misses the initial two. Any help greatly appreciated

RR_v1_trim_1
RR_v1_trim_1_svgofm_1

It seems the optimization is disabled when the path is linked in a use. I haven't found where this optimization is applied yet so I don't have much to add.

Yes, if I drop the use elements the path styles get cleaned properly. good spot, thanks. So I could cleanup before cloning. Shame to have a fragmented workflow. But writing plug-ins to do a second cleaning pass is beyond me for now. Thanks again for looking

I checked and the relevant plugin is removeUnknownsAndDefaults, which actually doesn't clean defaults on attributes with an id

Interesting, thanks for digging deeper @KTibow. Still leaves me in the same boat. Perhaps it would be possible to disable that id limitation?