High quality JPEG compression with c#

The .Net encoder built-in to the library (at least the default Windows library provided by Microsoft) is pretty bad: http://b9dev.blogspot.com/2013/06/nets-built-in-jpeg-encoder-convenient.html Partial Update I’m now using an approach outlined here, that uses ImageMagick for the resize then jpegoptim for the final compression, with far better results. I realize that’s a partial answer but I’ll expand on … Read more

Using SharpZipLib to unzip specific files?

ZipFile.GetEntry should do the trick: using (var fs = new FileStream(sourcePath, FileMode.Open, FileAccess.Read)) using (var zf = new ZipFile(fs)) { var ze = zf.GetEntry(fileName); if (ze == null) { throw new ArgumentException(fileName, “not found in Zip”); } using (var s = zf.GetInputStream(ze)) { // do something with ZipInputStream } }

Decompress gzip and zlib string in javascript [closed]

Pako is a full and modern Zlib port. Here is a very simple example and you can work from there. Get pako.js and you can decompress byteArray like so: <html> <head> <title>Gunzipping binary gzipped string</title> <script type=”text/javascript” src=”https://stackoverflow.com/questions/14620769/pako.js”></script> <script type=”text/javascript”> // Get datastream as Array, for example: var charData = [31,139,8,0,0,0,0,0,0,3,5,193,219,13,0,16,16,4,192,86,214,151,102,52,33,110,35,66,108,226,60,218,55,147,164,238,24,173,19,143,241,18,85,27,58,203,57,46,29,25,198,34,163,193,247,106,179,134,15,50,167,173,148,48,0,0,0]; // Turn number array … Read more

How to tell if a file is gzip compressed?

The magic number for gzip compressed files is 1f 8b. Although testing for this is not 100% reliable, it is highly unlikely that “ordinary text files” start with those two bytes—in UTF-8 it’s not even legal. Usually gzip compressed files sport the suffix .gz though. Even gzip(1) itself won’t unpack files without it unless you … Read more

How do I concatenate JavaScript files into one file?

I recommend using Apache Ant and YUI Compressor. http://ant.apache.org/ http://yui.github.com/yuicompressor/ Put something like this in the Ant build xml. It will create two files, application.js and application-min.js. <target name=”concatenate” description=”Concatenate all js files”> <concat destfile=”build/application.js”> <fileset dir=”src/js” includes=”*.js” /> </concat> </target> <target name=”compress” depends=”concatenate” description=”Compress application.js to application-min.js”> <apply executable=”java” parallel=”false”> <filelist dir=”build” files=”application.js” /> … Read more

How can I tail a zipped file without reading its entire contents?

No, you can’t. The zipping algorithm works on streams and adapts its internal codings to what the stream contains to achieve its high compression ratio. Without knowing what the contents of the stream are before a certain point, it’s impossible to know how to go about de-compressing from that point on. Any algorithm which allows … Read more