Giter Site home page Giter Site logo

olegrjumin / svg-to-png Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vincerubinetti/svg-to-png

0.0 0.0 0.0 1.12 MB

Convert SVG to PNG right in your browser, reliably and correctly

Home Page: https://vincerubinetti.github.io/svg-to-png/

License: MIT License

TypeScript 81.12% CSS 15.61% HTML 3.27%

svg-to-png's Introduction

SVG to PNG

Convert SVG to PNG right in your browser, reliably and correctly

⭐⭐ OPEN THE TOOL ⭐⭐

Motivation

There are many tools to convert SVGs to raster formats: Inkscape, ImageMagick, ezgif.com, convertio.co, online-convert.com, cloudconvert.com, and more. But in my experience, these tools have a lot of problems correctly converting anything but the most basic of SVGs.

If you work with SVGs a lot, you've probably run into this at some point too. You draw an SVG in one program, and then open it in another to discover that all of your text is rotated, or a shape is misaligned, or whole elements of your image are just gone.

Or, if you're an SVG wizard who codes them by hand, you might use the <use> feature, or some elaborate CSS <styles>'s, or some <filter>'s – only to find out that some GUI editor doesn't support those features, and the image is incomprehensible.

Why does this happen?

Probably because the specification for the SVG format is enormous, and it's incredibly difficult to support all of the features it lays out. Even for popular programs like Inkscape and ImageMagick that have large teams of developers, it's a monumental task to get everything right.

What's the solution?

Use a web browser to do the conversion. SVG is first and foremost a web standard. It was designed for the web, and web browsers were the first to implement it. It is meant to work well and be mixed in with other web technologies like HTML and CSS. As such, in my experience, modern web browsers such as Chrome and Firefox are always the most accurate tools at displaying/rendering SVGs, especially for uncommon, new, or otherwise "advanced" features.

How does this tool work?

This little web tool simply leverages your browser's built-in capability to accurately display/render SVGs. Your browser "renders" the vector graphic to raster pixels so it can display it on the screen, and the tool essentially takes whatever pixels are on the screen and saves it as an image.

Why not just open the SVG in a browser and take a screenshot?

This works fine for many cases. But it becomes a pain if you need a very high resolution image, where you would have to take multiple screenshots and stitch them together. Taking a screenshot also doesn't allow transparent backgrounds. This tool alleviates both of these problems with the use of HTML5 <canvas>.

Note about fonts

If your SVG has text in it, the fonts it uses may need to be installed on your system for the text to display properly, depending on how the SVG was exported or constructed.

Related tools

svg-to-png's People

Contributors

vincerubinetti avatar

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.