在结构js中,如何从图像对象获取原始图像源

时间:2022-11-23 11:04:48

In fabric js, I am trying to get the original source of an image, when I use the getElement() and getSrc() methods it shows the correct output, but after applying some image filters the same methods return the new image src (encoded image data) not the original image source.how can I get the original image source after applying the image filters.

在结构js中,我试图获取图像的原始源,当我使用getElement()和getSrc()方法时它显示正确的输出,但在应用了一些图像过滤器后,相同的方法返回新的图像src(编码)图像数据)不是原始图像源。我可以在应用图像过滤器后获得原始图像源。

2 个解决方案

#1


2  

You can get the source of original image by accessing the fabric.object methods.

您可以通过访问fabric.object方法获取原始图像的来源。

// Assuming your image object is selected. 
var object = canvas.getActiveObject(); 

var originalSource = object._originalElement.currentSrc;

will give you the original image source.

将为您提供原始图像源。

#2


0  

You can use getSrc() method:

你可以使用getSrc()方法:

var someUrlOrDataUrl = image.getSrc();

Docs: http://fabricjs.com/docs/fabric.Image.html#getSrc

文档:http://fabricjs.com/docs/fabric.Image.html#getSrc

#1


2  

You can get the source of original image by accessing the fabric.object methods.

您可以通过访问fabric.object方法获取原始图像的来源。

// Assuming your image object is selected. 
var object = canvas.getActiveObject(); 

var originalSource = object._originalElement.currentSrc;

will give you the original image source.

将为您提供原始图像源。

#2


0  

You can use getSrc() method:

你可以使用getSrc()方法:

var someUrlOrDataUrl = image.getSrc();

Docs: http://fabricjs.com/docs/fabric.Image.html#getSrc

文档:http://fabricjs.com/docs/fabric.Image.html#getSrc