Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 如何使用节点webkit创建临时图像文件?_Image_Node.js_Node Webkit - Fatal编程技术网

Image 如何使用节点webkit创建临时图像文件?

Image 如何使用节点webkit创建临时图像文件?,image,node.js,node-webkit,Image,Node.js,Node Webkit,我正在使用node webkit开发一个应用程序,以获取TIFF图像的一些数据。由于webkit不支持TIFF图像,我想创建一个临时PNG版本,在应用程序中显示它。我怎么能这样做?在节点webkit(如App.dataPath)中是否有放置临时文件的方法或位置?或者我应该使用另一个节点模块 我期待着很快得到你的答案。谢谢。您不需要创建临时图像文件,请尝试数据URL <h1>You will see an image later</h1> <img id="img"

我正在使用node webkit开发一个应用程序,以获取TIFF图像的一些数据。由于webkit不支持TIFF图像,我想创建一个临时PNG版本,在应用程序中显示它。我怎么能这样做?在节点webkit(如App.dataPath)中是否有放置临时文件的方法或位置?或者我应该使用另一个节点模块


我期待着很快得到你的答案。谢谢。

您不需要创建临时图像文件,请尝试数据URL

<h1>You will see an image later</h1>
<img id="img" src="">
<script type="text/javascript">
  //start js code here
  var data_prefix = "data:image/png;base64,";
  var img = document.getElementById('img');
  var xhr = new XMLHttpRequest();
  xhr.open('GET','https://avatars2.githubusercontent.com/u/1356417?s=140',true);
  xhr.responseType = 'arraybuffer';
  xhr.onload = function(e){
    var arr = new Uint8Array(this.response);
    var raw = String.fromCharCode.apply(null,arr);
    var b64=btoa(raw);
    var dataURL="data:image/jpeg;base64,"+b64;
    img.src = dataURL;
  };
  xhr.send();
</script>
稍后您将看到一幅图像
//从这里开始js代码
var data_prefix=“数据:图像/png;base64”;
var img=document.getElementById('img');
var xhr=new XMLHttpRequest();
xhr.open('GET','https://avatars2.githubusercontent.com/u/1356417?s=140",对),;
xhr.responseType='arraybuffer';
xhr.onload=函数(e){
var arr=新的Uint8Array(this.response);
var raw=String.fromCharCode.apply(null,arr);
var b64=btoa(原始);
var dataURL=“数据:图像/jpeg;base64,”+b64;
img.src=数据URL;
};
xhr.send();

< >是的,如果您在纯客户端解决方案之后考虑使用HTML5文件API。

你有保险吗

当然,这是假设您正在客户端Javascript中操作TIFF数据,并希望将其写入一个临时的
.png
文件