Conversation
lib/image_optim/worker/svgo.rb
Outdated
| '`0`..`10`, ignored in default/lossless mode') \ | ||
| do |v, opt_def| | ||
| if allow_lossy | ||
| OptionHelpers.limit_with_range(v.to_i, 0..10) |
There was a problem hiding this comment.
svgo allows precision to be from 0 to 20. I'm wondering why are negative numbers forbidden (to round integer part), but that is a question to svgo.
toy
left a comment
There was a problem hiding this comment.
Thank you! Just notes about range of values and the changelog entry
CHANGELOG.markdown
Outdated
|
|
||
| ## unreleased | ||
|
|
||
| * Added `svgo-allow-lossy` and `svgo-precision` options to use svgo in lossy mode. This sets svgo `precision`, which can result in substantially smaller svgs. Lower values are more lossy. 3 is the default, but many SVGs will work well even with 0 or 1. [#210] [@gurgeous](https://github.com/gurgeous) |
There was a problem hiding this comment.
I think it is better to use complete option names --svgo-precision, also I assume default is to use global --allow-lossy instead of per worker --xxx-allow-lossy.
And please create complete link to #210, so it works even outside of github and please add a link to this PR too.
|
Oh, that's neat. Appreciate the stats. Typically when I export an SVG from figma or whatever there are many extra digits. It's just the nature of the beast. Here is an actual export from one of my projects (below). I'll update the PR too :) Original (3.4k): After svgo -p1 (1.4k): Or even svgo -p0 (0.9k): |
|
I forgot also to ask to run |
|
Ah, ok. Ran it! |
|
Lower case |
|
Excellent, thanks! Really appreciate all your hard work on the gem. |
|
Just released v0.31.4 |
How about this? Personally I'd suggest --precision=1 as the default since this is what I've always used. Sometimes even zero! I don't have a strong preference, though, since picky users like me can easily override :)
I added a simple test too. There is a failing spec but I don't think it's related. Feedback welcome