matplotlib svg requires plugin to view - django

I am trying to dymamically render an SVG image from matplotlib and insert it into the HTML document.
I am using Cairo.SVG as the matplotlib backend.
Now whenever I try to insert it into the
<img src="/url_to_graph" />
//or
<object data="/url_to_graph" />
I either get nothing or the "Missing Plugins" error from Firefox.
FYI I am using Firefox. Also any other examples of SVG images I find on the web, work just fine - and require no plugin.
Does matplotlib render the SVG images in some special format I don't know about?

Have you tried <object type="image/svg+xml" data="/url_to_graph"></object>?
<img src="/url_to_graph"/> should work.
Are you able to see the svg file with other applications?
My guess is that the file is correctly generated, but the webserver is sending them with an incorrect mime-type.

Related

Edit SVG color in draw.io

I'm following this guide on editing imported svg's in draw.io but with no luck. I am not getting the style options after inserting the editableCssRules=.*; code on the svg itself.
Has anyone else experienced this? I have the latest version installed and have restarted my machine.
I'm expecting to see additional Fill options as the guide suggests.
If possible, please attach SVG image and add the whole SVG code (Ctrl+e) with inserted editableCssRules=.*; so I can see all the details.
Thanks,
Same problem here.
Here is the whole SVG code as requested :
editableCssRules=.*;aspect=fixed;html=1;points=[];align=center;image;fontSize=12;image=img/lib/azure2/general/File.svg;imageBackground=default;sketch=0;
The option editableCssRules just does what it says: it makes the specified CSS classes editables; in your case by using editableCssRules=.*; you are using a Regex expression to make all CSS classes in the SVG editable.
You are not seeing any options appear after modifying the style because with all probability the SVG you are using does not contain any CSS classes.
You will need to edit your SVG file and add the CSS classes that you need and refer to them in the paths, like so:
<style type="text/css">
.st0{fill:#000000;}
</style>
<path class="st0" d="YOUR_PATH_HERE"/>
Now, in draw.io import the SVG again and after adding the editableCssRules=.*; option to the style you should be able to edit its color, like so:

How to have the Layout convert a Page written in Markdown to HTML (using Zurb Foundation Panini)

I am using Zurb's Panini site generator. I am using a CMS that outputs a html file written in markdown to the pages folder. My goal was to have the template file convert the markdown to html.
I've tried to have the markdown get converted before it enters the template file but haven't found a way with the CMS I am using (NetlifyCMS). The CMS also needs to be very user friendly for non-technical users.
<!-- This is the part of the template file -->
<article class="cell medium-5 cell-block-y location-info-container">
<h1 class="location">{{title}}</h1>
{{#markdown}}
{{> body}}
{{/markdown}}
</article>
When running foundation build everything works as expected except for the markdown content is still markdown. I have tried to find a workaround but with no luck so I am open to a solution or workaround. Also, a quick apology in advanced, due to client restrictions I am unable to post links and have the project on a private repository.
You have to add a markdown helper using marked or another markdown library.
https://github.com/zurb/panini/blob/dev/readme.md

How to put an image from a local drive into a cfdocument file?

This will show me the image in a browser:
<cfset myImage=ImageNew("d:\UploadedDocuments\thumbnails\1487862_page_1.jpg")>
<cfimage source="#myImage#" action="writeToBrowser">
But if I use the same code inside of a .pdf file, it generates a small red x. Is this not possible to do?
If the image is already on the drive you don't need CFIMAGE here. You can embed it like so:
<img src="file:///d:\mysite\images\myimage.jpg" width="50" height="60">
You could also use an HTTP Path to it as well - store it at a location accessible by your web server through real or virtual directories use the <img> tag like you normally would.
This post on cfdocument and SSL and this suplimental post on using the file system with cfdocument should help you sort it out.

Coldfusion cfhtmltopdf tag not displaying bmp images

I'm using a <cfhtmltopdf> tag to pull in a .cfm file as a template and create a PDF. All works well when I use jpg for the image format. But if the image is a BMP - for some reason it won't work.
In the template file , I'm using a <cfdirectory> tag with no filter to pull in the images.
<cfdirectory directory="E:\xxx\images\#image_ID#\" name="myDir" type="file" sort="datelastmodified">
then I'm using a <cfloop> to display images from the directory...
<cfloop query="myDir">
<cfif right(myDirMain.name,4) is ".bmp" >
<img src="#request.root#images/#images_ID#/#myDir.name#" border="0" width="230px" style="margin-bottom:15px;" />
</cfif>
This works great for jpg, but when trying to use bmp images - it's no good.
Does anyone know if a reason why bmp images are an issue or does only work with jpg images?
There seems to be a bug in the system that stops PDF's using BMP images. A solution is to convert them using <cfimage> tag before creating the PDF - its workaround that works, even thou it uses a little bit more server resources.

Google Chart Image does not load

Im using Google charts to create a QR Code. It produces the QR Code perfectly when i just paste the link directly on the browser. However, i cannot get it to load as an image. I get a 400 Error Response.
i.e.: http://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/Test%3Fsecret%3DGVFXGN3WIYZEMYKW
pasted directly in the browser works but how can i get it to show as an image?
What am i doing wrong?
<img src="http://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/AEB+Staff+Benefits%3Fsecret%3DGVFXGN3WIYZEMYKW" width="200" height="200" />
You need to URL-encode the /'s (code %2F) in the chl parameter of the URL:
http://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth:%2F%2Ftotp%2FTest%3Fsecret%3DGVFXGN3WIYZEMYKW