Commit graph

198 commits

Author SHA1 Message Date
Eduard Braun
a7e7b4c21d Cleanup options.
Also omit short option strings of advanced options for now (if we offer them again in future, they should be chosen very carefully as should the options for which we offer them)
2017-02-23 23:39:27 +01:00
pborunda
7cb0d36d72 Improve precision options for smaller output size (#131)
Add a separate precision option for curve control points (--set-c-precision)
This can considerably reduce file size with marginal effect on visual appearance.
2017-02-23 22:00:32 +01:00
Eduard Braun
01cb120d71 Reduce precision of lengths in viewBox
This fixes #127.
Also simplify splitting of viewBox lengths and avoiding a "FutureWarning: split() requires a non-empty pattern match" at the same time
2017-02-19 16:10:01 +01:00
Eduard Braun
f5a61eeeb3 Even better fix for 8f87118725
(previous solution still did not work for numbers like 123.4 with precision < 3)
2017-02-19 00:57:00 +01:00
Eduard Braun
8f87118725 Only use number representation with reduced precision if it is shorter than the initial representation.
Before it could happen that "123" was replaced with "1e3" if precision was set to 1 which is obviously not desirable.
2017-02-18 19:01:26 +01:00
Eduard Braun
b00b374e64 Fix generation of non-scientific number representation.
Before numbers often were already in scientific notation due to the str() implementation of Decimal leading to strange optimization results.
2017-02-18 18:06:09 +01:00
Eduard Braun
25549b35d3 Some whitespace fixes to make newer versions of flake8 happy 2016-11-27 18:52:39 +01:00
Eduard Braun
6cf8c2b7d9 call sanitizeOptions() in start() to prevent a third-party breakage 2016-11-27 18:52:39 +01:00
Eduard Braun
d9b369864d Reimplement generateDefaultOptions() by simply calling sanitizeOptions() 2016-09-25 19:02:19 +02:00
Eduard Braun
49cb542689 Make sanitizeOptions() work with an empty parameter list 2016-09-25 18:49:05 +02:00
Eduard Braun
285d73e5a6 Fix statistics out put for "Number of comments removed" 2016-09-25 15:44:07 +02:00
Eduard Braun
2fe7152a1e Fix logic from 4a5b924d37 (which was still wrong after 4410f91dad) 2016-09-25 15:34:28 +02:00
Eduard Braun
8cc97601c4 scourXmlFile(): Set specified 'filename' as input filename so relative references will work 2016-09-23 22:32:32 +02:00
Eduard Braun
462460a512 Fix embedRasters() function.
It was not Python 3 compatible and usually would not have worked with local files.
2016-09-23 22:30:43 +02:00
Eduard Braun
24c8087bd4 minor whitespace fix 2016-09-18 17:12:33 +02:00
Eduard Braun
2487f4433b Fixes to globals used for tracking statistics (#118)
- Collect globals in `scourString()` and make sure they're all properly initialized to zero. Before statistics were wrong when scouring multiple files/strings because initialization was only done once when loading the module.
- harmonize names
- adjust according to PEP 8 while at it (including leading underscore to mark as non-public)
- include one missing variable in statistics output (number of comments removed)
2016-09-18 16:23:00 +02:00
Eduard Braun
4410f91dad Fix logic in previous commit 2016-09-18 03:25:19 +02:00
Eduard Braun
4a5b924d37 Do not attempt to close stdin/stdout file objects 2016-09-18 03:07:51 +02:00
Eduard Braun
d9198d7872 Order imports as suggested by PEP 8 2016-09-15 21:56:36 +02:00
Eduard Braun
99363c9089 Fix all issues detected by pyflakes 2016-09-15 21:31:34 +02:00
Eduard Braun
82df0d2327 More PEP 8 cleanup
(solves all issues reported by `pycodestyle`)
2016-09-15 21:02:15 +02:00
Eduard Braun
fc356815a2 Some reformatting and manually break all long lines at column 119 2016-09-15 01:54:19 +02:00
Eduard Braun
0f1974c1e2 Consistent whitespace across source files according to PEP 8
(mostly automated by using autopep8, fixes #69)
2016-09-15 00:35:13 +02:00
Eduard Braun
082b579410 We don't want spaces in the serialized value of style attributes.
Add a unittest that should catch this and other issues with parsing/serializing the `style` attribute
2016-09-11 14:01:04 +02:00
Eduard Braun
b065137187 Whitespace fix 2016-09-11 01:11:36 +02:00
Eduard Braun
0b5bb5184c Do not remove stroke:none; if a differing value would be inherited from a parent
(fixes rest of #22)
2016-09-11 00:16:04 +02:00
Eduard Braun
0b5eab7f2f Avoid removal of some additional styles if they might be inherited by a child 2016-09-10 22:13:02 +02:00
Eduard Braun
1cde426009 Do not remove stroke-related styles if they might be inherited by a child
(partially fixes #22)
2016-09-10 22:08:49 +02:00
Eduard Braun
1aa5722c6a Fix conversion of cubic Bézier "curveto" commands into "shorthand/smooth curveto" commands. (#110)
When the preceeding path segment is a Bézier curve, too, the first control point of the shorthand defaults to the mirrored version of the second control point of this preceeding path segment. Scour always assumed (0,0) as the control point in this case which could result in modified path data (e.g. #91).
2016-09-06 01:43:36 +02:00
Eduard Braun
ec855211de Fix replacement of duplicate gradients if "fill/stroke" contains fallbacks (#109)
(fixes #79)
2016-09-05 22:44:55 +02:00
Eduard Braun
25c05d99d8 Merge pull request #108 from Ede123/precision
Improve path scouring
2016-08-31 22:29:51 +02:00
Dirk Thomas
dc3f66ed0f Sort declarations in style attribute (#107) 2016-08-31 22:29:01 +02:00
Eduard Braun
0c63344ea4 Add a check to prevent we make path data longer by "optimization" 2016-08-31 07:06:42 +02:00
Eduard Braun
29e005bf7b Improve handling of scientific vs. non-scientific notation
* Negative exponents were not handled in a reasonable way (e.g. 0.000001 remained unchanged)
* Trailing zeroes were not always properly removed
2016-08-31 06:29:01 +02:00
Eduard Braun
9e4b9d6f5e Improve behaviour of numerial precision reduction
* Previously all calculations were immediately done with the precision specified by the user, resulting in accumulation of numerical errors and in some cases very discernible abberations from the initial image (e.g. #80)
* Now all calculations are done with default precision (the module "decimal" uses a whopping 28 signifigant digits initially!) and only at the very end coordinates are rounded to the desired precision.
2016-08-31 02:20:11 +02:00
Eduard Braun
3929426a5a Add some attributes that fit into the list of the previous commit, too 2016-08-30 22:32:57 +02:00
Dirk Thomas
e76da093ea Try to always order attributes intuitively based on a list of select attributes, order other attributes alphabetical (#105) 2016-08-30 22:30:29 +02:00
Eduard Braun
3b68fdacf8 Fix removal rules for the overflow attribute (#104)
(fixes #92)
2016-08-30 00:05:52 +02:00
Eitot
aa48c90d56 Add options to remove descriptive elements (#102)
* --remove-titles (removes <title>)
* --remove-descriptions (removes <desc>)
* --remove-descriptive-elements (removes <title>, <desc> and <metadata>)
2016-08-29 21:05:12 +02:00
Eduard Braun
842123a393 Fix improper comparison of numeric default attribute values with textvalues resulting in wrongly removed attributes (#101)
For example for `orient="auto"` SVGLength() returns (value=0, units=Unit.INVALID); since the default value for `orient` is zero it was removed as there was check for a valid unit.
2016-08-29 06:37:28 +02:00
Eitot
3511c05298 Remove obsolete Psyco dependency (#100) 2016-08-29 04:32:54 +02:00
Eduard Braun
0314070363 Fix/update list of SVG presentation attributes (#99)
(fixes #94)
2016-08-29 03:30:33 +02:00
Eduard Braun
5844076258 Only attempt to group elements that the content model allows to be children of a <g> when --create-groups is specified. (#98)
(before it could happen that e.g. `tspan` elements were grouped, which is invalid; fixes issues #96 and #97)
2016-08-29 02:33:13 +02:00
Eduard Braun
7c86de83d1 Rename default_attributes -> default_properties (that's what they are called and it makes the distinction to the other default attributes clearer)
Add some documentation / links to spec as sources
2016-08-27 16:15:47 +02:00
Eduard Braun
488c756989 removeDefaultAttributeValues(): Add a lot of new default attribute values 2016-08-27 03:40:38 +02:00
Eduard Braun
002c54b5cc removeDefaultAttributeValues(): Refactor to improve code clarity and extensibility 2016-08-26 23:45:44 +02:00
Eduard Braun
beb9823a91 Fix some erroneous removal of default attributes (fxes #66) 2016-08-26 23:45:44 +02:00
Eduard Braun
90910eaa6f Fix counting issue in statistics due to collidng variable names 2016-08-26 23:44:14 +02:00
Eduard Braun
386d5d8656 Allow elements to be found via Document.getElementById() in the minidom document returned by scourXmlFile() (#68) 2016-08-25 21:13:09 +02:00
Eduard Braun
8d6301950b Redirect informational output to stderr when SVG is output to stdout (#67)
fixes #47
2016-08-23 22:31:55 +02:00