compression

How to reduce the image file size using PIL

泪湿孤枕 提交于 2019-11-26 09:18:24
问题 I am using PIL to resize the images there by converting larger images to smaller ones. Are there any standard ways to reduce the file size of the image without losing the quality too much, lets say the original size of the image is 100KB, i want to get it down to like 5 or 10 KB especially for png and jpeg formats. 回答1: A built-in parameter for saving JPEGs and PNGs is optimize . >>> from PIL import Image # My image is a 200x374 jpeg that is 102kb large >>> foo = Image.open("path\\to\\image

python: read lines from compressed text files

非 Y 不嫁゛ 提交于 2019-11-26 07:38:28
问题 Is it easy to read a line from a gz-compressed text file using python without extracting the file completely? I have a text.gz file which is aroud 200mb. When I extract it, it becomes 7.4gb. And this is not the only file I have to read. For the total process, I have to read 10 files. Although this will be a sequential job, I think it will a smart thing to do it without extarcting the whole information. I do not even know that it is possible. How can it be done using python? I need to read a

How do I concatenate JavaScript files into one file?

蓝咒 提交于 2019-11-26 07:27:48
问题 I want to create a compiled JavaScript file for my website. For development I would prefer to keep the JavaScript in separate files and just as part of my automated scripts concatenate the files into one and run the compressor over it. My problem is that if I use the old DOS copy command it also puts in the EOF markers which the compressor complains about: copy /A *.js compiled.js /Y What are other people doing? 回答1: I recommend using Apache Ant and YUI Compressor. http://ant.apache.org/ http

Compression formats with good support for random access within archives?

家住魔仙堡 提交于 2019-11-26 07:20:59
问题 This is similar to a previous question, but the answers there don\'t satisfy my needs and my question is slightly different: I currently use gzip compression for some very large files which contain sorted data. When the files are not compressed, binary search is a handy and efficient way to support seeking to a location in the sorted data. But when the files are compressed, things get tricky. I recently found out about zlib\'s Z_FULL_FLUSH option, which can be used during compression to

What do you use to minimize and compress JavaScript libraries? [closed]

若如初见. 提交于 2019-11-26 07:19:22
问题 What do you use to minimize and compress JavaScript libraries? 回答1: I use YUI Compressor. Seems to get the job done well! 回答2: I've used YUI Compressor for a long time and have had no problems with it, but have recently started using Google Closure Compiler and had some success with it. My impressions of it so far: It generally outperforms YUI Compressor in terms of file size reduction. By a small amount on simple mode, and by a lot on advanced mode. Simple mode has so far been as reliable as

How can I Zip and Unzip a string using GZIPOutputStream that is compatible with .Net?

别说谁变了你拦得住时间么 提交于 2019-11-26 07:17:36
I need an example for compressing a string using GZip in android. I want to send a string like "hello" to the method and get the following zipped string: BQAAAB+LCAAAAAAABADtvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee++997o7nU4n99//P1xmZAFs9s5K2smeIYCqyB8/fnwfPyLmeVlW/w+GphA2BQAAAA== Then I need to decompress it. Can anybody give me an example and complete the following methods? private String compressString(String input) { //... } private String decompressString(String input) { //... } Thanks, update According to scessor's answer , Now I have the

How to implement GZip compression in ASP.NET?

99封情书 提交于 2019-11-26 06:56:41
问题 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 = new GZipStream(context.Response.Filter, CompressionMode.Compress); HttpContext.Current.Response.AppendHeader(\"Content-encoding\", \"gzip\"); HttpContext.Current.Response.Cache.VaryByHeaders[\"Accept-encoding\"] = true; The above code is only

Python: Inflate and Deflate implementations

痞子三分冷 提交于 2019-11-26 06:27:41
问题 I am interfacing with a server that requires that data sent to it is compressed with Deflate algorithm (Huffman encoding + LZ77) and also sends data that I need to Inflate . I know that Python includes Zlib, and that the C libraries in Zlib support calls to Inflate and Deflate , but these apparently are not provided by the Python Zlib module. It does provide Compress and Decompress , but when I make a call such as the following: result_data = zlib.decompress( base64_decoded_compressed_string

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

本小妞迷上赌 提交于 2019-11-26 06:17:40
问题 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 something in the code. I make the change and commit. 20 minutes later, I find there\'s a bug in this new feature, so I fix it and commit that too. I now have 3 changesets that I would really like to push to the remote repository as one changeset with

Read whole text files from a compression in Spark

独自空忆成欢 提交于 2019-11-26 05:54:27
问题 I have the following problem: suppose that I have a directory containing compressed directories which contain multiple files, stored on HDFS. I want to create an RDD consisting some objects of type T, i.e.: context = new JavaSparkContext(conf); JavaPairRDD<String, String> filesRDD = context.wholeTextFiles(inputDataPath); JavaPairRDD<String, String> filesRDD = context.wholeTextFiles(inputDataPath); JavaRDD<T> processingFiles = filesRDD.map(fileNameContent -> { // The name of the file String