我已经做了很多关于使用JS拍摄照片的搜索,但似乎没有用处。有人说使用activeX控件,这不适合我的情况。我希望能够使用JS拍摄照片并将其上传到服务器。 由于您在Chrome扩展程序中使用了此功能, 标签API 有一个名为 captureVisibleTab ,它允许捕获指定窗口中当前选定选项卡的可见区域。
要使用该功能,您只需将选项卡添加到您的权限清单中即可。从背景页面或弹出窗口(或任何其他扩展页面),只需调用该方法即可:
chrome。 tabs.captureVisibleTab(null,{},function(image){ //您可以添加该图像HTML5画布,或者Element。});您可以通过添加{quality:50}来控制属性并更改格式上面提到的文档。
HTML5的美妙之处在于,您可以使用HTML5 Canvas修改图片,您可以非常轻松地操纵,转换,修改,剪辑任何您想要的内容!
希望这就是你要找的!新年快乐!
I have made a lot of search regarding taking pictures using JS but none seem to be useful. Some say using activeX controls, which doesn't suit my situation. I was hoping to take picture using JS and upload it a server.
解决方案Since you're using this in Chrome Extensions, the Tab API has a method called captureVisibleTab, which allows captures the visible area of the currently selected tab in the specified window.
To use that you just add "tabs" to your permissions manifest. And from your background page, or popup (or any other extension page), you just call that method like this:
chrome.tabs.captureVisibleTab(null, {}, function (image) { // You can add that image HTML5 canvas, or Element. });You can control the property by adding {quality: 50} and change the format too, all described within the docs mentioned above.
The beauty of HTML5, you can alter that image with HTML5 Canvas, you can manipulate, transform, modify, clip, anything you want, very easily!
Hope that is what your looking for! Happy New Years!
更多推荐
使用javascript为Chrome扩展添加屏幕截图
发布评论