compression

How can I easily compress and decompress files using zlib? [closed]

纵然是瞬间 提交于 2019-11-27 14:44:49
How can I easily compress and decompress files using zlib? For decompression: char buf[1024*1024*16]; gzFile *fi = (gzFile *)gzopen("file.gz","rb"); gzrewind(fi); while(!gzeof(fi)) { int len = gzread(fi,buf,sizeof(buf)); //buf contains len bytes of decompressed data } gzclose(fi); For compression gzFile *fi = (gzFile *)gzopen("file.gz","wb"); gzwrite(fi,"my decompressed data",strlen("my decompressed data")); gzclose(fi); Please read through this. The information is already available here : That is the first link that shows up even on google. If you can use boost, I would recommend the boost

Does PostgreSQL support transparent compressing of tables (fragments)?

纵饮孤独 提交于 2019-11-27 14:21:41
问题 I'm going to store large amount of data (logs) in fragmented PostgreSQL tables (table per day). I would like to compress some of them to save some space on my discs, but I don't want to lose the ability to query them in the usual manner. Does PostgreSQL support such a transparent compression and where can I read about it in more detail? I think there should be some well-known magic name for such a feature. 回答1: Yes, PostgreSQL will do this automatically for you when they go above a certain

Python library for converting files to MP3 and setting their quality

拜拜、爱过 提交于 2019-11-27 13:56:45
问题 I'm trying to find a Python library that would take an audio file (e.g. .ogg, .wav) and convert it into mp3 for playback on a webpage. Also, any thoughts on setting its quality for playback would be great. Thank you. 回答1: Looks like PyMedia does this: http://pymedia.org/ and some more info here on converting to various formats, whilst setting the bitrate: http://pymedia.org/tut/recode_audio.html e.g. params= { 'id': acodec.getCodecId('mp3'), 'bitrate': r.bitrate, 'sample_rate': r.sample_rate,

How to compress a string?

守給你的承諾、 提交于 2019-11-27 13:45:03
问题 I would like to have a reversible compression for a type of string so that i can include it in URLs without keeping track of what it refers to. The string i would like to compress is SVG path string, here is a short primer: http://apike.ca/prog_svg_paths.html Basically, the string contains a character, followed by arbitrary number of integers, then another character followed by arbitrary number of integers and so on. If anyone knows of a good resource for this, it would be much appreciated!

Make tar file by Java

橙三吉。 提交于 2019-11-27 13:40:54
问题 I want to use Java to compress a folder to a tar file (in programmatic way). I think there must be an open source or library to do it. However, I cannot find such method. Alternatively, could I make a zip file and rename its extended name as .tar? Anyone could suggest a library to do it? Thanks! 回答1: You can use the jtar - Java Tar library. Taken from their site: JTar is a simple Java Tar library, that provides an easy way to create and read tar files using IO streams. The API is very simple

How to zip multiple files using only .net api in c#

若如初见. 提交于 2019-11-27 13:29:26
I like to zip multiple files which are being created dynamically in my web application. Those files should be zipped. For this, i dont want to use any third-party tools. just like to use .net api in c# Ruben Bartelink Use System.IO.Packaging in .NET 3.0+ . See this introduction to System.IO.Packaging If you're able to take a .NET 4.5 dependency, there's a System.IO.Compression.ZipArchive in that universe; see walkthrough article here ( via InfoQ news summary article here ) With the release of the .NET Framework 4.5 this is actually a lot easier now with the updates to System.IO.Compression

How can I easily compress and decompress Strings to/from byte arrays?

守給你的承諾、 提交于 2019-11-27 13:27:17
问题 I have some strings that are roughly 10K characters each. There is plenty of repetition in them. They are serialized JSON objects. I'd like to easily compress them into a byte array, and uncompress them from a byte array. How can I most easily do this? I'm looking for methods so I can do the following: String original = "....long string here with 10K characters..."; byte[] compressed = StringCompressor.compress(original); String decompressed = StringCompressor.decompress(compressed); assert

How do I zip a directory of files using C++?

帅比萌擦擦* 提交于 2019-11-27 13:17:08
问题 I'm working on a project using C++, Boost, and Qt. I understand how to compress single files and bytestreams using, for example, the qCompress() function in Qt. How do I zip a directory of multiple files, including subdirectories? I am looking for a cross-platform (Mac, Win, Linux) solution; I'd prefer not to fire off a bunch of new processes. Is there a standard way to combine bytestreams from multiple files into a zipped archive, or maybe there is a convenience function or method that would

Reduce size of Bitmap to some specified pixel in Android

走远了吗. 提交于 2019-11-27 13:05:26
I would like to reduce My Bitmap image size to maximum of 640px. For example I have Bitmap image of size 1200 x 1200 px .. How can I reduce it to 640px. Divyang Metalia If you pass bitmap width and height then use: public Bitmap getResizedBitmap(Bitmap image, int bitmapWidth, int bitmapHeight) { return Bitmap.createScaledBitmap(image, bitmapWidth, bitmapHeight, true); } If you want to keep the bitmap ratio the same, but reduce it to a maximum side length, use: public Bitmap getResizedBitmap(Bitmap image, int maxSize) { int width = image.getWidth(); int height = image.getHeight(); float

compress/archive folder using php script

☆樱花仙子☆ 提交于 2019-11-27 12:56:08
Is there a way to compress/archive a folder in the server using php script to .zip or .rar or to any other compressed format, so that on request we could archive the folder and then give the download link Thanks in advance Here is an example: <?php // Adding files to a .zip file, no zip file exists it creates a new ZIP file // increase script timeout value ini_set('max_execution_time', 5000); // create object $zip = new ZipArchive(); // open archive if ($zip->open('my-archive.zip', ZIPARCHIVE::CREATE) !== TRUE) { die ("Could not open archive"); } // initialize an iterator // pass it the