Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

svgcleaner outputs style="" #246

Open
jhpratt opened this issue Aug 15, 2021 · 6 comments
Open

svgcleaner outputs style="" #246

jhpratt opened this issue Aug 15, 2021 · 6 comments

Comments

@jhpratt
Copy link

jhpratt commented Aug 15, 2021

After just switching to svgcleaner from svgo, I noticed that svgcleaner outputs style="", which I presume is not strictly required. Wouldn't it make sense to remove this?

@RazrFalcon
Copy link
Owner

It looks like a bug. Can you provide a test example?

@jhpratt
Copy link
Author

jhpratt commented Aug 15, 2021

I can try and find an example when I'm on my laptop, but it happened with a number of svgs when I ran it locally.

@RazrFalcon
Copy link
Owner

I cannot reproduce it.

@jhpratt
Copy link
Author

jhpratt commented Aug 15, 2021

svgcleaner --multipass --remove-gradient-attributes --join-style-attributes all --apply-transform-to-paths yes --join-arcto-flags yes --coordinates-precision 3 --properties-precision 3 --transforms-precision 3 --paths-coordinates-precision 3 Rust_torus.svg Rust_torus.svg

Rust torus after having been processed with the above command follows. Repeating the command yields the same output.

<svg height="144" style="" viewBox="19 19 106 106" width="144" xmlns="http://www.w3.org/2000/svg"><path d="m123.62 70.716-4.4-2.72c-.03-.428-.08-.855-.12-1.28l3.77-3.522c.39-.358.56-.888.46-1.401a1.535 1.535 0 00-.96-1.122l-4.82-1.805c-.13-.418-.25-.833-.38-1.246l3.01-4.182c.31-.425.37-.978.17-1.463a1.52 1.52 0 00-1.16-.914l-5.09-.828c-.19-.386-.4-.766-.61-1.143l2.14-4.695c.22-.478.18-1.034-.12-1.468a1.498 1.498 0 00-1.31-.671l-5.16.18a40.98 40.98 0 00-.82-.99l1.19-5.032a1.514 1.514 0 00-.4-1.417 1.52 1.52 0 00-1.42-.403l-5.03 1.186a79 79 0 00-.99-.816l.18-5.166a1.52 1.52 0 00-.67-1.31 1.516 1.516 0 00-1.47-.119l-4.694 2.14a54.472 54.472 0 00-1.143-.613l-.83-5.091a1.513 1.513 0 00-2.376-.984l-4.185 3.011a45.914 45.914 0 00-1.244-.377l-1.805-4.828a1.509 1.509 0 00-2.522-.503l-3.522 3.779c-.425-.047-.853-.09-1.28-.125l-2.72-4.395a1.512 1.512 0 00-2.571 0l-2.72 4.395c-.428.035-.856.078-1.281.125l-3.523-3.779a1.51 1.51 0 00-2.522.503l-1.805 4.828c-.418.12-.832.247-1.245.377l-4.184-3.011a1.515 1.515 0 00-2.377.984l-.83 5.091c-.384.199-.764.404-1.143.613l-4.694-2.14a1.507 1.507 0 00-1.467.119c-.436.29-.691.787-.671 1.31l.18 5.166c-.334.267-.665.54-.992.816l-5.031-1.186a1.517 1.517 0 00-1.417.403 1.51 1.51 0 00-.403 1.417l1.185 5.032a48.63 48.63 0 00-.814.99l-5.166-.18a1.511 1.511 0 00-1.429 2.139l2.14 4.695a46.02 46.02 0 00-.613 1.143l-5.09.828a1.513 1.513 0 00-.984 2.377l3.011 4.182c-.131.413-.258.828-.378 1.246l-4.828 1.805a1.51 1.51 0 00-.501 2.523l3.777 3.522c-.047.425-.089.853-.125 1.28l-4.394 2.72a1.51 1.51 0 000 2.571l4.394 2.72c.036.428.078.855.125 1.28l-3.777 3.523a1.512 1.512 0 00.501 2.522l4.828 1.805c.12.418.247.833.378 1.246l-3.011 4.183a1.511 1.511 0 00.985 2.376l5.089.828c.199.386.403.766.613 1.145l-2.14 4.693a1.519 1.519 0 00.119 1.472c.292.43.789.69 1.31.67l5.164-.18c.269.33.54.66.816.99l-1.185 5.03c-.12.51.031 1.04.403 1.41.369.38.906.53 1.417.41l5.031-1.19c.327.28.658.55.992.82l-.18 5.16c-.02.53.235 1.02.671 1.31.434.29.99.34 1.467.12l4.694-2.14c.378.21.758.42 1.143.61l.83 5.09c.084.52.43.96.914 1.16.483.2 1.038.13 1.463-.17l4.182-3.01c.413.13.828.25 1.246.37l1.805 4.83c.183.49.607.85 1.122.95.514.11 1.043-.06 1.4-.45l3.523-3.78c.425.05.853.09 1.281.13l2.72 4.4a1.518 1.518 0 002.571 0l2.72-4.4c.428-.04.855-.08 1.28-.13l3.522 3.78c.357.39.887.56 1.4.45.515-.1.939-.46 1.122-.95l1.805-4.83c.418-.12.833-.24 1.246-.37l4.183 3.01c.425.3.979.37 1.462.17.484-.2.83-.64.914-1.16l.83-5.09c.384-.19.764-.4 1.143-.61l4.694 2.14a1.515 1.515 0 002.141-1.43l-.18-5.16c.33-.27.66-.54.99-.82l5.03 1.19c.51.12 1.05-.03 1.41-.41.38-.37.53-.9.41-1.41l-1.19-5.03c.28-.33.55-.66.82-.99l5.16.18c.52.02 1.02-.24 1.31-.67.29-.44.34-1 .12-1.472l-2.14-4.693c.21-.379.42-.759.61-1.145l5.09-.828c.52-.083.96-.429 1.16-.914a1.53 1.53 0 00-.17-1.462l-3.01-4.183c.13-.413.25-.828.37-1.246l4.83-1.805c.49-.184.85-.607.95-1.122a1.474 1.474 0 00-.45-1.4l-3.77-3.523.12-1.28 4.4-2.72a1.518 1.518 0 000-2.571zm-29.412 36.454a3.116 3.116 0 01-2.385-3.7 3.107 3.107 0 013.689-2.39 3.117 3.117 0 012.387 3.7 3.11 3.11 0 01-3.691 2.39zm-29.305-73.115 4.786 5.021a2.83 2.83 0 004.006.092l5.355-5.122c11.221 2.089 20.721 9.074 26.2 18.657l-3.67 8.28a2.842 2.842 0 001.44 3.744l7.06 3.135c1.41 12.759-4.2 24.055-10.79 30.62l-6.575-1.413a2.833 2.833 0 00-3.365 2.18l-1.56 7.281a38.184 38.184 0 01-15.79 3.4 38.261 38.261 0 01-16.121-3.55l-1.559-7.284a2.832 2.832 0 00-3.364-2.179l-6.427 1.38c-6.766-7.116-11.776-17.277-10.575-30.744l6.695-2.975a2.838 2.838 0 001.441-3.744l-3.48-7.874a38.487 38.487 0 0126.293-18.905zm-15.44 72.955c-1.678.37-3.33-.7-3.691-2.38a3.112 3.112 0 012.386-3.7 3.11 3.11 0 011.305 6.08zm-11.863-48.1a3.114 3.114 0 01-1.581 4.107 3.106 3.106 0 01-4.101-1.584 3.114 3.114 0 011.581-4.107 3.106 3.106 0 014.101 1.584zm32.091-29.126a3.105 3.105 0 014.394.101 3.115 3.115 0 01-.103 4.401 3.103 3.103 0 01-4.394-.102 3.116 3.116 0 01.103-4.4zm36.379 29.277a3.106 3.106 0 014.1-1.583 3.11 3.11 0 011.58 4.107 3.102 3.102 0 01-4.1 1.584 3.118 3.118 0 01-1.58-4.108z" style=""/></svg>

