file that opens in 3 seconds in Google Chrome takes 10 minutes in inkscape
Hi all,
I wonder whether the file is formed in such a way that inkscape has a hard time with it?
Google Chrome's file dialog can preview the file instantly and then renders it within 3 seconds, wheres Inkscape hangs for minutes when trying to preview it or to open it.
What inkscape does successfully is, in a few minutes, to save it as PDF from the command line using the -A switch. Saving to PDF shrinks the file from the original 8 MB down to ~800 KB.
As a PDF Inkscape has no problem previewing it instantly, and opening it within 20 seconds or so. It's the only way I managed to open the file with inkscape.
Given that we generate this file ourselves from our own software ( github.com/acardona/CATMAID/), I would appreciate if someone could look at the SVG example file and let us know what would be best for Inkscape regarding formatting, choice of svg vs g elements, and styling.
Example files (original SVG and also the PDF as saved with inkscape -A):
https://www.dropbox.com/sh/d10pxph6b1kd77c/AABXs0TJhxDtlBPr6GZ_3bSQa?dl=0
Thank you.
Albert
On Sun, 2014-11-30 at 12:40 -0500, Albert Cardona wrote:
Hi all,
I wonder whether the file is formed in such a way that inkscape has a hard time with it?
Google Chrome's file dialog can preview the file instantly and then renders it within 3 seconds, wheres Inkscape hangs for minutes when trying to preview it or to open it.
After download perhaps... it took a couple of minutes for me to download the file.
What inkscape does successfully is, in a few minutes, to save it as PDF from the command line using the -A switch. Saving to PDF shrinks the file from the original 8 MB down to ~800 KB.
As a PDF Inkscape has no problem previewing it instantly, and opening it within 20 seconds or so. It's the only way I managed to open the file with inkscape.
Given that we generate this file ourselves from our own software (github.com/acardona/CATMAID/), I would appreciate if someone could look at the SVG example file and let us know what would be best for Inkscape regarding formatting, choice of svg vs g elements, and styling.
Example files (original SVG and also the PDF as saved with inkscape -A):
https://www.dropbox.com/sh/d10pxph6b1kd77c/AABXs0TJhxDtlBPr6GZ_3bSQa?dl=0
I don't know why Inkscape takes so long to open the file but here are some quick observations:
1. The file begins with 13000 style declarations. This might in itself choke Inkscape (I am not sure).
2. Why is the style data being saved as CDATA? I don't see anything that requires this (but I didn't examine all 13000 lines).
3. Most of the styling classes are redundant. The only things that are changing on the lines is the color and the stroke-width. The other properties can be pulled out. And even then, you might group the objects with the same color and similar stroke width together. All the black lines seem to the same width and all the blue and red lines seem to have the same width. style97 (text) is the only really different style. All the black lines
3. Some of the properties are useless:
fill:none: Fill won't show on a straight line. stroke-opacity: 1; This is the default value. stroke-linejoin: round: There is no line join on a straight line.
4. The SVG standard requires rendering to an accuracy of 1px and it specifies that lengths are stored as floats, yet there is 17 digits for stroke-width. Ditto for line element values. Reducing this to something reasonable would reduce file size by at least 75%.
5. You have nested SVGs. Don't know if this is contributing or not.
Passing the file through PDF and back is probably getting rid of most of these things.
Tav
Thanks Tav, that was very helpful. The most impactful change was to reduce floating point precision which reduced the +13,000 different styles to about 100. Now Inkscape can open the file within a few seconds.
Best,
Albert
2014-11-30 13:28 GMT-05:00 Tavmjong Bah <tavmjong@...206...>:
On Sun, 2014-11-30 at 12:40 -0500, Albert Cardona wrote:
Hi all,
I wonder whether the file is formed in such a way that inkscape has a hard time with it?
Google Chrome's file dialog can preview the file instantly and then renders it within 3 seconds, wheres Inkscape hangs for minutes when trying to preview it or to open it.
After download perhaps... it took a couple of minutes for me to download the file.
What inkscape does successfully is, in a few minutes, to save it as PDF from the command line using the -A switch. Saving to PDF shrinks the file from the original 8 MB down to ~800 KB.
As a PDF Inkscape has no problem previewing it instantly, and opening it within 20 seconds or so. It's the only way I managed to open the file with inkscape.
Given that we generate this file ourselves from our own software (github.com/acardona/CATMAID/), I would appreciate if someone could look at the SVG example file and let us know what would be best for Inkscape regarding formatting, choice of svg vs g elements, and styling.
Example files (original SVG and also the PDF as saved with inkscape -A):
https://www.dropbox.com/sh/d10pxph6b1kd77c/AABXs0TJhxDtlBPr6GZ_3bSQa?dl=0
I don't know why Inkscape takes so long to open the file but here are some quick observations:
- The file begins with 13000 style declarations. This might in itself
choke Inkscape (I am not sure).
- Why is the style data being saved as CDATA? I don't see anything that
requires this (but I didn't examine all 13000 lines).
- Most of the styling classes are redundant. The only things that are
changing on the lines is the color and the stroke-width. The other properties can be pulled out. And even then, you might group the objects with the same color and similar stroke width together. All the black lines seem to the same width and all the blue and red lines seem to have the same width. style97 (text) is the only really different style. All the black lines
- Some of the properties are useless:
fill:none: Fill won't show on a straight line. stroke-opacity: 1; This is the default value. stroke-linejoin: round: There is no line join on a straight line.
- The SVG standard requires rendering to an accuracy of 1px and it
specifies that lengths are stored as floats, yet there is 17 digits for stroke-width. Ditto for line element values. Reducing this to something reasonable would reduce file size by at least 75%.
- You have nested SVGs. Don't know if this is contributing or not.
Passing the file through PDF and back is probably getting rid of most of these things.
Tav
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.cl... _______________________________________________ Inkscape-user mailing list Inkscape-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-user
participants (2)
-
Albert Cardona
-
Tavmjong Bah