GithubHelp home page GithubHelp logo

alexandre-pod / svgconverter Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 233 KB

A library and executable to convert SVG to PNG image using webkit.

Home Page: https://alexandre-pod.github.io/SVGConverter/documentation/svgconvertercore/

License: MIT License

Swift 89.21% Shell 10.79%

svgconverter's Introduction

SVGConverter

A library and executable to convert SVG to PNG image using webkit.

CLI Installation

swift build -c release
sudo cp -f .build/release/SVGConverter /usr/local/bin/svgConverter
Uninstallation
sudo rm /usr/local/bin/svgConverter

Usage

From CLI:

svgConverter file.svg output.png 1920 1080
# Or if you have not installed the executable:
# swift swift run SVGConverter file.svg output.png 1920 1080
svgConverter help
USAGE: svg-converter <input-path> <output-path> <width> <height> [--no-svg-fix] [--quiet]

ARGUMENTS:
  <input-path>            Path to the svg file you want to convert
  <output-path>           Destination path for the created png
  <width>                 Width of the output image
  <height>                Height of the output image

OPTIONS:
  --no-svg-fix            Set this to true if you do not want this tool to automatically add a viewBox attribute if it is possible. Without viewBox the svg cannot be resized, but it can still be converted at its natural size
  --quiet                 Setting this to true prevent any output in standard error output
  -h, --help              Show help information.

From code:

import SVGConverterCore

func run() async throws {
    let svgData = try Data(contentsOf: "file.svg")
    let renderer = await SVGRenderer()
    let pngData = try await renderer.render(svgData: svgData, size: CGSize(width: 1920, height: 1080))
    try pngData.write(to: URL(fileURLWithPath: "output.png"))
}

svgconverter's People

Contributors

alexandre-pod avatar

Stargazers

Bing ZHEUNG avatar

Watchers

James Cloos avatar  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.