admin管理员组文章数量:1401291
I have converted a canvas image to data URI using jquery and the data URI is too long, say about 800,000 characters.
Is there any methods for reducing/shortening the length of the data URI?
I need to send the image data via GET/POST method but I got an error message that the string length is too long
I have converted a canvas image to data URI using jquery and the data URI is too long, say about 800,000 characters.
Is there any methods for reducing/shortening the length of the data URI?
I need to send the image data via GET/POST method but I got an error message that the string length is too long
Share Improve this question edited May 28, 2015 at 5:36 Antony Varghese asked May 28, 2015 at 5:29 Antony VargheseAntony Varghese 451 silver badge5 bronze badges 4- What problems are you running into that makes the URI too long? – Austin Brunkhorst Commented May 28, 2015 at 5:31
- I need to send the image data URI as an attachment via GET/POST method but I got an error message that the string length is too long – Antony Varghese Commented May 28, 2015 at 5:35
- 1 Why can't you just send the binary data? – BoltClock Commented May 28, 2015 at 5:36
- 800k characters is about 780 kilobytes of data, or 0.76 megabytes, which shouldn't be a problem at all with a POST request. – adeneo Commented May 28, 2015 at 5:37
2 Answers
Reset to default 6canvas.toDataURL() support different image types. You could try the different formats or use jpg and decrease the quality:
e.g. for 100% quality:
canvas.toDataURL("image/jpeg", 1.0)
or for 50%:
canvas.toDataURL("image/jpeg", 0.5)
This should reduce the image size and therefore the amount of image data.
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 pressed.You can check out JavaScript implementation of Gzip
You can try adjusting the image quality i.e (image/jpeg,value from 0-1) But this wont reduce it to a great extent.
本文标签: Is there any method to shorten image data URI using javascriptjqueryStack Overflow
版权声明:本文标题:Is there any method to shorten image data URI using javascriptjquery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744284557a2598814.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论