svg

Get the contour (outline) from a png image with the correct edges

Get the contour (outline) from a png image with the correct edges Question: I have multiple png files and I’m trying to get the polygon contour coordinates. That is the simplified coordinates, only each outer corner (not a convex hull polygon). The program that will do this at the moment is python and opencv. But …

Total answers: 1

Stacking a lot of SVG images as layers issue

Stacking a lot of SVG images as layers issue Question: So I would like to stack a lot of svg images on top of each other in Python. I am using this to do so: import svgutils.transform as st template = st.fromfile(‘firstLayer.svg’) second_svg = st.fromfile(‘secondLayer.svg’) template.append(second_svg) template.save(‘merged.svg’) It technically works. Only problem is that for …

Total answers: 2

How do I get a coordinates list from an svgpathtools bezier curve?

How do I get a coordinates list from an svgpathtools bezier curve? Question: I have python code to create a bezier curve, from which I create a bezier path. Here are my imports: import from svgpathtools import Path, Line, CubicBezier Here is my code: bezier_curve = CubicBezier(start_coordinate, control_point_1, control_point_2, end_coordinate) bezier_path = Path(bezier_curve) I would …

Total answers: 4

Importing an svg file into a matplotlib figure

Importing an svg file into a matplotlib figure Question: I like to produce high quality plots and therefore avoid rasterized graphics as much as possible. I am trying to import an svg file on to a matplotlib figure: import matplotlib.pyplot as plt earth = plt.imread(‘./gfx/earth.svg’) fig, ax = plt.subplots() im = ax.imshow(earth) plt.show() This works …

Total answers: 4

Display SVG in IPython notebook from a function

Display SVG in IPython notebook from a function Question: In IPython notebook, the following code displays the SVG below the cell: from IPython.display import SVG SVG(url=’http://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg’) The following displays nothing: from IPython.display import SVG def show_svg(): SVG(url=’http://upload.wikimedia.org/wikipedia/en/a/a4/Flag_of_the_United_States.svg’) Is there a way to display an SVG from within a function (or a class)? Asked By: prooffreader …

Total answers: 2

Flask and .svg picture not show

Flask and .svg picture not show Question: I started to work with python – Flask and I found some problems which i didn’t solve. When I want show picture in .svg format so it doesn’t show in flask but when i open html file (index.html) in for example Firefox it showed! Code in Flask template: …

Total answers: 2

Arc, pie cut, in svgwrite

Arc, pie cut, in svgwrite Question: Does any body have a working example of an arc slice (cheese slice or pac-man) done in svgwrite (python), I have tried this in an attempt to get a NorthWest quadrant strarting at (100,100) , but get a weird shape: w = dwg.path(d=”M 100,50 A 50,50 0 0 1 …

Total answers: 3

How can I get the output of a matplotlib plot as an SVG?

How can I get the output of a matplotlib plot as an SVG? Question: I need to take the output of a matplotlib plot and turn it into an SVG path that I can use on a laser cutter. import matplotlib.pyplot as plt import numpy as np x = np.arange(0,100,0.00001) y = x*np.sin(2*pi*x) plt.plot(y) plt.show() …

Total answers: 2

Python SVG parser

Python SVG parser Question: I want to parse an SVG file using python to extract coordinates/paths (I believe this is listed under the “path” ID, specifically the d=”…”/>). This data will eventually be used to drive a 2 axis CNC. I’ve searched on SO and Google for libraries that can return the string of such …

Total answers: 3

converting a latex code to mathml or svg code in python

converting a latex code to mathml or svg code in python Question: Is there any python code that allow take a latex code (for equations) and parse it to mathml or svg code ? A simple function that take as argument a string (the latex code) and output a string (the svg or mathml code) …

Total answers: 5