@JoKalliauer
Copy link
Contributor

I cannot reproduce it.

@RazrFalcon You need --join-style-attributes all and an element that does not contain any style-attributes

@jhpratt Having a style=""-attribute in all elements could be an advantage for post-processing. Removing empty style-attribute is easy, adding it might be difficult (since there might already exist a non-empty one). If you want smaller files you should consider using --join-style-attributes no or --join-style-attributes some.

input (minimal example)

<?xml version="1.0" encoding="UTF-8"?>
<svg height="144" viewBox="19 19 106 106" width="144" xmlns="http://www.w3.org/2000/svg">
 <circle cx="50" cy="50" r="45"/>
</svg>

terminal

svgcleaner in.svg out.svg --allow-bigger-file --indent 1 --join-style-attributes all --remove-declarations no
Your image is -10.59% smaller now.

output (svg)

<?xml version="1.0" encoding="UTF-8"?>
<svg height="144" style="" viewBox="19 19 106 106" width="144" xmlns="http://www.w3.org/2000/svg">
 <circle cx="50" cy="50" r="45" style=""/>
</svg>

@jhpratt
Copy link
Author

jhpratt commented Aug 17, 2021

@JoKalliauer I'm not looking to add it to be clear — I'd like to see the superfluous attribute removed to decrease size.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants