相关疑难解决方法(0)

JavaScript使用基于64位编码的代码来减小图像的大小和质量

我有一个基于图像的64位编码代码.现在我想减小图像的大小和质量.我怎么能用JavaScript或jQuery做到这一点?

这里解决的是工作代码:Index.php 这是我的javascript代码

<html>
<head>
<title>JavaScript Image Resize</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
body {
    font-size: 16px;
    font-family: Arial;
}

</style>
<script type="text/javascript">
function _resize(img, maxWidth, maxHeight) 
{
    var ratio = 1;
    var canvas = document.createElement("canvas");
    canvas.style.display="none";
    document.body.appendChild(canvas);

    var canvasCopy = document.createElement("canvas");
    canvasCopy.style.display="none";
    document.body.appendChild(canvasCopy);

    var ctx = canvas.getContext("2d");
    var copyContext = canvasCopy.getContext("2d");

        if(img.width > maxWidth)
                ratio = maxWidth / img.width;
        else if(img.height > maxHeight)
                ratio = maxHeight / img.height;

        canvasCopy.width = img.width;
        canvasCopy.height = img.height;
try {
        copyContext.drawImage(img, 0, 0); …
Run Code Online (Sandbox Code Playgroud)

javascript jquery image-processing

18
推荐指数
2
解决办法
5万
查看次数

标签 统计

image-processing ×1

javascript ×1

jquery ×1