GithubHelp home page GithubHelp logo

Comments (6)

liZe avatar liZe commented on May 18, 2024

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.

liZe avatar liZe commented on May 18, 2024

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.

makmanalp avatar makmanalp commented on May 18, 2024

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.

makmanalp avatar makmanalp commented on May 18, 2024

Just tested it out locally - drastic improvement! Loads instantly and files are much smaller like you said.

from cairosvg.

liZe avatar liZe commented on May 18, 2024

1.0.8 released!

from cairosvg.

makmanalp avatar makmanalp commented on May 18, 2024

👍

from cairosvg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.