compression

How to compress JSON with PHP?

﹥>﹥吖頭↗ 提交于 2019-11-28 17:57:19
I'm writing a little analysis page which will help me hunt down bugs in an application. In essence it allows to visually compare actual data and log entries, plus perform a bit of analysis on the data. Since this is for debugging only and since I will be deploying this on the live site I want it to have as little server load as possible. Several of the analysis options will include rather heavy substring searching or n 2 operations, so I'm going to offload this to the client. This means that the PHP page will just take the data from the tables and logs, JSON some of it, and write it out. The

PHP: How to compress images without losing visible quality (automatically)?

强颜欢笑 提交于 2019-11-28 17:18:28
I'm wondering how to figure out the best compress rate (small filesize + no quality loss) automatically. At the moment I'm using imagejpeg() with $quality = 85 for each .jpg . PageSpeed (Chrome Plugin) suggests, to lower the quality of a few images to save some kb. The percentage of reduction is different. I'd like to write a cronjob that crawls a specific directory and optimizes every image. How does PageSpeed or TinyPNG figure out the best optimized quality and is this possible with PHP or another serverside-language? TinyPNG uses pngquant . Pngquant has option to set desired quality,

Creating a zipped/compressed folder in Windows using Powershell or the command line

余生长醉 提交于 2019-11-28 17:16:32
I am creating a nightly database schema file and would like to put all the files created each night, one for each database, into a folder and compress that folder. I have a PowerShell script that creates the schema.Only creation script of the db's and then adds all the files to a new folder. The problem lies within the compression portion of this process. Does anybody have any idea if this can be accomplished with the pre-installed Windows utility that handles folder compression? It would be best to use that utility if possible rather than something like 7zip (I don't feel like installing 7zip

Disable Asset Minification in Rails Production

China☆狼群 提交于 2019-11-28 16:59:52
In order to debug javascript in my heroku production environment, I need to disable asset compression (or at least compression of javascript). I tried config.assets.compress = false along with config.assets.debug = true , and the compressed assets were still used. I then deleted the compressed assets, at which point no assets were rendered at all. I added config.assets.enabled = false , which did not help. I tried copying the uncompressed assets into various directories, including the application root, public, and public/assets (the latter two using both the folders "images, "javascripts", and

How to zip a WordprocessingML folder into readable docx

末鹿安然 提交于 2019-11-28 16:51:24
I have been trying to write a simple Markdown -> docx parser/writer, but am completely stuck with the last part, which should be the easiest: i.e. compressing the folder into a .docx that Word, or any other .docx reader, will recognize. My parser-writer is irrelevant really: I have this problem if I simply unzip any old Word-produced *.docx and then try to recompress it with the usual compression utilities, giving it the file-ending docx. Is there some mysterious header I should be adding, or do I need a special OPC compression utility, or what? I don't so much want a tool that will do this,

Data Compression Algorithms

半腔热情 提交于 2019-11-28 16:49:12
问题 I was wondering if anyone has a list of data compression algorithms. I know basically nothing about data compression and I was hoping to learn more about different algorithms and see which ones are the newest and have yet to be developed on a lot of ASICs. I'm hoping to implement a data compression ASIC which is independent of the type of data coming in (audio,video,images,etc.) If my question is too open ended, please let me know and I'll revise. Thank you 回答1: There are a ton of compression

Compact decompression library for embedded use

若如初见. 提交于 2019-11-28 16:45:11
We're currently creating a device for a customer that will get a block of data (like, say, 5-10KB) from a PC application. This is a bit simplified, so assume that the data must be passed and uncompressed a lot, not just once a year. The communication channel is really, really slow, so we'd like to compress the data beforehand, pass to the device and let it uncompress the data to its internal flash. The device itself, however, runs on a micro controller that is not really fast and does not have a lot of memory. It has enough flash memory to store the result, and can uncompress the data block as

Removing extra whitespace from generated HTML in MVC

别来无恙 提交于 2019-11-28 16:42:30
I have an MVC application view that is generating quite a large HTML table of values (>20MB). I am compressing the view in the controller using a compression filter internal class CompressFilter : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { HttpRequestBase request = filterContext.HttpContext.Request; string acceptEncoding = request.Headers["Accept-Encoding"]; if (string.IsNullOrEmpty(acceptEncoding)) return; acceptEncoding = acceptEncoding.ToUpperInvariant(); HttpResponseBase response = filterContext.HttpContext.Response; if

How can I protect myself from a zip bomb?

橙三吉。 提交于 2019-11-28 16:38:47
I just read about zip bombs , i.e. zip files that contain very large amount of highly compressible data (00000000000000000...). When opened they fill the server's disk. How can I detect a zip file is a zip bomb before unzipping it? UPDATE Can you tell me how is this done in Python or Java? Try this in Python: import zipfile z = zipfile.ZipFile('c:/a_zip_file') print 'total files size=', sum(e.file_size for e in z.infolist()) z.close() Zip is, erm, an "interesting" format. A robust solution is to stream the data out, and stop when you have had enough. In Java, use ZipInputStream rather than

Can you use gzip over SSL? And Connection: Keep-Alive headers

大兔子大兔子 提交于 2019-11-28 16:32:10
I'm evaluating the front end performance of a secure (SSL) web app here at work and I'm wondering if it's possible to compress text files (html/css/javascript) over SSL. I've done some googling around but haven't found anything specifically related to SSL. If it's possible, is it even worth the extra CPU cycles since responses are also being encrypted? Would compressing responses hurt performance? Also, I'm wanting to make sure we're keeping the SSL connection alive so we're not making SSL handshakes over and over. I'm not seeing Connection: Keep-Alive in the response headers. I do see Keep