繁体   English   中英

Lapton图像即时转换为jpeg

[英]Lapton image converting to jpeg on fly

我正在将jpeg图像压缩为.lep,现在我有一个.exe文件,可以将.lep图像转换回jpeg,我想编写一个简单的jsp文件,在其中我可以即时解码和.lep图像并在浏览器中显示,下面的代码仅适用于IE

<html>
<head>
<script type="text/javascript">

    function foo() {
        console.log("Testing");
        var WshShell = new ActiveXObject("WScript.Shell");
        var oExec = WshShell.Exec("D:\lepton.exe D:\img.lep");

        var strOutput = oExec.StdOut.ReadAll();
        console.log(strOutput);

        document.getElementById("img1").src = "D:\img.jpg";
    }
 </script>
 </head>
 <body>
        <button onclick="foo()">Click me</button>
        <img id="img1" alt="Smiley face" >
 </body>
 </html>

ActiveX控件是Microsoft工具包的一部分,因此只能与Internet Explorer一起使用。 要运行.exe ,通常需要向服务器发出请求,然后服务器将程序输出的响应发送回去。 使用PHP和AJAX的方法如下:

$.ajax({
    type: "GET",
    url: 'run-executable.php',
    success: function(data){
        alert(data);
    }
});

在服务器上,位于您的网页所在目录内的名为run-executable.php中:

<?php exec("/path/to/exe"); ?>

确保PHP有权在您的服务器上运行它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM