有什么方法可以使用 javascript/jquery 缩短图像数据 URI?

编程入门 行业动态 更新时间:2024-10-25 14:23:43
本文介绍了有什么方法可以使用 javascript/jquery 缩短图像数据 URI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我已使用 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-23 08:49:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1039138.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么   可以使用   图像   方法   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!