问题描述
我一直在使用Google Apps Script开发项目,但是遇到了问题。
我目前正在尝试使用HTML画布获取图像的单个像素(如果您知道从JS图片中获取像素数据的另一种方法,请告诉我)。问题是,Google Apps脚本似乎没有用于画布的getContext方法。我不确定这是否是有目的的,还是某种错误。
代码:
var img = XmlService.createElement('img');
img.src =查询;
var canvas1 = XmlService.createElement(’canvas’);
var context = canvas1.getContext(’2d’);
错误:
我不确定如何解决或解决此问题。
画布元素您的要求是的一部分。 p>
Google Apps脚本不包含canvas元素的功能,实际上它不包含任何Web API元素的功能。
XMLService Service具有,即
I have been working on making projects inside Google Apps Script but came across a problem.
I am currently trying to get the individual pixels of an image, by using an HTML canvas(if you know of another way to get pixel data from an image in JS, please let me know). The problem is, Google Apps Script doesn't seem to have a getContext method for the canvas. I'm not sure if this is done purposely, or if it is some kind of bug.
Code:
var img = XmlService.createElement('img');
img.src = query;
var canvas1 = XmlService.createElement('canvas');
var context = canvas1.getContext('2d');
Error:
I am not sure how to fix or get around this.
The "canvas element" your are asking for is part of Canvas API.
Google Apps Script doesn't include functions for the canvas element, actually it doesn't include any function for any Web APIs elements.
The XMLService Service has the Class Element, this is
这篇关于“ canvas1.getContext不是函数”;通过XmlService创建画布元素时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!