electron photobooth.js
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>欢迎系统</title>
<link type="text/css" rel="stylesheet" media="screen" href="page.css" />
<title>Photobooth.js</title>
</head>
<body>
<div id="wrapper">
<h1>
<a name="Demo">HTML5 Webcam for your website</a>
</h1>
<div id="example"></div>
<div id="gallery"></div>
<div class="tab_container">
<div class="tab_content standalone">
<code>
container = document.getElementById( "example" );
gallery = document.getElementById( "gallery" );
myPhotobooth = new Photobooth( container );
myPhotobooth.onImage = function( dataUrl ){
var myImage = document.createElement( "img" );
myImage.src = dataUrl;
gallery.appendChild( myImage );
};
</code>
</div>
</div>
<!--
<h2><a name="dataUrl">Storing dataUrls as image</a></h2>
The user clicked the camera icon, your <code>onImage()</code> function get's called and receives a dataUrl... now what?
<h3>In the Browser</h3>
<h3>Sending the image to the server</h3>
<h3>Storing the image on the server</h3>
Storing your dataUrl as an image is easy when you know how. A dataUrl consists of two parts, seperated by a come: a meta-data section at
the start and the actual data
<code>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAA...</code>
The String after the comma is base64 encoded binary data. So in order to save it as an image you need to
1) Split the dataUrl on the first comma
2) base64 decode the data ( emphasize on DECODE, not encode )
Every major serverside language has a built in way of doing that. E.g.
PHP
$dataUrlParts = explode( ",", $dataUrl);
base64_decode( $dataUrlParts[ 1 ] );
Node.js
var dataUrl = "data:image/jpeg;base64,/9j/4AAQSkZJRgA...";
var buffer = new Buffer( dataUrl.split( "," )[ 1 ], 'base64');
require( "fs" ).writeFileSync( "image.jpg", buffer.toString( 'binary' ), "binary" );
3) Save the result to a file and name it yourImage.png ( or jpeg, depending on the dataUrl type )
-->
</div>
<!-- Insert this line above script imports -->
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<!-- normal script imports etc -->
<!-- Mainly scripts -->
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="photobooth_min.js"></script>
<script type="text/javascript" src="script.js"></script>
<!-- Insert this line after script imports -->
<script>if (window.module) module = window.module;</script>
</body>
<script>
// You can also require other files to run in this process
require('./renderer.js')
</script>
</html>
electron photobooth.js的更多相关文章
- photobooth.js
HTML5 Webcam for your website, photobooth.js
- 基于HTML5实现的超酷摄像头(HTML5 webcam)拍照功能 - photobooth.js
在线演示 WebRTC可能是明年最受关注的HTML5标准了,Mozilla为此开发了一套帮助你控制硬件的API,例如,摄像头,麦克风,或者是加速表.你可以不依赖其它的插件来调用你需要的本机硬件设备. ...
- electron node.js 在 vscode 设置 调试 Debug
在当前工程下,添加一个 .vscode/launch.json 文件 { // Use IntelliSense to learn about possible attributes. // Hove ...
- electron node.js 实现文件拖动读取文件
css/styles.css .for_file_drop { width: 100%; height: 100px; background-color: blueviolet; } index.ht ...
- photobooth.js jquery
<div id="example" class="photobooth" style="width:758px;height:400px&quo ...
- electron中JS报错:require is not defined的问题解决方法
Electron已经发布了6.0正式版,升级后发现原来能运行的代码报错提示require is not defined 解决办法: 修改创建BrowserWindow部分的相关代码,设置属性webPr ...
- (译)通过 HTML、JS 和 Electron 创建你的第一个桌面应用
原文:Creating Your First Desktop App With HTML, JS and Electron 作者:Danny Markov 近年来 web 应用变得越来越强大,但是桌面 ...
- 记一次使用Node.js electron打包网站的记录
具体步骤请参考:http://blog.csdn.net/a727911438/article/details/70834467 打包时出现了不少问题,逐一记录下来以供其他人参考. package.j ...
- 如何用Electron Js创建第一个应用Hello World
什么是Electron Node.js和Chromium的结合品.允许只使用HTML,CSS和JavaScript来开发跨平台桌面应用. 编写第一个Electron程序(Hello World) 在开 ...
随机推荐
- 【Android 开发】: Android 消息处理机制之一: Handler 与 Message
最近几讲内容,我们学习了Android中关于多线程的一些知识,上一讲我们讲解了异步任务 AsyncTask 的操作,Android中还提供了其他的线程操作,如Handler Message Messa ...
- 1031MVCC和事务浅析
转自 http://blog.csdn.net/sofia1217/article/details/50778906 关于MVCC浅析,有些难度http://xuebinbin212.blog.163 ...
- Intent传参数
Intent 是Android 程序中各组件之间进行交互的一种重要方式,它不仅可以指明当前组 件想要执行的动作,还可以在不同组件之间传递数据.Intent 一般可被用于启动活动.启动 服务.以及发送广 ...
- [Elasticsearch] 全文搜索 (一) 基础概念和match查询
全文搜索(Full Text Search) 现在我们已经讨论了搜索结构化数据的一些简单用例,是时候开始探索全文搜索了 - 如何在全文字段中搜索来找到最相关的文档. 对于全文搜索而言,最重要的两个方面 ...
- 简单解决ListView和ScrollView冲突,复杂情况仅供参考
ScrollView嵌套ListView冲突问题的最优解决方案 (转) 记录学习之用 项目做多了之后,会发现其实 ScrollView嵌套ListVew或者GridView等很常用,但是你也会发现各种 ...
- git 创建别名
git config --global alias.shortname command 例子如下 git config --global alias.psm 'push origin master' ...
- hoj2662 状态压缩dp
Pieces Assignment My Tags (Edit) Source : zhouguyue Time limit : 1 sec Memory limit : 64 M S ...
- HTTP之referer(网上搜集)
1.打开httpfox抓包插件,在百度中搜索126.com,搜索项中点击网站入口,通过抓包工具,查看http请求 在http请求的Headers部分可见Referer. Referer http:// ...
- HashMap和TreeMap的区别
HashMap:数组方式存储key/value,线程非安全,允许null作为key和value,key不可以 重复,value允许重复,不保证元素迭代顺序是按照插入时的顺序,key的hash值是先计算 ...
- iOS中通知中心(NSNotificationCenter)的使用总结
一.了解几个相关的类 1.NSNotification 这个类可以理解为一个消息对象,其中有三个成员变量. 这个成员变量是这个消息对象的唯一标识,用于辨别消息对象. @property (readon ...