Questions tagged [zlib]

zlib is a library used for data compression. Also a crucial component of many software platforms including Linux, Mac OS X, and the iOS

zlib is a library (current version: 1.2.8, released April 28, 2013) that is very widely used for doing data compression. It is open source software written in C, and is unencumbered by patents. It supports three principal compression formats:

  • format Raw compressed data
  • format data (essentially just raw data with a small header)
  • format data (the raw data with a considerably more sophisticated header)

Documentation may be found in RFC-1950 (zlib), RFC-1951 (deflate), and RFC-1952 (gzip).

The zlib library was created by Jean-loup Gailly and Mark Adler.

2362 questions
1192
votes
3 answers

How are zlib, gzip and zip related? What do they have in common and how are they different?

The compression algorithm used in zlib is essentially the same as that in gzip and zip. What are gzip and zip? How are they different and how are they same?
Abhishek Jain
  • 9,614
  • 5
  • 26
  • 40
129
votes
13 answers

Ubuntu rails install fails on zlib

I've just moved over to Ubuntu 8.10 as my dev box; it's my first serious foray into Linux as a daily-use OS, and I'm having a hard time getting Rails going. I have followed a number of tutorials which all seem to work fine, but when I try and use…
Paul
  • 35,689
  • 11
  • 93
  • 122
122
votes
3 answers

How can I decompress a gzip stream with zlib?

Gzip format files (created with the gzip program, for example) use the "deflate" compression algorithm, which is the same compression algorithm as what zlib uses. However, when using zlib to inflate a gzip compressed file, the library returns a…
Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
95
votes
6 answers

What does a zlib header look like?

In my project I need to know what a zlib header looks like. I've heard it's rather simple but I cannot find any description of the zlib header. For example, does it contain a magic number?
unixman83
  • 9,421
  • 10
  • 68
  • 102
92
votes
5 answers

sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings

Using SQLite3 in Python, I am trying to store a compressed version of a snippet of UTF-8 HTML code. Code looks like this: ... c = connection.cursor() c.execute('create table blah (cid integer primary key,html blob)') ... c.execute('insert or ignore…
R. Hill
  • 3,582
  • 1
  • 20
  • 19
91
votes
4 answers

Deflate compression browser compatibility and advantages over GZIP

UPDATE Feb 10 2012: zOompf has completed some very thorough research on this very topic here. It trumps any findings below. UPDATE Sept 11 2010: A testing platform has been created for this here HTTP 1.1 definitions of GZIP and DEFLATE (zlib)…
David Murdoch
  • 87,823
  • 39
  • 148
  • 191
85
votes
11 answers

How do I ungzip (decompress) a NodeJS request's module gzip response body?

How do I unzip a gzipped body in a request's module response? I have tried several examples around the web but none of them appear to work. request(url, function(err, response, body) { if(err) { handleError(err) } else { …
izk
  • 1,189
  • 2
  • 8
  • 23
81
votes
2 answers

How to fix fatal error: zlib.h: no such file or directory?

I'm trying to compile miniSAT on Kali Linux 64 bits but I keep getting the error message: fatal error: zlib.h: no such file or directory I have read that there might be a linking problem that makes the compiler unable to find the header files, but…
user3043108
  • 965
  • 1
  • 8
  • 10
79
votes
9 answers

no module named zlib

First, please bear with me. I have hard time telling others my problem and this is a long thread... I am using pythonbrew to run multiple versions of python in Ubuntu 10.10. For installing pythonbrew and how it works, please refers to this link…
CppLearner
  • 16,273
  • 32
  • 108
  • 163
78
votes
5 answers

Compilation error - missing zlib.h

I am trying to compile software on Blue Gene Q using IBM XL compilers and I got this error message: "iostreams/zlib.cpp", line 19.10: 1540-0836 (S) The #include file "zlib.h" is not found. make[3]: *** [zlib.o] Error 1 I have installed a new…
didymos
  • 1,191
  • 3
  • 10
  • 13
75
votes
4 answers

Convert from '_io.BytesIO' to a bytes-like object in python3.6?

I am using this function to uncompress the body of a HTTP response if it is compressed with gzip, compress or deflate. def uncompress_body(self, compression_type, body): if compression_type == 'gzip' or compression_type == 'compress': …
Dan
  • 2,209
  • 3
  • 23
  • 44
72
votes
10 answers

Compression formats with good support for random access within archives?

This is similar to a previous question, but the answers there don't satisfy my needs and my question is slightly different: I currently use gzip compression for some very large files which contain sorted data. When the files are not compressed,…
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
71
votes
9 answers

zlib.error: Error -3 while decompressing: incorrect header check

I have a gzip file and I am trying to read it via Python as below: import zlib do = zlib.decompressobj(16+zlib.MAX_WBITS) fh = open('abc.gz', 'rb') cdata = fh.read() fh.close() data = do.decompress(cdata) it throws this error: zlib.error: Error -3…
VarunVyas
  • 1,357
  • 6
  • 15
  • 23
70
votes
2 answers

Python: Inflate and Deflate implementations

I am interfacing with a server that requires that data sent to it is compressed with Deflate algorithm (Huffman encoding + LZ77) and also sends data that I need to Inflate. I know that Python includes Zlib, and that the C libraries in Zlib support…
Demi
  • 6,147
  • 7
  • 36
  • 38
66
votes
6 answers

When compressing and encrypting, should I compress first, or encrypt first?

If I were to AES-encrypt a file, and then ZLIB-compress it, would the compression be less efficient than if I first compressed and then encrypted? In other words, should I compress first or encrypt first, or does it matter?
Sei Satzparad
  • 1,137
  • 1
  • 9
  • 12
1
2 3
99 100