本文介绍了Javascript客户端数据压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过processingjs开发一个画笔应用程序。
此API具有函数 loadPixels(),它会将RGB值加载到数组中。
现在我想将数组存储在服务器db中。

I am trying to develop a paint brush application thru processingjs.This API has function loadPixels() that will load the RGB values in to the array.Now i want to store the array in the server db.

问题是数组的大小,当我转换为字符串的大小是5 MB。

The problem is the size of the array, when i convert to a string the size is 5 MB.

最好的解决方案是在javascript级别进行压缩?如何做?

Is the best solution is to do compression at javascript level? How to do it?

推荐答案

请参阅的LZW压缩示例。

See http://rosettacode.org/wiki/LZW_compression#JavaScript for an LZW compression example. It works best on longer strings with repeated patterns.

从:


字符串在
字典中注册,并可用于
后续编码为单个输出
值。该算法在具有重复模式的
数据上工作最好,因此消息的
初始部分将看到
一点压缩。然而,随着消息
增长,压缩比
趋向于渐近到
最大值。

In this way, successively longer strings are registered in the dictionary and made available for subsequent encoding as single output values. The algorithm works best on data with repeated patterns, so the initial parts of a message will see little compression. As the message grows, however, the compression ratio tends asymptotically to the maximum.

这篇关于Javascript客户端数据压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 16:31