我想通过JavaScript将SVG转换为位图图像(如JPEG,PNG等).
尝试创建
第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) 我试图让用户下载SVG图形作为PNG.您可以通过JSFIDDLE访问代码
SVG到CANVAS部分无法正常工作.
已经添加了canvg和Mozillas的代码,它们都没有工作.还添加了Canvas2Image,如果canvas有元素,它应该有效.