Here is the situation. I use the Inkscape command to transform png file to svg file.
Like this in cmd:
inkscape image.png --export-plain-svg=image.svg
However, I need to remove the background of the svg file.
The GUI process is (1) open up the file, (2) select all(Alt + A) and (3) selecet "Path" -> Trace BitMap -> click the Remove Background. Finally, save it.
Is there any command which can insert in the terminal or cmd even in python to do this process???
i might have thousands of svg files...
What you're doing with your command is embedding a png image into an SVG image.
What you want to do is to trace a png image to turn it into vector data. I don't think tracing works without GUI currently. What you want is not possible with Inkscape 0.92.4.
You need to either:
use a different software or
write an extension that can run potrace without parameters, or with default parameters or
run potrace directly
do this manually
Related
Hope you are all doing well.
I am trying to draw a 3D-text which I want to embed into an HTML document.
So for this I found vpython which can draw 3D text and render result in browser window using CANVAS.
Is there any easy way to get that rendered canvas or raster image (jpeg/png) exported right from the the vpython script?.
[Here is jupyter notebook result]
[1]: https://i.stack.imgur.com/Z2YUH.png
Same code executed from python file launches the browser having rendered HTML page.
Once I get rendered canvas or even raster image I will be able to use it.
If I understand correctly, the following approach should work: Go to webvpython.org and log in with a Google account. Create a new file, which will have a header "GlowScript 3.2 VPython". Add your 3D text statement such as text(text='Hello'). Click "Run this program" to check that it looks the way you want, then click "Edit this program" followed by clicking "Share or export this program". Copy the JavaScript code that has been transpiled from your (very short) VPython program and store it in an .html file. Double-click that .html file, which will invoke a browser and display the 3D text. You can install the JavaScript code in your own html and/or use iframe to embed it. Alternatively, if you simply want to create an image, use scene.capture(some file name) to store a .png file into your Download folder.
I'm looking for a way to convert the text in a specific font face (.ttf or .otf) into an SVG path. So that I can continue working with the path in vector graphics as drawSvg (or a similar Library)
I don't know if you want it inside a python script only, but an alternative would be use cnc-text-tool or even text tool of Inkscape and then save it as plain SVG.
I am using the Python Interactive tab (similar to Jupyter notebooks) in Microsoft Visual Studio Code.
When I plot an image, I am unable to save it directly from the editor. There's no option to save it directly with the mouse, or to save it directly from the interface.
Is there a way to save it from the interface or should I only use matplotlib's savefig method?
In my version (1.47.3) I can double click the image, which opens it in a separate tab for inspection.
One of the buttons in this tab is a save icon, which allows you to save the image in a format that depends on the file ending you choose. I've tried .png, but couldn't find an option to change resolution. .pdf or .svg saves it losslessly as vector graphic.
In the image below you can see what it looks like for me. (on Ubuntu)
Not fully sure if this counts as a full answer here on Stack Overflow. But the answer here is that we don't have a way to do this currently. You can highlight it in the interactive window and Ctrl-C to copy it out, but even that support is rather flakey at this point. If you would like to log this issue this would be the best spot to get it on our radar:
https://github.com/Microsoft/vscode-python/issues
We keep our issues open to the public so you can track when we work on it after it's filed there.
Through a python program, i am generating some SVG images. Each of this SVG Image has an external PNG Image attached to it.
Individually all these SVG images are good and look perfect.
But then i am creating a master SVG, which contains all these previously created SVG images (linked via image tag). When i view the master SVG in inkscape (on ubuntu), the PNG images are not displaying.
Can anyone suggest what is the problem?
NOTE: All Images (SVG and PNG) are linked by absolute paths on the system.
If you're using an SVG image via the <image> tag then it must be complete in a single file i.e. it can't link to an external png file.
You could convert the png file to a data URL and embed it in the SVG image file.
Im using python turtle (Tkinter) to draw some lines which I need to export to a .jpg or .png file. To do so, I'm using python's turtle method to export my canvas to a postscript file:
pen.getcanvas().postscript(file="grafica.ps")
Where pen is just a fancy name for my turtle.
I get my .ps file, I convert it and... surprize! The image gets cut.
I tried some modifications like:
pen.getcanvas().postscript(file="grafica.ps", colormode='color', pagewidth=1600, pageheight=1200, width=1600, height=1200)
Since my turtle's window is 800x600 I thought that maybe twice as much space would be enough space to fit all the image but it still gets cut down...
I'm posting some output examples after the convertion, how my turtle's screen looks like when saving it, and how it should look exported.
Window while saving the image:
(Yes, there are sliders for the canvas)
How should it look:
And this is what I get:
I'm wondering how should I call postscript(), any idea?
I don't want to code this again on WxPython or other library :(
thanks!
This is probably a problem with ImageMagick interacting with the bounding box of the EPS file. My typical workflow for .eps files on Windows may be slightly convoluted, but it works. Similar thing should work for Linux. Install GhostScript (you'll have to make sure the GhostScript executables are on your path), then use the ps2pdf utility from the command line with the -dEPSCrop option:
ps2pdf -dEPSCrop input.eps output.pdf.
Then, use ImageMagick to convert the PDF to anything else, e.g. PNG
convert output.pdf output.png
You can control the PNG resolution etc. through ImageMagick. Like I said, convoluted, but it works.