Lapton图像转换为jpeg

Lapton image converting to jpeg on fly

本文关键字:jpeg 转换 图像 Lapton      更新时间:2023-09-26

我正在将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控件仅适用于Internet Explorer,因为它们是Microsoft工具包的一部分。要运行.exe,通常需要向服务器发出请求,然后服务器会发回程序输出的响应。以下是使用PHP和AJAX的方法:

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

在服务器上,在网页所在目录中名为run-executable.php的文件中:

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

请确保PHP有权在您的服务器上运行此程序。