compression

Java: Error creating a GZIPInputStream: Not in GZIP format

核能气质少年 提交于 2019-11-28 03:38:13
问题 I am trying to use the following Java code to compress and uncompress a String. But the line that creates a new GZipInputStream object out of a new ByteArrayInputStream object throws a "java.util.zip.ZipException: Not in GZIP format" exception. Does anyone know how to solve this? String orig = "............."; // compress it ByteArrayOutputStream baostream = new ByteArrayOutputStream(); OutputStream outStream = new GZIPOutputStream(baostream); outStream.write(orig.getBytes()); outStream.close

Why JPEG compression processes image by 8x8 blocks?

对着背影说爱祢 提交于 2019-11-28 03:36:46
问题 Why JPEG compression processes image by 8x8 blocks instead of applying Discrete Cosine Transform to the whole image? 回答1: 8 X 8 was chosen after numerous experiments with other sizes. The conclusions of experiments are: 1. Any matrices of sizes greater than 8 X 8 are harder to do mathematical operations (like transforms etc..) or not supported by hardware or take longer time. 2. Any matrices of sizes less than 8 X 8 dont have enough information to continue along with the pipeline. It results

Why do real-world servers prefer gzip over deflate encoding?

佐手、 提交于 2019-11-28 03:26:41
We already know deflate encoding is a winner over gzip with respect to speed of encoding, decoding and compression size. So why do no large sites (that I can find) send it (when I use a browser that accepts it)? Yahoo claims deflate is "less effective". Why? I maintain HTTP server software that prefers deflate, so I'd like to know if there's some really good reason not to continue doing so. There is some confusion about the naming between the specifications and the HTTP: DEFLATE as defined by RFC 1951 is a compressed data format . ZLIB as defined by RFC 1950 is a compressed data format that

How to compress a directory with libbz2 in C++

孤街醉人 提交于 2019-11-28 03:04:17
问题 I need to create a tarball of a directory and then compress it with bz2 in C++. Is there any decent tutorial on using libtar and libbz2? 回答1: Okay, I worked up a quick example for you. No error checking and various arbitrary decisions, but it works. libbzip2 has fairly good web documentation. libtar, not so much, but there are manpages in the package, an example, and a documented header file. The below can be built with g++ C++TarBz2.cpp -ltar -lbz2 -o C++TarBz2.exe : #include <sys/types.h>

Most Efficient Multipage RequireJS and Almond setup

此生再无相见时 提交于 2019-11-28 03:02:27
I have multiple pages on a site using RequireJS, and most pages have unique functionality. All of them share a host of common modules (jQuery, Backbone, and more); all of them have their own unique modules, as well. I'm wondering what is the best way to optimize this code using r.js . I see a number of alternatives suggested by different parts of RequireJS's and Almond's documentation and examples -- so I came up with the following list of possibilities I see, and I'm asking which one is most recommended (or if there's another better way): Optimize a single JS file for the whole site , using

how to config grunt.js to minify files separately

半城伤御伤魂 提交于 2019-11-28 02:59:05
there are some js files in static/js/ 1. a.js 2. b.js 3. c.js how to config grunt.js to get below files: 1. a.min.js 2. b.min.js 3. c.min.js as far, I have to type specific file name: min: { dist: { src: 'js/**/*.js', dest: 'js/min/xxx.min.js' } } Had the same problem and found a solution that would automatically minify all my scripts separately: uglify: { build: { files: [{ expand: true, src: '**/*.js', dest: 'build/scripts', cwd: 'app/scripts' }] } } In grunt 0.4 you can specify multiple dest/src pairs like this: uglify: { dist: { files: { 'dist/main.js': 'src/main.js', 'dist/widget.js':

Tool to Unminify / Decompress JavaScript [closed]

﹥>﹥吖頭↗ 提交于 2019-11-28 01:47:11
Are there any command line scripts and/or online tools that can reverse the effects of minification similar to how Tidy can clean up horrific HTML? (I'm specifically looking to unminify a minified JavaScript file, so variable renaming might still be an issue.) You can use this : http://jsbeautifier.org/ But it depends on the minify method you are using, this one only formats the code, it doesn't change variable names, nor uncompress base62 encoding. edit: in fact it can unpack "packed" scripts (packed with Dean Edward's packer : http://dean.edwards.name/packer/ ) Jon Adams Chrome developer

Inno Setup - How to add cancel button to decompressing page?

我们两清 提交于 2019-11-28 00:36:21
I am using this code: How to add .arc decompression to Inno Setup? (answer of Martin Prikryl). I want to add a cancel button at decompressing page and active this page for others functions (when the decompression is active, this page is inactive and, for example, i can not press on/off button of my music implementation). How to add a cancel button to decompression page? and how to active this page for others functions? I have reimplemented the solution from How to add .arc decompression to Inno Setup? using unarc.dll (from FreeArc+InnoSetup package ISFreeArcExtract v.4.0.rar ). It greatly

Is there a quality, file-size, or other benefit to JPEG sizes being multiples of 8px or 16px?

江枫思渺然 提交于 2019-11-28 00:17:21
问题 The JPEG compression encoding process splits a given image into blocks of 8x8 pixels, working with these blocks in future lossy and lossless compressions. [source] It is also mentioned that if the image is a multiple 1MCU block (defined as a Minimum Coded Unit, 'usually 16 pixels in both directions') that lossless alterations to a JPEG can be performed. [source] I am working with product images and would like to know both if, and how much benefit can be derived from using multiples of 16 in

What's a good compression library for Java?

老子叫甜甜 提交于 2019-11-28 00:17:17
I need to compress portions of our application's network traffic for performance. I presume this means I need to stay away from some of the newer algorithms like bzip2, which I think I have heard is slower. Steve g You can use Deflater / Inflater which is built into the JDK. There are also GZIPInputStream and GZIPOutputStream, but it really depends on your exact use. Edit: Reading further comments it looks like the network taffic is HTTP. Depending on the server, it probably has support for compression (especially with deflate/gzip). The problem then becomes on the client. If the client is a