Last modified: 2014-10-27 15:55:19 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T74547, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 72547 - Minimize SVG output
Minimize SVG output
Status: NEW
Product: Mathoid
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Unprioritized normal
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-27 05:08 UTC by Gabriel Wicke
Modified: 2014-10-27 15:55 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Gabriel Wicke 2014-10-27 05:08:46 UTC
The SVG produced by MathJax is a bit verbose. It is possible to reduce the size using tools like scour (apt-get install python-scour):

scour --indent=none --shorten-ids -i /tmp/test.svg -o /tmp/test.scoured.svg

ls -lh /tmp/test*
-rw-r--r-- 1 gabriel gabriel  20K Oct 26 21:42 /tmp/test.svg
-rw-r--r-- 1 gabriel gabriel  15K Oct 26 22:05 /tmp/test.scoured.svg

After gzip -9 on each of the SVG files:
-rw-r--r-- 1 gabriel gabriel 7.3K Oct 26 21:57 /tmp/test.svg.gz
-rw-r--r-- 1 gabriel gabriel 5.5K Oct 26 22:05 /tmp/test.scoured.svg.gz

So about a 25% reduction of the compressed size, I believe without any quality loss.

There is a partial port of scour to JS (https://github.com/preciousforever/SVG-Cleaner), but it does miss the crucial path simplification pass from scour.
Comment 1 Gabriel Wicke 2014-10-27 05:29:01 UTC
I got even better results with https://github.com/svg/svgo, which is already a node module.

svgo --disable=removeUselessStrokeAndFill -i /tmp/test.svg -o /tmp/test.svgo.svg

-rw-r--r-- 1 gabriel gabriel  14K Oct 26 22:26 /tmp/test.svgo.svg
-rw-r--r-- 1 gabriel gabriel 5.3K Oct 26 22:27 /tmp/test.svgo.svg.gz

We can just drop this into mathoid as-is.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links