compression

How to open and read LZMA file in-memory

末鹿安然 提交于 2019-12-30 18:50:10
问题 I have a giant file, let's call it one-csv-file.xz . It is an XZ-compressed CSV file. How can I open and parse through the file without first decompressing it to disk? What if the file is, for example, 100 GB? Python cannot read all of that into memory at once, of course. Will it page or run out of memory? 回答1: You can iterate through an LZMAFile object import lzma # python 3, try lzmaffi in python 2 with open('one-csv-file.xz') as compressed: with lzma.LZMAFile(compressed) as uncompressed:

Compressing and decompressing streams

百般思念 提交于 2019-12-30 18:25:24
问题 I found this article about simple proxy server implemented in JAVA: http://www.java2s.com/Code/Java/Network-Protocol/Asimpleproxyserver.htm The code simply gets some stream from the client, after sends it to the server and after it gets stream from the server and sends the response to the client. What I would like to do is to compress this streams before it is sent and decompress after it is received. I found the class GZIPInputStream but I'm not sure how to use it and what I found on

node.js image compression

独自空忆成欢 提交于 2019-12-30 18:10:14
问题 I'm looking for a node.js module. A node.js module that I can use to serve compressed images of the sort by the smushit service. Is there such a module? Thanks 回答1: Maybe https://github.com/bentruyman/pulverizr? 回答2: maybe you can use imagemin github:https://github.com/imagemin/imagemin It can work. 回答3: You can use GraphicsMagick for node.js. 回答4: For anyone googling this, GraphicsMagic is hosted on NPM as gm: https://www.npmjs.org/package/gm 回答5: Detected path and can use combination

node.js image compression

人盡茶涼 提交于 2019-12-30 18:10:12
问题 I'm looking for a node.js module. A node.js module that I can use to serve compressed images of the sort by the smushit service. Is there such a module? Thanks 回答1: Maybe https://github.com/bentruyman/pulverizr? 回答2: maybe you can use imagemin github:https://github.com/imagemin/imagemin It can work. 回答3: You can use GraphicsMagick for node.js. 回答4: For anyone googling this, GraphicsMagic is hosted on NPM as gm: https://www.npmjs.org/package/gm 回答5: Detected path and can use combination

uncompressing tar.Z file with python?

删除回忆录丶 提交于 2019-12-30 11:37:08
问题 I need to write a python script that retrieves tar.Z files from an FTP server, and uncompress them on a windows machine. tar.Z, if I understood correctly is the result of a compress command in Unix. Python doesn't seem to know how to handle these, it's not gz, nor bz2 or zip. Does anyone know a library that would handle these ? Thanks in advance 回答1: If GZIP -- the application -- can handle it, you have two choices. Try the Python gzip library. It may work. Use subprocess Popen to run gzip

Decompressing a .gz file via PHP

坚强是说给别人听的谎言 提交于 2019-12-30 10:34:27
问题 I need to be able to decompress through PHP some data that I have in a string which uses the gzip format. I need to do this via PHP, not by calling - through system for example - an external program. I go to the documentation and I find gzdecode. Too bad it doesn't exist. Digging further through google it appears this function was implemented in PHP6, which I cannot use. (Interestingly enough gzencode exists and is working). I believe - but I'm not sure - that the gzip format simply has some

Adding a big text file to assets folder

谁都会走 提交于 2019-12-30 10:34:23
问题 I'm developing an Android 2.2 application. I want to add some big text files (4.5MB or more) to Android project. First I don't know if I can add such kind of big files to assets folder. But, if I can, is it possible to compress them? How can I compress files? and decompress? Any other better way to add big text files to Android project? Thanks. 回答1: Files over 1 MB placed in the assets folder won't be readable from your app (It'll throw an exception). This is because they get compressed

How to determine png dimensions based on file size limit?

寵の児 提交于 2019-12-30 10:28:24
问题 If an app has business logic that says a 24-bit PNG can never exceed 250KB, is it possible to predict what the largest width & height that the image could be and still fit under the 250KB requirement? Since there are a lot of variables with color-depth, alpha channels, etc... is it possible to know this? Or to get even close? 回答1: It is possible, but it probably isn't useful. PNG's zlib compression has a maximum compression ratio of 1032:1 (for a long sequence of the same byte value). So 250

How to compress HTTP response headers?

左心房为你撑大大i 提交于 2019-12-30 09:56:29
问题 At the Velocity 2010 conference, Google said that header compression can yield big gains: Hölzle noted a glaring inefficiency in the handling of web page headers, which provide information about a user’s IP address, browser and other session data. The average web page makes 44 calls to different resources, with many of those requests including repetitive header data. Holzle said compressing the headers produces an 88 percent page load improvement for some leading sites. How does one ensure

How to check whether file exists in zip file using dotnetzip

笑着哭i 提交于 2019-12-30 09:34:25
问题 I am creating zip using dotnetzip library. But I don't know how to check if a file exists in the zip. If the file exists then I will update the file with path. public void makezip(string flname) { string fln =flname; string curFile = @"d:\crs.zip"; if (File.Exists(curFile)) { ZipFile zipfl = ZipFile.Read(@"D:\crs.zip"); var result = zipfl.Any(entry => entry.FileName.EndsWith(@fln)); if (result == true) { zipfl.UpdateFile(@fln); }else{ zipfl.AddFile(@fln); } zipfl.Save(@"d:\crs.zip"); } else {