I am working on a small image comparison script and I am using Cairosvg to transform my source data(svg) into png. However this gets rendered wierd, like spaces between objects get removed. Does anybody have an idea why?
original:
https://prnt.sc/70Gw5shayPtT
rendered
https://prnt.sc/Dqk_nIiCHplQ
Edit: it also moves Objects to different Locations inside the canvas
Related
I have a word document from a colleague who gave me a .docx Microsoft Word file with 90 images on it that need to be extracted so they can be turned into flashcards. I tried using the Python module "docx2txt" which worked ok, but only extracted 34 images. Upon further inspection, I found that it was because when my coworker made the original file, he took screenshots of PowerPoint slides that he had made with about 4-6 of the images on one slide. Then, he would put them in Word and use the built in Word trimming tool to copy the picture several times and trim down to each individual picture he needed in a particular line of the document. Docx2txt copied the pictures files to my designated directly perfectly, but did not keep the formatting. Any picture file he had inserted and "trimmed down" to size, was copied as the full image. Does anyone know of a way to keep the formatting so I don't have to go through and manually copy 90 pictures one by one? Perhaps converting to a .pdf file and using a pdf related module or something? Or might be there some way of using another Python library which will keep the picture formatting? Thanks for any help you can provide! I'm somewhat of a beginner with Python, but love it when I can get it to automate stuff... even if it ends up taking longer to figure out how to do it than just boring myself to death saving the photos manually, lol.
https://support.microsoft.com/en-us/topic/reduce-the-file-size-of-a-picture-in-microsoft-office-8db7211c-d958-457c-babd-194109eb9535
Important: Cropped parts of the picture are not removed from the file, and can potentially be seen by others; including search engines if the cropped image is posted online. Only the Office desktop apps have the ability to remove cropped areas from the underlying image file.
Follow the relevant section for Desktop Office (Windows or Mac) note from above it CANNOT work on Web 365.
go to "Other kinds of cropping"
Important: If you delete cropped areas and later change your mind, you can click the Undo Button Image button to restore them. Deletions can [ONLY] be undone until the file is saved.
So make a backup copy of the file
Select the picture or pictures (If you want all selected that should be easy with CTRL + A to highlight everything)
Then follow the instructions
Picture Tools > Format, and in the Adjust group, click Compress Pictures
Be sure that the Delete cropped areas of pictures check box is selected
DEselect the Apply only to this picture check box.
Double check a few manually to verify all is well then save a copy.
I am using Pygraphviz library with python 2.7. I'm generating 'svg' output images. What I like to do is to use an 'svg' image as the label of my graphs. To do that, I am using the html tag (http://www.graphviz.org/doc/info/shapes.html#html).
Here is the part of my code that is responsible to do that:
dot = Digraph(comment=zone)
dot.graph_attr['label'] = "\
<\
<TABLE>\
<TR>\
<TD><IMG SRC=\"/path/to/svg/image\"/></TD>
</TR>
</TABLE>
>"
The svg output image is created but my svg logo is not displayed; the table is empty)
Any ideas?
I know this is a very old question, but as this is the first result on google and I stumbled over this as well I thought I'd share:
You can open the *.svg with a text editor to check that the links are there and point to the correct location xlink:href="/path/to/svg/image" (which was the case for me)
Make sure to open it with an application that actually loads the images (e.g. firefox, chrome, inkscape). The default image viewer in gnome, GIMP, Krita, etc. open the image just fine, but don't load the images by default, resulting in an empty table/node.
I am using Ipython Notebook and I would like to save the notebook as pdf. When a notebook contains html figures in markdown mode I cannot export them
In example:
<img src='http://draftingmanuals.tpub.com/14262/img/14262_140_2.jpg'>
represents the following:
However, when I download the notebook as PDF via LaTeX (pdf) the result is without the figure:
Is this a bug or can I avoid this somehow?
This is not really a bug, but a known limitation. Actually there are two issues in your example:
the raw html <img> tag gets stripped when the markdown cells are converted by pandoc to latex (see pandoc docu).
you link to a remote image, which is (currently) not downloaded prior to the conversion.
Thus, it is a bit tricky to get what you desire. The first issue may be overcome by means of a custom filter and custom template. For the second, you may need a custom preprocessor.
Alternatively, you could use python with urllib (e.g. Downloading a picture via urllib and python) and matplotlib to display this image. Such embedded images are converted fine.
I'm currently working on a Qt program that works with images that are supplied by the users. One problem I've run into is that a lot of images are saved with the wrong extension - e.g. an image is saved in JPG format but has a PNG extension.
Qt doesn't seem to deal well with this. When I load an image like this into a QImage, the QImage fails to load. I've been looking through the docs, but I haven't come across anything relating to this.
Other programs I've used are able to correctly identify the image as a JPG despite the PNG extension, so there should be no reason for Qt to be unable to do this, but I'm not having any luck.
Any suggestions?
I solved this by using a QImageReader. An example is shown below using PySide.
First I created an instance of QImageReader and set it to read the format from the content.
image_reader = QtGui.QImageReader()
image_reader.setDecideFromContent(True)
This setting tells the reader to only look at the image's data to determine its format and not the extension.
Then I set the filename to the filename of the image I wanted to load and called read().
image_reader.setFileName(file_path_here)
image = image_reader.read()
Read returns a QImage object, so I proceeded with the rest of my code from there.
I'm trying to make colored boxes using Sphinx for Python.
For example, this website has a lot of gray div or boxes (not the Note ones): http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html
I'm wondering how they manage to create thoses boxes since this website is also created using sphinx.
One thing I found, is that Sphinx has built in colored boxes as shown here: http://openalea.gforge.inria.fr/doc/openalea/doc/_build/html/source/sphinx/rest_syntax.html#colored-boxes-note-seealso-todo-and-warnings. Those boxes would work perfectly for me if they didn't have the words "Note:", "SeeAlso" or "Warning" in the beginning.
Any help is greatly appreciated.
Things like notes, warnings, and such are called admonitions. Unfortunately, you can't create ones that don't have a title, as it's required by reStructuredText.
The other boxes on that page are from code blocks. Code blocks are run through the Pygments color syntax highlighter.
There are a couple of other ways to get what you want. You could embed raw HTML, but that's frowned upon. The other choice might be to write an extension to create a directive that gives you the functionality you need.
This is a simple source code block.