compression

ITextSharp returning same size pdf when I'm trying to compress pdf file with different levels

不想你离开。 提交于 2019-11-28 05:13:39
问题 I'm reading a pdf and injecting some content using itextsharp. The resulting byte[] is passed to the method below along with the compression level. public static byte[] method(byte[] pdf,int compressionlevel) { using (MemoryStream outputPdfStream1 = new MemoryStream()) { //PdfReader reader1 = new PdfReader(pdf); //PdfStamper stamper1 = new PdfStamper(reader1, outputPdfStream1); //int level = (int)compressionlevel; //if (level <= 9) // stamper1.Writer.CompressionLevel = (int)compressionlevel;

php - Get compressed contents using cURL

回眸只為那壹抹淺笑 提交于 2019-11-28 05:10:59
问题 I need to get content of various web pages. Some of them are compressed using different methods (gzip, deflate, etc). I've searched on the Internet and found the solution for gzipped content: $ch = curl_init("http://games2k.net/"); curl_setopt($ch,CURLOPT_ENCODING , "gzip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); echo $output; However, this only works for a single method. I need a solution that works for as many compression methods as possible

Image compression like Whatsapp and other messengers on Android

杀马特。学长 韩版系。学妹 提交于 2019-11-28 05:03:57
I am using the following code for image compression. The code compresses image files that are larger than 2 MB. But this code takes time and image quality stays pure. public static String compressImage(String imagePath, Context context) { String resizeImagePath = null; String filePath = imagePath; CustomLogHandler.printDebug(TAG, "resizeImagePath:" + imagePath); Bitmap scaledBitmap = null; int imageScal = 1; // File size greater then 2mb DecimalFormat df = new DecimalFormat("0.00"); File imgFile = new File(filePath); double bytes = imgFile.length(); double kilobytes = (bytes / 1024); double

.NET compression of XML to store in SQL Server database

痞子三分冷 提交于 2019-11-28 05:01:43
问题 Currently our .NET application constructs XML data in memory that we persist to a SQL Server database. The XElement object is converted to a string using ToString() and then stored in a varchar(MAX) column in the DB. We dind't want to use the SQL XML datatype as we didn't need any validation and SQL doesn't need to query the XML at any stage. Although this implementation works fine, we want to reduce the size of the database by compressing the XML before storing it, and decompressing it after

Kafka message codec - compress and decompress

早过忘川 提交于 2019-11-28 04:59:30
问题 When using kafka, I can set a codec by setting the kafka.compression.codec property of my kafka producer. Suppose I use snappy compression in my producer, when consuming the messages from kafka using some kafka-consumer, should I do something to decode the data from snappy or is it some built-in feature of kafka consumer? In the relevant documentation I could not find any property that relates to encoding in kafka consumer (it only relates to the producer). Can someone clear this? 回答1: As per

How can I use deflated/gzipped content with an XHR onProgress function?

前提是你 提交于 2019-11-28 04:29:23
I've seen a bunch of similar questions to this get asked before, but I haven't found one that describes my current problem exactly, so here goes: I have a page which loads a large (between 0.5 and 10 MB) JSON document via AJAX so that the client-side code can process it. Once the file is loaded, I don't have any problems that I don't expect. However, it takes a long time to download, so I tried leveraging the XHR Progress API to render a progress bar to indicate to the user that the document is loading. This worked well. Then, in an effort to speed things up, I tried compressing the output on

how to unpack resources.pak from google chrome?

筅森魡賤 提交于 2019-11-28 04:24:01
There are bunch of interesting files accessible via chrome://resources/* using google chrome. On linux That the content is in /opt/google/chrome/resources.pak . I know I can get the whole sources from http://chromium.googlecode.com/svn/trunk/ but I would like to unpack the resource.pak file. file resources.pak reports just junk. Just to be clear, the question is NOT where to get those resources from . The question is what is the resources.pak file format and how to unpack it? v1nce taken from https://groups.google.com/a/chromium.org/forum/?fromgroups=#!topic/chromium-dev/agGjTt4Dmcw 4 byte

GZipStream doesn't detect corrupt data (even CRC32 passes)?

折月煮酒 提交于 2019-11-28 04:17:50
问题 I'm using GZipStream to compress / decompress data. I chose this over DeflateStream since the documentation states that GZipStream also adds a CRC to detect corrupt data, which is another feature I wanted. My "positive" unit tests are working well in that I can compress some data, save the compressed byte array and then successfully decompress it again. The .NET GZipStream compress and decompress problem post helped me realize that I needed to close the GZipStream before accessing the

How to untar a TAR file using Apache Commons

半城伤御伤魂 提交于 2019-11-28 03:57:55
问题 I'm using the Apache Commons 1.4.1 library to compress and uncompress ".tar.gz" files. I'm having trouble with the last bit -- converting a TarArchiveInputStream into a FileOutputStream . Oddly enough, it's breaking on this line: FileOutputStream fout = new FileOutputStream(destPath); destPath is a File with a Canonical path of: C:\Documents and Settings\Administrator\My Documents\JavaWorkspace\BackupUtility\untarred\Test\subdir\testinsub.txt Error produced: Exception in thread "main" java.io

How to compress URL parameters

孤街醉人 提交于 2019-11-28 03:39:16
Say I have a single-page application that uses a third party API for content. The app’s logic is in-browser only, and there is no backend I can write to. To allow deep-linking into the state of the app, I use pushState to keep track of a few variables that determine the state of the app (note that Ubersicht’s public version doesn’t do this yet). In this case repos , labels , milestones and username , show_open (bool) and with_comments (bool) and without_comments (bool). The URL format is ?label=label_1,label_2,label_3&repos=repo_1… . Values are the usual suspects, roughly [a-zA-Z][a-zA-Z0-9_-]