我想通过JavaScript将SVG转换为位图图像(如JPEG,PNG等).
我有一个小项目,用户使用Raphael构建图表,然后将组合图表导出到图像中进行保存.
问题是它必须脱机运行.http://www.nihilogic.dk/labs/canvas2image/不会起作用,因为它需要画布,而不是Raphael生成的SVG.
有没有办法(javascript)我可以从SVG导出图像?
尝试创建
第1步 - 让用户通过Ajax,Raphael和Raphael freetransform上传图像.
步骤2 - 单击按钮以显示合并上载图像中的一个图像.(问题):
我找到了关于转换Raphael svg 1
2
3的类似帖子
,
所以我也使用Canvg但得到console.log :Resource interpreted as image but transferred with MIME type text/html error: image "" not found.
请帮我找到解决方法.或任何线索如何达到相同的目标(将上传的几个Raphael svg图像转换为一个png/jpeg)?
谢谢!
步骤1
// upload images and ajax show in page
var paper = Raphael($('.upload_img')[0], 400, 200);
$('.upload_btn').click(function(){
...
$.ajax({
type: "POST",
url: "index.php",
data: fd,
processData: false,
contentType: false,
success: function(html){
var session = ..., file = ... type = ...;
function register(el) {
// …Run Code Online (Sandbox Code Playgroud)