Questions tagged [compression]

The name given to the process of encoding data such that it uses lesser number of bits as compared to the original representation.

There are a number of techniques to compress information, with most algorithms working to compress image, speech, music or video. Encoding the same information in lesser bits results in saving some crucial resource such as transmission bandwidth or hard-disk space. Compression algorithms also take advantage of human perception to further reduce the size of information. By encoding the same piece of information with fewer bits in places that the human brain is not accustomed to perceiving as well as other parts, substantial gains in compression ratios can be achieved.

9175 questions
110
votes
3 answers

Create a .tar.bz2 file Linux

On my Linux machine, I wish to create a .tar.bz2 file of a certain folder. Once I place myself in that folder (in the terminal), what do I type in the terminal command line to place the compressed folder in the home directory of my machine? Let's…
Adam
  • 2,384
  • 7
  • 29
  • 66
106
votes
13 answers

Node.js: Gzip compression?

Am I wrong in finding that Node.js does no gzip compression and there are no modules out there to perform gzip compression? How can anyone use a web server that has no compression? What am I missing here? Should I try to—gasp—port the algorithm to…
SnickersAreMyFave
  • 5,047
  • 8
  • 26
  • 24
103
votes
3 answers

How do I enable gzip compression when using MVC3 on IIS7?

Does anybody know how to enable gzip compression in MVC 3? I'm using IIS7. Google Chrome Audit's result: Enable gzip compression (4) Compressing the following resources with gzip could reduce their transfer size by about two thirds (~92.23KB): …
imarkic84
  • 1,031
  • 2
  • 8
  • 3
103
votes
4 answers

Read lines from compressed text files

Is it possible to read a line from a gzip-compressed text file using Python without extracting the file completely? I have a text.gz file which is around 200 MB. When I extract it, it becomes 7.4 GB. And this is not the only file I have to read. For…
delete_this_account
  • 2,376
  • 7
  • 23
  • 31
97
votes
6 answers

How do I gzip compress a string in Python?

How do I gzip compress a string in Python? gzip.GzipFile exists, but that's for file objects - what about with plain strings?
Bdfy
  • 23,141
  • 55
  • 131
  • 179
96
votes
1 answer

uncompress a .txt.gz file in mac?

How do I uncompress a .txt.gz file in mac? I already tried unzip file.txt.gz but it says it cannot find zipfile directory in one of file.txt.gz or file.txt.gz.zip, and cannot find file.txt.gz.ZIP, period.
Sagar
  • 1,149
  • 1
  • 7
  • 12
96
votes
11 answers

With Mercurial, how can I "compress" a series of changesets into one before pushing?

Let's say I have a local and a remote Mercurial repository. Now, I start working on a feature. I work on it, and when I think it's done, I commit the changeset. Testing it a bit more, I find that I could further improve this feature by tweaking…
Lucas
  • 6,328
  • 8
  • 37
  • 49
95
votes
3 answers

python zipfile module doesn't seem to be compressing my files

I made a little helper function: import zipfile def main(archive_list=[],zfilename='default.zip'): print zfilename zout = zipfile.ZipFile(zfilename, "w") for fname in archive_list: print "writing: ", fname …
Ramy
  • 20,541
  • 41
  • 103
  • 153
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
10 answers

Zip folder in C#

What is an example (simple code) of how to zip a folder in C#? Update: I do not see namespace ICSharpCode. I downloaded ICSharpCode.SharpZipLib.dll but I do not know where to copy that DLL file. What do I need to do to see this namespace? And do…
Marko
83
votes
9 answers

How to implement GZip compression in ASP.NET?

I am trying to implement GZip compression for my asp.net page (including my CSS and JS files). I tried the following code, but it only compresses my .aspx page (found it from YSlow) HttpContext context = HttpContext.Current; context.Response.Filter…
djmzfKnm
  • 26,679
  • 70
  • 166
  • 227
81
votes
12 answers

How to compress URL parameters

Say I have a single-page application that uses a third party API for content. The app’s logic is in-browser only; there is no backend I can write to. To allow deep-linking into the state of the app, I use pushState() to keep track of a few variables…
Jan Lehnardt
  • 2,619
  • 1
  • 17
  • 14
81
votes
5 answers

How to detect type of compression used on the file? (if no file extension is specified)

How can one detect the type of compression used on the file? (assuming that .zip, .gz, .xz or any other extension is not specified). Is this information stored somewhere in the header of that file?
22332112
  • 2,337
  • 5
  • 21
  • 42
79
votes
15 answers

Best Compression algorithm for a sequence of integers

I have a large array with a range of integers that are mostly continuous, eg 1-100, 110-160, etc. All integers are positive. What would be the best algorithm to compress this? I tried the deflate algorithm but that gives me only 50%…
pdeva
  • 43,605
  • 46
  • 133
  • 171
78
votes
4 answers

Which compression method to use in PHP?

I have a large amount of data to move using two PHP scripts: one on the client side using a command line PHP script and other behind Apache. I POST the data to the server side and use php://input stream to save it on the web-server end. To prevent…
Milan Babuškov
  • 59,775
  • 49
  • 126
  • 179