compression

C# Creating and Sending Zip files with gmail

假装没事ソ 提交于 2019-12-02 04:33:57
I'm trying to Zip and send .csv files using C#. I create the files, zip them and send them using an SMTP Gmail host. It can sometimes take this email several hours to reach it's destination. For testing I am using very small files so size isn't an issue. If I try to "manually" send these zips using gmail I get the following error: "myFile.csv.zip contains an executable file. For security reasons, Gmail does not allow you to send this type of file." I think there might be a problem with my compression method but it's very straight forward: string compressedFile = fileName + ".zip"; FileInfo fi

Python decompress gzip data in memory without file

左心房为你撑大大i 提交于 2019-12-02 04:31:41
问题 I have gzipped data from HTTP reply. I have following code: def gzipDecode(self, content): import StringIO import gzip outFilePath = 'test' compressedFile = StringIO.StringIO(content) decompressedFile = gzip.GzipFile(fileobj=compressedFile) with open(outFilePath, 'w') as outfile: outfile.write(decompressedFile.read()) data = '' with open(outFilePath, 'r') as myfile: data=myfile.read().replace('\n', '') return data which decompress input gzipped content and return string (http reply is gzipped

String to string compression algorithm?

偶尔善良 提交于 2019-12-02 04:14:22
问题 I'm looking for an algorithm that would compress some string to another string (i.e. without "\0" or special control characters), but I can't find anything on the internet. Is there such an algorithm? It doesn't have to be particularly efficient, just something basic. 回答1: Apparently you have some specific character set in mind and you want to use it for both the original string and the compressed string. Standard compression routines (e.g. gzip) work on byte strings. One idea is to take

Why does gzip/deflate compressing a small file result in many trailing zeroes?

时光毁灭记忆、已成空白 提交于 2019-12-02 04:06:47
问题 I'm using the following code to compress a small (~4kB) HTML file in C#. byte[] fileBuffer = ReadFully(inFile, ResponsePacket.maxResponsePayloadLength); // Read the entire requested HTML file into a memory buffer inFile.Close(); // Close the requested HTML file byte[] payload; using (MemoryStream compMS = new MemoryStream()) // Create a new memory stream to hold the compressed HTML data { using (GZipStream gzip = new GZipStream(compMS, CompressionMode.Compress)) // Create a new GZip object

Why do image compression algorithms process the image by sub-blocks?

痞子三分冷 提交于 2019-12-02 03:00:30
问题 For instance, consider the DFT or DCT. Precisely, what would be the differences between an image transformed by sub-blocks, and an image transformed whole? Is the resulting file size smaller? Is the algorithm more efficient? Does the transformed image look different? Thanks. 回答1: They are designed so they can be implemented using parallel hardware. Each block is independent, and can be calculated on a different computing node, or shared out to as many nodes as you have. Also as noted in an

Uncompress data in memory using Boost gzip_decompressor

我们两清 提交于 2019-12-02 02:46:44
问题 I'm trying to decompress binary data in memory using Boost gzip_decompressor . From this answer, I adapted the following code: vector<char> unzip(const vector<char> compressed) { vector<char> decompressed = vector<char>(); boost::iostreams::filtering_ostream os; os.push(boost::iostreams::gzip_decompressor()); os.push(boost::iostreams::back_inserter(decompressed)); boost::iostreams::write(os, &compressed[0], compressed.size()); return decompressed; } However, the returned vector has zero

String to string compression algorithm?

荒凉一梦 提交于 2019-12-02 02:23:01
I'm looking for an algorithm that would compress some string to another string (i.e. without "\0" or special control characters), but I can't find anything on the internet. Is there such an algorithm? It doesn't have to be particularly efficient, just something basic. Apparently you have some specific character set in mind and you want to use it for both the original string and the compressed string. Standard compression routines (e.g. gzip ) work on byte strings. One idea is to take existing code (e.g. gzip's) and rewrite it to use your character set instead of bytes. Another is to construct

Compress and decompress string in c#

淺唱寂寞╮ 提交于 2019-12-02 02:03:13
I know there is system.io.compression.gzipstream but it accept a stream as arguments. I'm looking for a method that accept string eg. string compress(string stringtocompress,compressionlevel level); string decompress(string stringtodecompress); you should try this: using System; using System.IO; using System.IO.Compression; using System.Text; ... public static string Compress(string s) { var bytes = Encoding.Unicode.GetBytes(s); using (var msi = new MemoryStream(bytes)) using (var mso = new MemoryStream()) { using (var gs = new GZipStream(mso, CompressionMode.Compress)) { msi.CopyTo(gs); }

.zip file created by Java doesn't support Chinese(utf-8)

不问归期 提交于 2019-12-02 00:10:38
I want to create a .zip file using Java(jdk, ant.jar or commons-compress). But if the ZipEntry's name contains non-English(eg. Chinese, Japanese), it will display unreadable code in WinRAR or Windows Compress(commons-compress display correctly in WinRAR). Who can help me!!! J-16 SDiZ You have hit one of the Top 25 java bug . Good news is this is already resolved. Bad news it it is fixed only in JDK7. See this entry for details. Alternativlly, you can use Arcmexer (readonly). try this by using apache commons compress, import java.io.*; import org.apache.commons.compress.archivers.zip

Uncompress data in memory using Boost gzip_decompressor

拜拜、爱过 提交于 2019-12-01 23:27:21
I'm trying to decompress binary data in memory using Boost gzip_decompressor . From this answer , I adapted the following code: vector<char> unzip(const vector<char> compressed) { vector<char> decompressed = vector<char>(); boost::iostreams::filtering_ostream os; os.push(boost::iostreams::gzip_decompressor()); os.push(boost::iostreams::back_inserter(decompressed)); boost::iostreams::write(os, &compressed[0], compressed.size()); return decompressed; } However, the returned vector has zero length. What am I doing wrong? I tried calling flush() on the os stream, but it did not make a difference