I usually add my image on github blog by copying the locally saved image into
github code editor.
Then it makes a image's link, it usually saved into form of HTML.
but sometimes it makes MD(markdown) format, not HTML.
What is the condition of image link creation?
I want to know what determines the format of the image's link
I made 2 different images, and copied them into same github code editor.
then it returns 2 different image link, but the formats are different, too.
enter image description here
I am working with the very good mxgraph library. I base my application on the GraphEditor example.
I have used my own PNG icons. Everything works well. For a better rendering I want to use SVG images. I have tried to remplace PNG image by SVG image, it's working well in the javascript : I can drag and drop, then resize ... I can save and open correctly.
But if I try to export in PNG or PDF, the SVG images or not exported (the rest of the diagram is OK).
I tested SVG images on draw.io and it is correctly exported.
Is there any option or parameter to fix that ?
I looked to another request : SVG shapes instead of stencils
The solution might be with mxImage but I can't find how to use it.
Any help welcome.
I am generating one html file. The file should display 3 divs. Each div will have:
background-image: url("something.png");
Now, when user will download the file (e.g. chooses "save page as"), he will only get the HTML - without the actual png file.
How can I make sure that he is able to see them, without making him download them?
I've tried converting to SVG, but this pictures have multiple colors, and it totally failed.
You could just make it data-based, i.e.
background:url(data:image/png;base64,base64-encoded-image-goes-here)
It is possible to have jpg, gif, etc.
You can get the base64 image by using an image-to-base64 converter.
I copied an SVG map at the end of this page, that is map of Iran and I want to use it in my website.
I copied its code and paste it in a file what named map.svg and when I open it by Firefox that just show me the svg source!
How to copy that source that show me the map?
I cannot post a comment because of my reputation level, but the svg you're trying to copy is working perfectly for me
make sure you copy everything between and including the tags <svg> .. </svg>
you will not get the styling and events, just a black SVG map
I am developing a web application which takes user inputs, does engineering calculations and then shows a formatted report or graphic. The graphics are engineering diagrams and not always standard graphs like Pie charts. The primary function of the application is to enable the user to copy these diagrams from the browser to a Word or Excel document.
I have to make a choice on using SVG generated in the client, or bitmaps generated on the server side. I prefer the SVG approach and the prototyping looks good, however, copying the SVG graph seems to be inconsistently supported across browsers, especially if the graph is shown in a div (i.e. the entire page is not .svg). For example, IE shows a "copy" on the dropdown, but copies only part of the SVG graphic to the clipboard. Chrome gives no copy option if I right click on the SVG graphic.
If I Google around, I am surprised to see how little information there is on the problem of getting an SVG image from a web application onto the clipboard.
My question for readers who have worked through this problem:
Is there a consistent way to get an SVG element that is part of a
larger DOM onto the clipboard, preferably using JavaScript;
Any other recommendations given my requirement of getting graphics
from browser onto clipboard?
Instead of displaying the svg as an svg element display it with the img tag. This has some limitations (you can't display custom fonts or embed scripts, but it seems this is not your use case). The upside is that is behaves exactly as you would expect from an image (you can drag and drop, right click and copy, etc).
To do this you need to encode it with base64. You can do it server side or client side with js. Your image tag ends up looking something like...
<img src="data:image/svg;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolf" width="..." height="..." alt="diagram" />
Where R0lGODlhEAAQAMQ... is your base64 encoded svg.
Javascript and the Clipboard is a pain in the a**.
There is one workaround for your situation that I know of:
If it is a true SVG file, in Chrome, right click on the image, and select "Inspect Element".
The browser console will open, and should open to an SVG element that you can select in the inspector.
Right click the svg tag in the inspector, and select 'Copy' or 'Copy as HTML' (I can't recall the choices exactly)
Paste that text into a text file and then save the file with an SVG extension. It can then be opened in any browser or SVG editing program. Inkscape is a good choice for editing and debugging, as you can view and edit the entire SVG file in an XML style editor.
**Sorry - I missed the first part of your request. That will be tricky. I'm afraid I can't help with that part. Copy and paste probably isn't your best option though. There are PHP classes to both manipulate SVG and Excel files, and that will likely be the way to go.
I managed to copy SVG content to clipboard as plain XML text, but it appeared useless for me, because Inkscape (which I use to work with SVG), doesn't recognize the text in clipboard as SVG. It appears that copying text of SVG is not enough and the browser should also set the mime-type to image/svg+xml.
I tried several tricks with HTML5 Clipboard API, but ended with the problem that Chrome is unable to export the mime-type into system clipboard. The relevant bug report and jsfiddle link for it is here https://code.google.com/p/chromium/issues/detail?id=504700
I faced the same problem in a project. The customer wanted to have a rather complicated chart. We decided to develop it using svg. Worked perfect, but the customer wanted to be able to download the graph as a picture. After a search on the internet, we found saveSvgAsPng (https://www.npmjs.com/package/save-svg-as-png). That did the trick for us.
The graph is in the page like this:
<svg id="graph1" style="width: 700px; height: 700px">
....
.....
...
</svg>
The graph is shown, but can't be downloaded or copied. So, here are the steps I took:
I installed the package mentioned above.
<script src="/path/to/lib/save-svg-as-png/lib/saveSvgAsPng.js"></script>
Added "display: none:" to the svg code, otherwise we will have two instances of the same image:
<svg id="graph1" style="width: 700px; height: 700px; display: none">
<!-- // code goes here -->
</svg>
Directly after the declaration of the svg graph, I added a new image. This image, is the placeholder for the new png image representation for the svg image. I hide it on first, to prevent the image from flickering while loading. The source is initially not specified:
<img id="graph1_as_png" src="" width="700" height="700" style="display: none">
After the newly added image, I added some lines of code, that to the conversion trick:
<script>
svgAsPngUri(document.getElementById("graph1")).then(uri => {
$("#graph1_as_png").attr('src', uri).show();
});
</script>
The source of the second image is filled up with a BASE64 encoded version of the svg. After the conversion, the image is shown. Now we have exactly the same image as our svg image, but with the possibility to download or to copy the image.
I hope this will help you as wel..