有什么方法可以使用 javascript/jquery 缩短图像数据 URI? [英] Is there any method to shorten image data URI using javascript/jquery?

查看:27
本文介绍了有什么方法可以使用 javascript/jquery 缩短图像数据 URI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用 jquery 将画布图像转换为数据 URI,但数据 URI 太长,例如大约 800,000 个字符.

I have converted a canvas image to data URI using jquery and the data URI is too long, say about 800,000 characters.

有没有什么方法可以减少/缩短数据URI的长度?

Is there any methods for reducing/shortening the length of the data URI?

我需要通过 GET/POST 方法发送图像数据,但我收到一条错误消息,指出字符串长度太长

I need to send the image data via GET/POST method but I got an error message that the string length is too long

推荐答案

你不能.因为这是canvasimagedata(这是一个base64字符串).如果你减少它,一些数据可能会丢失.Base64本身是相当压缩的.你可以查看Gzip的JavaScript实现

You cant.As this is the canvasimagedata(which is a base64 string).If you reduce it,some of the data maybe lost.Base64 itself is fairly compressed.You can check out JavaScript implementation of Gzip

您可以尝试调整图像质量,即(图像/jpeg,值从 0-1)但这不会在很大程度上减少它.

You can try adjusting the image quality i.e (image/jpeg,value from 0-1) But this wont reduce it to a great extent.

这篇关于有什么方法可以使用 javascript/jquery 缩短图像数据 URI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