SVG Images not linked properly inside Master SVG - python

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.

Related

Command-line rendering batch of PNG images from obj+mtl file

I am trying to command-line rendering an PNG file from obj+mtl file instead of using blender.
Currently, I'm using blender to load the obj+mtl file, and then use the render feature of Blender. But, that requires GUI to do so.
I need to render a batch of PNG files with different textures on the same obj on a server.
How should I do that?
Thank you very much!

How to remove SVG background in the Inkscape by command?

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

Can't save Matplotlib images to a readable .tif format

I'm having trouble saving my Matplotlib plots to a readable .tiff format. The file itself does save, but when I double-click on it on the folder, I get the following error in Windows Photo Viewer:
"Windows Photo Viewer can't open this picture because either Photo Viewer doesn't support this file format, or you don't have the latest updates to Photo Viewer."
But attempted workarounds such as trying to load the file with Paint or Photo do not work. I get the feeling that the file is not saving correctly. (The image displays just fine and can be saved as a .gif just fine.) How do I resolve this?

Downloading a section of an Image from a website in python?

I am currently able to download an entire image from a URL using
from PIL import Image, ImageTk
import cStringIO
import urllib
url = http://prestigemgmt.us/wp-content/uploads/2013/03/dog.jpg
self.image = Image.open(cStringIO.StringIO(urllib.urlopen(url).read()))
It works fine and gets the whole image from the website. My question is there any way to get, lets say only the right half of the image.
I understand I could edit the image after it is downloaded, but speed is an important aspect, so ideally I would download only what I need.
It is not possible to do this.
The common image file formats like PNG and JPEG are encoded in a manner that you cannot download an arbitrary part of the picture without downloading the full picture.
You need to download the whole picture, decode it and edit it after the download.
For the advanced knowledge you can always study PNG and JPEG file formats.
If you are in the control of the server providing the images you can write a server-side script which edits the image on the server and then sends the edit over the wire.

Image preview with Reportlab?

I'm generating some pdf's with Reportlab and Django using a web interface. The pdf's are always going to be a single page. I'd like to generate a png or jpg image of the generated page and return that to the browser for the user to preview before saving the final pdf and delivering it to the end user. Is there anyway to do this?
This answer explains that you can use ghostscript to convert pdf to png. Depending of the requirements of your app (traffic, response time, nb of pdfs ...) it may or may not be a solution for you.
This is just an idea, but may be you can generate the preview image in parallel using PIL ImageDraw and get rid of the pdf-to-png conversion.
I hope it helps

Categories