compression

fileinput usage with openbook=hook_compressed

为君一笑 提交于 2019-12-11 13:52:32
问题 I'm trying fileinput to read some compressed files, and I tried the following three methods, however, none of them really works. file=os.join.path(path+filename) for i,line in enumerate(fileinput([file], openhook=gzip.open)): for i,line in enumerate(fileinput.input(openhook=fileinput.hook_compressed(file1,'r'))): for i,line in enumerate(fileinput.FileInput(openhook=fileinput.hook_compressed(file1,'r'))): For the first command, errors are like: 'module' object is not callable For the third

How do I group integers in a Ruby array so that I can compress the array?

守給你的承諾、 提交于 2019-12-11 13:34:51
问题 Assuming I have an array of integers in Ruby 2.1+ such as: [2, 4, 4, 1, 6, 7, 5, 5, 5, 5, 5, 5, 5, 5] What I would like to do is compress the array so that I get something like: [2, [4, 2], 1, 6, 7, [5, 8]] Notice the two internal arrays just contain two elements. The value and the number of times it is repeated. Also, the order is important. **EDIT* Sorry, I didn't mention that for single elements, I'm not concerned with the count. So [2,1]...[1,1],[6,1]... doesn't concern me. In fact, I'm

compress text before storing in mysql database

早过忘川 提交于 2019-12-11 12:17:08
问题 I am developing a web application using php and MySQL. I am compressing the text using gzcompress() php function before storing in MySQL database / storing compressed form of text in database. My Question is that is this OK? to store compressed form? Or this method will create trouble or not for me? I am compressing text for saving disk space. 回答1: I honestly don't see any practical benefits of storing compressed texts. Sure you could probably save some space, but if your text is so big that

zLib inflate has empty result in some cases

早过忘川 提交于 2019-12-11 12:02:54
问题 My program processes PDF files and reads some streams out of them. There are also FlateEncoded streams in there. I use the "inflate()" method of zlib to decompress them. This usually works really well with the following code: static string FlateDecode(string s){ int factor = 50; z_stream stream; while(true){ char * out = new char[s.length()*factor]; stream.zalloc = Z_NULL; stream.zfree = Z_NULL; stream.opaque = Z_NULL; stream.avail_in = s.length(); stream.next_in = (Bytef*)s.c_str(); stream

Algorithm issue with TIFF CCITT Group 4 decompression (T.6)

巧了我就是萌 提交于 2019-12-11 11:35:12
问题 I work for an engineering design house and we store black and white design drawings in TIFF format compressed with CCITT Group 4 compression. I am working on a project to improve our software for working with these drawings. I need to be able to load the raw data into my program obviously, so I must decompress it. I tried using LibTiff but gave up on that rather quickly. It wouldn't build, generating over 2000 errors. I found many obvious syntax errors in the library and concluded it was junk

How to access a zipEntry from a streamed zip file in memory

假如想象 提交于 2019-12-11 11:12:25
问题 I'm currently implementing an Ereader library (skyepub) that requires that I implement a method that checks if a zipEntry exists or not. In their demo version, the solution is simple: public boolean isExists(String baseDirectory,String contentPath) { setupZipFile(baseDirectory,contentPath); if (this.isCustomFont(contentPath)) { String path = baseDirectory +"/"+ contentPath; File file = new File(path); return file.exists(); } ZipEntry entry = this.getZipEntry(contentPath); if (entry==null)

Compress CSS/JavaScript before publish/package

爷,独闯天下 提交于 2019-12-11 10:57:59
问题 I've been reading this post about minifying and compressing static files like CSS/JS within the publish/package event in VS2010. I wonder if it also is possible to combine the files to one CSS file and one JS file? And how that can be done in this process. 回答1: As far as minifying and compressing your CSS and JS files - that shouldn't be any issue. However - when it comes to actually combining all of your related files (CSS & JS) into single files, you will need to be careful to avoid any

PHP: Converting a KML into a KMZ

微笑、不失礼 提交于 2019-12-11 10:30:08
问题 I've got a custom php script that creates a KML file. Now how do I convert it into KMZ? Should I just run gzcompress() on it? Or should I create a ZipArchive? 回答1: Creating a ZipArchive worked. I add the already created kml file to it. $zip = new ZipArchive(); $zip_name = "c:\\kml\\".$sFilename.".kmz"; $filename = "c:\\kml\\".$sFilename.".kml"; $zip->open($zip_name, ZIPARCHIVE::CREATE); $zip->addFile($filename); $zip->close(); 来源: https://stackoverflow.com/questions/21149383/php-converting-a

ServiceStack - How To Compress Requests From Client

眉间皱痕 提交于 2019-12-11 10:06:35
问题 Does anyone have any examples of how to setup ServiceStack on the client side to automatically compress all requests using GZip? I've found good examples of how to automatically decompress requests on the server side using a Module but nothing for the client side. Thanks! 回答1: ServiceStack's Service Clients automatically sends the Accept-Encoding: gzip,deflate HTTP Header indicating it accepts a GZip or Deflated response. It can be disabled with: client.DisableAutoCompression = true; If the

Compress image without saving it

被刻印的时光 ゝ 提交于 2019-12-11 09:57:22
问题 I am using the following code to compress an image and it does a nice job but I want to use the compressed image not save it. So right now I have to save the image then read it in again which is slow. Is there a way of compressing it with out saving it. private void compress(System.Drawing.Image img, long quality, ImageCodecInfo codec) { EncoderParameters parameters = new EncoderParameters(1); parameters.Param[0] = new EncoderParameter(Encoder.Quality, quality); img.Save("check1.jpg", codec,