Comments (6)
You're right, the output file is really heavy and loads slowly in some clients. It seems to be caused by the opacity of the rectangles: without these opacities, the file size goes from 2 MB to 230 kB. I'm trying to find an optimization to fix this problem, I hope that the problem is in CairoSVG and not in Cairo!
from cairosvg.
I finally have a 238 kB file with this fix, that's ~12% of the original file size, and that's better in my clients.
For the record and the curious people: when a tag has an "opacity" attribute, there's no need to create an atomic layer for the compositing if there's only one element to draw. This pre-compositing optimization is really useful when there are lots of semi-transparent elements, this gist is a really good example.
from cairosvg.
Wow, I had honestly given up hope on this one, thank you so much!
I'll test it out on the site to see the improvement and let you know how it goes. Would you be opposed to doing a new release for CairoSVG on pypi after that?
from cairosvg.
Just tested it out locally - drastic improvement! Loads instantly and files are much smaller like you said.
from cairosvg.
1.0.8 released!
from cairosvg.
👍
from cairosvg.
Related Issues (20)
- Failed to load CairoSVG in serverless program HOT 8
- closing the path for ellipse (and circle)? HOT 2
- `text` property `shape-inside` not respected HOT 1
- Convert to WebP HOT 1
- Add rlPyCairo to requirements.txt HOT 1
- Stroke Width is not taken into account for final height / width HOT 3
- OSE Error cairo-2 not found HOT 6
- Conversion of multiple files halted with error HOT 2
- SVG to PDF render improper PNG position HOT 1
- OSError: no library called "cairo-2" was found HOT 1
- RecursionError: maximum recursion depth exceeded in comparison HOT 1
- Truncating fractional height in pixels HOT 4
- svg2pdf incorrect width and height output - HOT 1
- Feature request: support style='background_color:xxxx' in the <svg> object
- Add support for blend modes
- Missing linked images and text HOT 6
- svg2png the stroke attribute causes display anomalies. HOT 1
- Fail of image path resolution in a defs/use context HOT 1
- SVG path parse error
- ValueError: could not convert string to float: 'null' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cairosvg.