compression

Compress and decompress a Stream with Compression.DeflateStream

烂漫一生 提交于 2019-12-18 03:56:39
问题 I am trying to compress and decompress a Stream using Compression.DeflateStream. Compressing seems to work correctly since the code below compresses my Stream to a 110 bytes long array. However, reading the decompressed Stream results in an empty string. class Program { static void Main(string[] args) { // Compress a random string value string value = Path.GetRandomFileName(); byte[] compressedBytes; using (var writer = new StreamWriter(new MemoryStream())) { writer.Write(value); writer.Flush

Is there a safe way to run a diff on two zip compressed files?

我是研究僧i 提交于 2019-12-18 03:54:48
问题 Seems this would not be a deterministic thing, or is there a way to do this reliably? 回答1: If you're using gzip, you can do something like this: # diff <(zcat file1.gz) <(zcat file2.gz) 回答2: Reliable: unzip both, diff. I have no idea if that answer's good enough for your use, but it works. 回答3: In general, you cannot avoid decompressing and then comparing. Different compressors will result in different DEFLATEd byte streams, which when INFLATEd result in the same original text. You cannot

Is there a safe way to run a diff on two zip compressed files?

岁酱吖の 提交于 2019-12-18 03:54:25
问题 Seems this would not be a deterministic thing, or is there a way to do this reliably? 回答1: If you're using gzip, you can do something like this: # diff <(zcat file1.gz) <(zcat file2.gz) 回答2: Reliable: unzip both, diff. I have no idea if that answer's good enough for your use, but it works. 回答3: In general, you cannot avoid decompressing and then comparing. Different compressors will result in different DEFLATEd byte streams, which when INFLATEd result in the same original text. You cannot

Random access gzip stream

帅比萌擦擦* 提交于 2019-12-18 02:41:40
问题 I'd like to be able to do random access into a gzipped file. I can afford to do some preprocessing on it (say, build some kind of index), provided that the result of the preprocessing is much smaller than the file itself. Any advice? My thoughts were: Hack on an existing gzip implementation and serialize its decompressor state every, say, 1 megabyte of compressed data. Then to do random access, deserialize the decompressor state and read from the megabyte boundary. This seems hard, especially

How to Compress a JSONObject send it over Http in Android?

点点圈 提交于 2019-12-18 01:08:22
问题 I am sending a JSONObject to my Webserver from an Android client using the code from this example. Reproducing code here import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; int TIMEOUT_MILLISEC = 10000; // = 10 seconds

Unzip a zip file using zlib

人走茶凉 提交于 2019-12-17 23:41:21
问题 I have an archive.zip which contains two crypted ".txt" files. I would like to decompress the archive in order to retrieve those 2 files. Here's what I've done so far: FILE *FileIn = fopen("./archive.zip", "rb"); if (FileIn) printf("file opened\n"); else printf("unable to open file\n"); fseek(FileIn, 0, SEEK_END); unsigned long FileInSize = ftell(FileIn); printf("size of input compressed file : %u\n", FileInSize); void *CompDataBuff = malloc(FileInSize); void *UnCompDataBuff = NULL; int fd =

LZW compression/decompression under low memory conditions

落花浮王杯 提交于 2019-12-17 22:43:17
问题 Can anybody give pointers how I can implement lzw compression/decompression in low memory conditions (< 2k). is that possible? 回答1: The zlib library that everyone uses is bloated among other problems (for embedded). I am pretty sure it wont work for your case. I had a little more memory maybe 16K and couldnt get it to fit. It allocates and zeros large chunks of memory and keeps copies of stuff, etc. The algorithm can maybe do it but finding existing code is the challenge. I went with http:/

Can you use gzip over SSL? And Connection: Keep-Alive headers

纵然是瞬间 提交于 2019-12-17 21:46:58
问题 I'm evaluating the front end performance of a secure (SSL) web app here at work and I'm wondering if it's possible to compress text files (html/css/javascript) over SSL. I've done some googling around but haven't found anything specifically related to SSL. If it's possible, is it even worth the extra CPU cycles since responses are also being encrypted? Would compressing responses hurt performance? Also, I'm wanting to make sure we're keeping the SSL connection alive so we're not making SSL

How does Git save space and is fast at the same time?

我是研究僧i 提交于 2019-12-17 21:45:31
问题 I just saw the first Git tutorial at http://blip.tv/play/Aeu2CAI. How does Git store all the versions of all the files, and how can it still be more economical in space than Subversion which saves only the latest version of the code? I know this can be done using compression, but that would be at the cost of speed, but this also says that Git is much faster (though where it gains the maximum is the fact that most of its operations are offline). So, my guess is that Git compresses data

Compress jpeg on server with PHP

ⅰ亾dé卋堺 提交于 2019-12-17 20:09:34
问题 I have a site with about 1500 JPEG images, and I want to compress them all. Going through the directories is not a problem, but I cannot seem to find a function that compresses a JPEG that is already on the server (I don't want to upload a new one), and replaces the old one. Does PHP have a built in function for this? If not, how do I read the JPEG from the folder into the script? Thanks. 回答1: you're not telling if you're using GD, so i assume this. $img = imagecreatefromjpeg("myimage.jpg");