compression

What is suitable buffer size for uncompressing large gzip files in gzopen using php?

两盒软妹~` 提交于 2019-12-07 22:42:54
问题 function uncompress($srcName, $dstName) { $sfp = gzopen($srcName, "rb"); $dstName = str_replace('.gz', '', $dstName); $fp = fopen($dstName, "w"); fseek($FileOpen, -4, SEEK_END); $buf = fread($FileOpen, 4); $GZFileSize = end(unpack("V", $buf)); while ($string = gzread($sfp, $GZFileSize)) { fwrite($fp, $string, strlen($string)); } gzclose($sfp); fclose($fp); } I use this code for uncompressing but It does not work and I get following error: Internal Server Error The server encountered an

Is there a fast and non-fancy C# code/algorithm to compress a string of comma separated digits close to maximum info density?

一曲冷凌霜 提交于 2019-12-07 21:24:58
问题 In a nutshell, I programmed myself into a corner by creating a CLR aggregate that performs row id concatenation, so I say: select SumKeys(id), name from SomeTable where name='multiple rows named this' and I get something like: SumKeys name -------- --------- 1,4,495 multiple rows named this But it dies when SumKeys gets > 8000 chars and I don't think I can do anything about it. As a quick fix (it's only failing 1% of the time for my application) I thought I might compress the string down and

Compress Image before Saving to disk in Java

谁都会走 提交于 2019-12-07 20:16:25
问题 Is it possible to compress an image before saving it? I'm using the Robot class to capture images, and it returns a BufferedImage. How can I compress this image and then save it? 回答1: .png files are (losslessly) compressed images. You can use ImageIO.write() to save a .png image: ImageIO.write(myBufferedImage, "png", outputfile); 回答2: There is colour compression ("compression quality") and there is resolution compression ("resizing"). E.g. I got a 4mb photo to 270K using a very low

How to use CompressionCodec in Hadoop

橙三吉。 提交于 2019-12-07 19:18:16
问题 I am doing following to do compression of o/p files from reducer: OutputStream out = ipFs.create( new Path( opDir + "/" + fileName ) ); CompressionCodec codec = new GzipCodec(); OutputStream cs = codec.createOutputStream( out ); BufferedWriter cout = new BufferedWriter( new OutputStreamWriter( cs ) ); cout.write( ... ) But got null pointer exception in line 3: java.lang.NullPointerException at org.apache.hadoop.io.compress.zlib.ZlibFactory.isNativeZlibLoaded(ZlibFactory.java:63) at org.apache

why can't python execute a zip archive passed via stdin?

好久不见. 提交于 2019-12-07 18:45:55
问题 I have a zip archive containing a __main__.py file : archive.zip I can execute it with python archive.zip => OK ! but not with cat archive.zip | python => File "<stdin>", line 1 SyntaxError: Non-ASCII character '\x9e' in file <stdin> on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details why is there a difference between the 2 modes and is there a way to make the pipe work without unzipping outside of python ? I receive this archive over the network and

Java Compress Large File

纵饮孤独 提交于 2019-12-07 18:37:46
问题 I'm working on an app that works with some very large files each are around 180mb and there are 3 of them. I would like to add an option to my app to back these files up by compressing them in a zip or a tar or something. What is the best option would be to compress them down as much as possible in Java? Tar? Zip? Gzip? 回答1: You can do this programmatically using Apache Compress. 回答2: Look at the classes in the java.util.zip package. 回答3: Alright went with zip here is the method i used. I

Compression / Decompression of Strings using the deflater

☆樱花仙子☆ 提交于 2019-12-07 18:19:41
问题 I want to compress/decompress and serialize/deserialize String content. I'm using the following two static functions. /** * Compress data based on the {@link Deflater}. * * @param pToCompress * input byte-array * @return compressed byte-array * @throws NullPointerException * if {@code pToCompress} is {@code null} */ public static byte[] compress(@Nonnull final byte[] pToCompress) { checkNotNull(pToCompress); // Compressed result. byte[] compressed = new byte[] {}; // Create the compressor.

AS3 Video Encoding at runtime with high compression (H.264?)

六月ゝ 毕业季﹏ 提交于 2019-12-07 17:09:35
问题 I need to compress video image data (lets say a display object) in AS3 to a Byte Array with high compression at runtime. Framerate only needs to be around 5 but 1024x768 video needs to go to < 40 Kilobyte per Second without the quality beeing tooo bad. I wrote a custom encoder and got it to around 80-100 Kilobyte per Second for 1024*768 which still is too much and i dont see a lot of improvements to be mad to my encoder. Using JPG or PNG Encoder gives way higher KB/s. Is there any open source

Implementing run-length encoding

萝らか妹 提交于 2019-12-07 16:08:35
问题 I've written a program to perform run length encoding. In typical scenario if the text is AAAAAABBCDEEEEGGHJ run length encoding will make it A6B2C1D1E4G2H1J1 but it was adding extra 1 for each non repeating character. Since i'm compressing BMP files with it, i went with an idea of placing a marker "$" to signify the occurance of a repeating character, (assuming that image files have huge amount of repeating text). So it'd look like $A6$B2CD$E4$G2HJ For the current example it's length is the

Compression webpack plugin

那年仲夏 提交于 2019-12-07 16:00:51
问题 I'm trying to figure out how to properly use webpack-html-plugin with the compression plugin , the documentation of latter is a bit scarce. My webpack configuration declares : output: { filename: 'js/[name]-[hash].js', The compression plugin is run at last new CompressionPlugin({ asset: "[path].gz[query]", algorithm: "gzip" }) In the end the scripts are correctly produced and compressed. js/app-caf3b4b3.js.gz 382 kB [emitted] [big] I can declare the preloading of the gzipped file in the index