Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native javascript decompress function in Chrome/webkit

If you are sending data that is base64-encoded and compressed (using, say, python's zlib.compress()), you can use the native Chrome function window.atob() to convert from base64 to binary data. Is there any similar native javascript function to decompress the zlib-compressed data? Is there some hack to do this?

I know that code to decompress data is already in the browser because it can receive HTML sent with gzip headers.

I am not looking for a javascript library to do decompression.

If you come up a decompression scheme on the browser, I can compress it in that format for transmission. In other words, any decompression routine is acceptable.

like image 275
hughdbrown Avatar asked Dec 07 '22 21:12

hughdbrown


2 Answers

Here's a hack to paint a PNG containing compressed data into a canvas and reading the data back, pixel by pixel: Compression using Canvas and PNG-embedded data. If you want anything that uses a browser's native compression library, here's one option. Unfortuantely, you have to convert the ImageData to string within javascript.

like image 50
yonran Avatar answered Dec 10 '22 11:12

yonran


There is no such function exposed.

like image 24
Domenic Avatar answered Dec 10 '22 11:12

Domenic