-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
svgo --precision #211
svgo --precision #211
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Just notes about range of values and the changelog entry
CHANGELOG.markdown
Outdated
@@ -2,6 +2,8 @@ | |||
|
|||
## 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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